Post Reply 
List indexing problems
10-01-2016, 05:16 AM
Post: #1
List indexing problems
I'm encountering a lot more trouble with list subscripting than it feels I should for such a basic operation.

Code:

LOCAL a:={1,2,3};
a(1);   // returns 1
a[1];   // returns 2

But:

Code:

{1,2,3}(1);   // → {1,2,3}
{1,2,3}[1];   // → {[1],[2],[3]} (?!)
{"a","b","c"}(2);   // Error: Bad argument type

And, most importantly to me at the moment:

Code:

LOCAL a:={{"A",1,2},{"B",3,4}};
EXECON("&1(1)",a);   // Expected: retrieve a list of first elements in each sublist
   // Actual result: “Error: Bad argument type”
   // Same result if [ ] are used instead of ( )

Someone please tell me there's an alternative function or syntax for list indexing that works reliably.…
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
List indexing problems - TravisE - 10-01-2016 05:16 AM
RE: List indexing problems - TravisE - 10-01-2016, 09:29 PM
RE: List indexing problems - StephenG1CMZ - 10-02-2016, 07:38 AM
RE: List indexing problems - TravisE - 10-02-2016, 07:32 PM



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