add (picrin procedure)

This commit is contained in:
Yuichi Nishiwaki 2015-07-18 18:04:33 +09:00
parent 3d170afac8
commit 34028172f2
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1 @@
CONTRIB_LIBS += $(wildcard contrib/50.procedure/*.scm)

View File

@ -0,0 +1,25 @@
(define-library (picrin procedure)
(import (scheme base))
(export >>
<<
constant
identity)
(define identity values)
(define (constant . args)
(lambda _
(apply values args)))
(define (>> . fs)
(if (null? fs)
identity
(let ((f (car fs))
(g (apply >> (cdr fs))))
(lambda args
(call-with-values (lambda () (apply f args))
(lambda args
(apply g args)))))))
(define (<< . fs)
(apply >> (reverse fs))))