in reply to Lisp-In-Perl
So yours wins here. I think this is because perl-lisp implements lists (1 2 3) as an array instead of an actual linked list (even though when you use 'cons' it seems to construct a proper list), so there is no real way for it to return what its supposed to. Sure, it (perl-lisp) could either shift the array, or take a list slice (which copies the array), but neither is a correct implementation of a list.>(set 'a (list 1 2 3)) Both return: (1 2 3) #Right! >(cdr a) perl-lisp returns: 3 #Wrong! Lisp returns: (2 3) #Right!
This is because neither lisp's implement the apply function, perl-lisp doesn't implement the mapcar function, and I don't think your Lisp correctly implements mapcar, because mapcar should accept any number of lists following the function, but yours only accepts one, and I think (not sure here, its been awhile since I've really done lisp) that you should have to quote the function passed in. (Every once in a while, I've thought that perl should have a mapcar function also :)(defun transpose (x) (apply 'mapcar (cons 'list x)) Which on this input: (transpose '((1 2 3) (4 5 6) (7 8 9) (10 11 12))) Should product this output: ((1 4 7 10) (2 5 8 11) (3 6 9 12))
|
|---|