Skip to content

Commit a982151

Browse files
committed
Add higher-order functions in prelude, Y combinator
1 parent 3f0b853 commit a982151

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

prelude.lisp

+8
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,12 @@
222222

223223
(define odd? (lambda (n) (eq? (mod n 2) 1)))
224224

225+
(define curry (lambda (f x) (lambda args (f x . args))))
226+
227+
(define compose (lambda (f g) (lambda args (f (g . args)))))
228+
229+
(define Y (lambda (f) (lambda args ((f (Y f)) . args))))
230+
231+
(define reveal (lambda (f) (cons 'lambda (cons (car (car f)) (cons (cdr (car f)) ())))))
232+
225233
(define defun (macro (f v x) (list 'define f (list 'lambda v x))))

0 commit comments

Comments
 (0)