Well, comparing your 'Lisp' interpreter against 'perl-lisp' in CPAN (lisp), I have to say that your's is a more complete implementation, and I think the more correct one. On this simple script: >(set 'a (list 1 2 3))
Both return:
(1 2 3) #Right!
>(cdr a)
perl-lisp returns:
3 #Wrong!
Lisp returns:
(2 3) #Right!
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.
Sorry to say, though, that neither lisp's will execute my favorite Lisp function:(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))
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 :)
Neither have an append function, either. I would think that appending lists is something a list processing language ought to be able to do :-)
One thing in perl-lisp's favor, it does have a setq function, which your's lacks, but of course is a trivial thing and should be easy to implement if you wanted to :)
One more thing you might want to consider is using h2xs to create a normal installable perl module (where you can make/make test/make install), with some tests, like the CPAN modules, and then consider putting this on CPAN.
I've been looking at the syntax for Common Lisp and it seems I was wrong about mapcar. In Common Lisp it does only take one list argument, so this implementation of mapcar is not an incorrect one, just not a very good one (as is Common Lisp's). | [reply] [d/l] [select] |
This is just wrong :-)
LISP=Lisp InSide Perl
LISP=Lisp Isn't Supposed to be in Perl
PERL=Perl Even Runs Lisp | [reply] |
| [reply] |