Go to file
NunoSempere 1cf5599acc clean function definitions a bit
And in particular, move some common function definitions to
the top
2023-05-07 18:57:22 -04:00
notes more scaffolding for defining functions 2023-05-07 12:24:04 -04:00
src clean function definitions a bit 2023-05-07 18:57:22 -04:00
.gitignore add README. 2023-05-02 22:08:21 -04:00
LICENSE.txt tweak: add license. 2023-05-02 22:09:19 -04:00
makefile feat: remove all compiler warnings 2023-05-02 21:33:42 -04:00
mumble feat: get user function application working better! 2023-05-07 17:46:17 -04:00
README.md add example function definition 2023-05-07 18:43:09 -04:00

Mumble: A lisp in C

About

This is a Lisp written in C. It follows the outline in this Build Your Own Lisp book, though it then adds some small tweaks and improvements and quality of life improvements:

  • A makefile
  • Configurable verbosity levels
  • Different and perhaps slightly more elegant printing functions
  • A slightly different approach to evaluating functions
  • Capturing Ctrl+D
  • Float instead of ints

Conversely, it doesn't have:

  • Function currying
  • strings
  • Variable arguments
  • ...

Overall this might be mostly of interest as a pointer to the book that this is originally based on. And to readers of that same book, I'd be curious to see what you ended up with.

Installation and usage

Dependencies

This depends on editline, which can be installed on Debian/Ubuntu with:

git clone https://github.com/troglobit/editline
./autogen.sh
./configure
make all
sudo make install
ldconfig

Readers might also find it interesting to compile it with tiny c compiler rather than gcc, as it is significantly faster.

Compilation

git clone https://github.com/NunoSempere/mumble
make
# sudo make install # 

Usage

Simply call the ./mumble binary:

./mumble

Example usage

mumble> (1 2 3)
mumble> { 1 2 3 }
mumble> head (1 2 3)
mumble> { head (1 2 3) }
mumble> tail { 1 2 3 }
mumble> list ( 1 2 3 )
mumble> eval { head {1 2 3} } 
mumble> (eval { head {+ tail head } } ) 1 2 3 
mumble> len {1 2 3}
mumble> join { {1 2} {3 4} }
mumble> def { {x} { 100 } }
mumble> x
mumble> def { { a b c } { 1 2 3} }
mumble> * a b c
mumble> - a b c
mumble> / a b c
mumble> VERBOSITY=0
mumble> VERBOSITY=1
mumble> VERBOSITY=2
mumble> def {sq} (@ {x} {* x x})
mumble> sq 44
1936.000000
mumble> def {sqsum} (@ {x y} {(+ (sq x) (sq y))})
( )
mumble> sqsum 2 3
( 13.000000 )

Gotchas

This doesn't currently run on Windows. But it easily could, with [preprocessor statements from the book].

Usage and licensing

I don't expect this project to be such that people might want to use it. If you want a

But for the eventuality, this code is licensed under the MIT license; see the license.txt file.