Post Reply 
List indexing problems
10-01-2016, 08:36 AM
Post: #2
RE: List indexing problems
(10-01-2016 05:16 AM)TravisE Wrote:  But:

Code:

{1,2,3}(1);   // → {1,2,3}
{1,2,3}[1];   // → {[1],[2],[3]} (?!)
{"a","b","c"}(2);   // Error: Bad argument type
Here the issue comes from the implicit multiplication as {1,2,3}(1) is interpreted as {1,2,3}*(1) and not as "take the first element of {1,2,3}".

(10-01-2016 05:16 AM)TravisE Wrote:  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.…

Instead of EXECON try with :
Code:
MAKELIST(a(I,1),I,1,SIZE(a));
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 - Didier Lachieze - 10-01-2016 08:36 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)