diff --git a/function.sld b/function.sld index aa64fa8..d7e5184 100644 --- a/function.sld +++ b/function.sld @@ -1,14 +1,4 @@ (define-library (schemepunk function) (export identity const flip compose bind complement) (import (scheme base)) - (begin - (define (identity x) x) - (define (const x) (lambda (y) x)) - (define (flip f) (lambda (x y) (f y x))) - (define (compose f . fs) - (if (null? fs) f (let ((g (apply compose fs))) (lambda (x) (f (g x)))))) - (define (bind f . fs) - (if (null? fs) f (let ((g (apply bind fs))) (lambda (x) (g (f x)))))) - (define (complement f) - (lambda xs (not (apply f xs)))))) - + (include "function/schemepunk.scm")) diff --git a/function/schemepunk.scm b/function/schemepunk.scm new file mode 100644 index 0000000..fef8a47 --- /dev/null +++ b/function/schemepunk.scm @@ -0,0 +1,14 @@ +(define (identity x) x) + +(define (const x) (lambda (y) x)) + +(define (flip f) (lambda (x y) (f y x))) + +(define (compose f . fs) + (if (null? fs) f (let ((g (apply compose fs))) (lambda (x) (f (g x)))))) + +(define (bind f . fs) + (if (null? fs) f (let ((g (apply bind fs))) (lambda (x) (g (f x)))))) + +(define (complement f) + (lambda xs (not (apply f xs))))