
Lisp implemented in under 1K of JavaScript - swannodette
https://github.com/kanaka/miniMAL
======
andrewchambers
This person wrote a lisp in 1K lines of C (not bytes :)), the cool thing is
that also includes a copying garbage collector.

[https://github.com/rui314/minilisp](https://github.com/rui314/minilisp)

~~~
mrottenkolber
I wrote a minimal Lisp compiler (targeting C) when I was a bit younger. :> My
GC was just a really bad reference counting implementation though. I dare you
to make fun of my "hash function". Hehe.

[https://github.com/eugeneia/microlisp](https://github.com/eugeneia/microlisp)

~~~
rrmm
Your hash function is fast! So it's got that going for it.

~~~
PhantomGremlin
I had to go look. Not hard to find.

I'll just say this, back in the prehistoric 1970s, a '%' operation was
eschewed, because it _wasn 't_ fast (relatively speaking)!!!

It often was used anyway, because it's very effective considering its
simplicity.

------
PinnBrain
So much effort to go under 1K (in the era of 128GiB fingernail chips), with
this .gitignore:

node_modules _-uglify_ _-crush_ _-regpack_

------
guard-of-terra
Thank you for at least not writing another Brainfuck clone.

------
mattdw
It's JSON lists as s-exps, which means (as I understand it) that the author
doesn't need to implement parsing, only traversal and evaluation. (Which can
essentially be a big-ass case statement.)

    
    
        ["def", "foo", 1]
        ["fn", "foo", ["a", "b"], […]]
    

It's not the most attractive Lisp I've seen…

~~~
infogulch
So write a lisp parser, then dump the result into this. I like that they
didn't include a parser in compacted code, such a parser wouldn't be very
interesting.

~~~
zardeh
So, uhmm,

    
    
        def parse(s): return json.loads('['+re.sub('([")])\s*(["(])','\g<1>,\g<2>',re.sub('[^()\s]+','"\g<0>"',s)).replace('(','[').replace(')',']')+']')
    

works for python, I'm assuming javascript has something equally small

~~~
infogulch
Yes, uninteresting, as I said. Lisp syntax is quite simple, so I would not
expect it to be very difficult to make a regex to parse it. Btw, does that
handle quoted strings, strings with syntax characters in them, and strings
with escapes?

~~~
agumonkey
And dotted pairs ? I had a super cute sexp parser in PHP, until I started
handling sexp fully.

~~~
gps408
Would dotted pair notation make sense for this lisp where lists are arrays,
not linked cons cells?

~~~
agumonkey
IMHO, yes, binary building blocks matter a lot in lisp philosophy, whether or
not they're built on javascript arrays.

~~~
gps408
Thanks for responding, man. That's my point though. There is no cons building
block in this lisp. I don't think (1 2 . 3) _can_ be represented in it so
having the notation for it makes no sense.

------
TazeTSchnitzel
I wrote a minimal Lisp for PHP in about an hour:
[https://gist.github.com/TazeTSchnitzel/44720ea3aec64a9e330a](https://gist.github.com/TazeTSchnitzel/44720ea3aec64a9e330a)

