Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

symbolic list element as expression? #160

Open
dyc-emet opened this issue Nov 3, 2018 · 5 comments
Open

symbolic list element as expression? #160

dyc-emet opened this issue Nov 3, 2018 · 5 comments

Comments

@dyc-emet
Copy link

dyc-emet commented Nov 3, 2018

Hi,
I noticed that right now the list element cannot be used as an expression, e.g.
a[i]
,in which a and i are just two symbols, will trigger an error.

@dyc-emet
Copy link
Author

The expression is not supported and is supposed to trigger an error.

@jlapeyre
Copy link
Owner

Thanks. Yes, it is not supported. But I had considered a more user-friendly (Symata-level) error. For instance

symata 12> 3[4]
BoundsError("part specification 4 is longer than the depth of the object.", #undef)

Although the Symata-level error is no longer working as I want now. As you can see. It is thrown to Julia.

But, I think I did implement subscripted variables. I'll search for if/how I did it.

@jlapeyre
Copy link
Owner

You can use a(i). This is analogous to a[i] in Mathematica. And Symata a[i] is Mathematica a[[i]]. I think I have not yet implemented a(i), a(3), a(j) etc as a hash table, which would improve effciency. But, I'm not sure.

I'll open this again, because the error is exposing the implementation.

@jlapeyre jlapeyre reopened this Nov 10, 2018
@jlapeyre
Copy link
Owner

More precisely, a[i] is supported. It is equivalent to Mathematica a[[i]]. But, if the "part specification is longer than the depth of the object", then an error is thrown.

symata 1> a[1]
BoundsError("part specification 1 is longer than the depth of the object.", #undef) ...

symata 1> b = [0]
Out(1) = [0]

symata 2> b[1]
Out(2) = 0

@jlapeyre
Copy link
Owner

jlapeyre commented Dec 10, 2018

Mathematica

In[1]:= Table[a[i], {i, 10}]

Out[1]= {a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10]}

Symata

symata 1> Table(a(i) , [i, 10])
Out(1) = [a(1),a(2),a(3),a(4),a(5),a(6),a(7),a(8),a(9),a(10)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants