Post Reply 
Confused about indexing into lists...
11-05-2017, 01:36 AM
Post: #1
Confused about indexing into lists...
My understanding was that in CAS mode, lists should be indexed using square brackets to avoid confusion with function calls, so I tried the following....

L1:={1,2,3,4,5,6,7,8,9}

When in Home mode, I can type L1(3) or L1[3] and I'll get 3 back....correct...both braces work.

Now, go to CAS mode.

L1(3) works and returns 3...so next I tried the square brackets...

L1[3] gets converted to at(L1,2) and {1,2,3,4,5,6,7,8,9} gets returned??????

So, then I typed...

at(L1,2) and it returned at({1,2,3,4,5,6,7,8,9},2) ????

So, what am I doing wrong?
Find all posts by this user
Quote this message in a reply
11-05-2017, 02:17 AM
Post: #2
RE: Confused about indexing into lists...
(11-05-2017 01:36 AM)webmasterpdx Wrote:  My understanding was that in CAS mode, lists should be indexed using square brackets to avoid confusion with function calls, so I tried the following...

Almost. Use () with all home variables and objects.

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
11-05-2017, 03:08 AM
Post: #3
RE: Confused about indexing into lists...
That's confusing. How does one know if a variable passed into a program is a CAS or Home variable?
Find all posts by this user
Quote this message in a reply
11-05-2017, 03:27 AM
Post: #4
RE: Confused about indexing into lists...
So you're taking arbitrary input into your program and not checking type or what the user gave you before attempting to do something to it?

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
11-05-2017, 03:57 AM
Post: #5
RE: Confused about indexing into lists...
Hmm....if I pass in a home list to a cas function as a list, it gets converted to a cas list and can be addressed with []. So I guess that solves that problem.
It's still pretty confusing though (from the command line).

The other thing that really bugs me is if I am looking for a function that is a cas program, it should be accessible from the toolbox menu, under the USER submenu, like the home functions. It's pretty disconnected to have the cas ones under the variables-CAS-Programs submenu....
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)