add a macroish example
that currently doesn't work. outputs this (wrong): (unquote (foldr (lambda acc (lambda binding (cons -> (cons binding (cons acc ()))))) d (cons a (cons b (cons c ())))))
This commit is contained in:
parent
b10b94865f
commit
1cc38adba9
1 changed files with 27 additions and 0 deletions
27
lambda-like-macroish.slimp
Normal file
27
lambda-like-macroish.slimp
Normal file
|
@ -0,0 +1,27 @@
|
|||
(forall (car' cdr) (car (cons car' cdr)) car')
|
||||
(forall (car cdr') (cdr (cons car cdr')) cdr')
|
||||
|
||||
(forall (a as bs) (++ (cons a as) bs) (cons a (++ as bs)))
|
||||
(forall (bs) (++ () bs) bs)
|
||||
|
||||
(forall (f acc) (foldr f acc ()) acc)
|
||||
(forall (f acc x xs) (foldr f acc (cons x xs)) (foldr f (app f acc x) xs))
|
||||
|
||||
; could be sugared much better
|
||||
; also this is just map? ugh this is just map
|
||||
; defeats the whoel point KLFJkljfksdljf 1:24 brain
|
||||
(forall (var body) (for var () body) ())
|
||||
(forall (var x xs body) (for var (cons x xs) body) (cons (let var x body) (for var xs body)))
|
||||
(forall (bindings body) (@ bindings body) (lambda-like lambda bindings body))
|
||||
(forall (var body arg) ((lambda var body) arg) (let var arg body))
|
||||
|
||||
(forall (lam bindings body)
|
||||
(lambda-like' lam bindings body)
|
||||
(unquote
|
||||
(foldr
|
||||
(@ (acc binding)
|
||||
(quote (lam binding acc)))
|
||||
body
|
||||
(quote bindings))))
|
||||
|
||||
(lambda-like' -> (a b c) d)
|
Loading…
Reference in a new issue