Post Reply 
Size of a list passed to a function?
04-14-2017, 02:58 PM
Post: #6
RE: Size of a list passed to a function?
(04-14-2017 02:17 PM)toml_12953 Wrote:  I'm shooting for a program to automatically create a multi-dimensional list and am hoping to use a variable number of dimensions.

This will create recursively a multi-dimensional list whose dimensions are passed as a list and initialized with 0:
Code:
EXPORT dimension(mylist)
BEGIN
  LOCAL l:=tail(mylist),v:={};
  IFTE(SIZE(mylist)==1,MAKELIST(0,I,1,mylist(1)),MAKELIST(dimension(l),I,1,my​list(1)));
END;

dimension({3,2,2}) returns {{{0,0},{0,0}},{{0,0},{0,0}},{{0,0},{0,0}}}
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Size of a list passed to a function? - Didier Lachieze - 04-14-2017 02:58 PM



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