elnygren / ellisp

ellisp is a lisp parser & interpreter made with Rust for fun.
4 stars 1 forks source link

standard library #1

Open elnygren opened 5 years ago

elnygren commented 5 years ago

Reference implementation (right hand side is python from norvig.com/lispy2.html)

'+':            op.add,
'-':            op.sub,
'*':            op.mul,
'/':            op.truediv, 
'>':            op.gt,
'<':            op.lt,
'>=':           op.ge,
'<=':           op.le,
'=':            op.eq, 
'abs':          abs,
'append':       op.add,  
'apply':        lambda proc, args: proc(*args),
'begin':        lambda *x: x[-1],
'car':          lambda x: x[0],
'cdr':          lambda x: x[1:], 
'cons':         lambda x,y: [x] + y,
'eq?':          op.is_, 
'expt':         pow,
'equal?':       op.eq, 
'length':       len, 
'list':         lambda *x: List(x), 
'list?':        lambda x: isinstance(x, List), 
'map':          map,
'max':          max,
'min':          min,
'not':          op.not_,
'null?':        lambda x: x == [], 
'number?':      lambda x: isinstance(x, Number),  
'print':        print,
'procedure?':   callable,
'round':        round,
'symbol?':      lambda x: isinstance(x, Symbol),
elnygren commented 5 years ago

Most of these are now implemented.