如何使用带下标的变量?

问题描述

Mathics 开始,我尝试了:

Subscript[a,0] = 1

但它给出了错误

Subscript[a,0] 中的标签下标受保护。

解决方法

此消息意味着您尝试执行的操作没有意义。下标是一个系统函数,可以防止无意中重新定义,就像加号 (+) 或任何其他内置系统函数一样。

根据:

https://reference.wolfram.com/language/ref/Subscript.html

下标是一个格式为 x_(y) 的对象。

您会收到与尝试相同的错误消息:

 Plus[a,0] = 1

另请注意,Wolfram 语言和数学中的列表从 1 开始,而不是 0。

以下是如何创建列表变量a,其中元素在索引 1 处包含值 1:

$ mathics

Mathics 2.0.1.dev
on CPython 3.8.8 (default,Feb 27 2021,09:08:32) 
using SymPy 1.7.1,mpmath 1.2.1,numpy 1.20.1,cython 0.29.22

Copyright (C) 2011-2021 The Mathics Team.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software,and you are welcome to redistribute it
under certain conditions.
See the documentation for the full license.

Quit by evaluating Quit[] or by pressing CONTROL-D.

In[1]:= a = {1}
Out[1]= {1}

In[2]:= a[[1]]
Out[2]= 1

也许 https://www.wolfram.com/language/fast-introduction-for-programmers/en/lists/https://www.wolfram.com/language/fast-introduction-for-programmers/en/assignments/ 是开始的好地方。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...