macro / function question 3 points by bOR_ 5977 days ago | 9 comments I wonder how I can write a macro or definition that understands that if I ask for`````` (twodimlist 0 3) `````` That i want`````` ((twodimlist 0) 3) `````` As there doesn't seem to be any syntax that I can alter to achieve this, the only option I see is to write a function like this:`````` (def ls (list x y) ((list x) y)) `````` but as my knowledge about macros is about 2 hours old, I might have missed a way to learn arc (listname 0 3).
 1 point by kennytilton 5976 days ago | link Sorry, my Arc is rusty, did you mean:`````` (def ls (x y) ((list x) y)) `````` My next question would be what that has to do with your original query, and my question there would be what does this do?:`` ((twodimlist 0) 3)``-----
 1 point by bOR_ 5976 days ago | link I've a function that binds a list of lists to to variable 'world', and a function that prints out this world.`````` (def makeworld (x) (let z nil (repeat x (= z (cons nil z))) (repeat x (= z (map [cons nil _] z))) (= world z))) (def show () (each x world (each y x (pr (if (is y nil) #\. y) #\space)) (pr #\linefeed))) `````` The world can then be seeded with trees, or shrubs or monsters or whatever. Anyway, as the world is a list of lists, it functions as a two-dimensional array.If in arc I want to access a point in this two-dimensional list / array, I need to enter ((world 0) 3), and the basic question was how to change arc (macrowise) to make (world 0 3) be equivalent to ((world 0) 3). I already worked around it by now.To answer your question: you're assuming that there is a list called 'list', and in my initial example I described a function that took the name of the list as first argument.-----
 2 points by pg 5976 days ago | link I don't understand exactly what this code is for, but I think you could write makeworld as`````` (def makeworld (x) (= world (n-of x (n-of x nil))))``````-----
 1 point by t1m 5977 days ago | link Does this work...`````` (mac twodimlist (x y) `((twodimlist ,x) ,y)) ?``````-----
 1 point by t1m 5977 days ago | link Oops, ignore the above. How about this...`````` arc> (mac blah (n x y) `((,n ,x) ,y)) #3(tagged mac #) arc> (macex1 '(blah twodimlist 0 3)) ((twodimlist 0) 3) ?``````-----
 2 points by sjs 5975 days ago | link Arbitrary number of arguments:`````` (mac drill (lst . xs) (if (no xs) `,lst (no (cdr xs)) `(,lst ,(car xs)) `((drill ,lst ,@(rev (cdr (rev xs)))) ,(last xs))))``````-----