curry checks that a single argument is a procedure (notified by #1839)
This commit is contained in:
parent
48092bdc0c
commit
27ec348a62
|
@ -29,4 +29,4 @@
|
||||||
(check-equal? ((((curry foldl) +) 0) '(1 2 3)) 6)
|
(check-equal? ((((curry foldl) +) 0) '(1 2 3)) 6)
|
||||||
|
|
||||||
(check-exn exn:fail:contract? (λ () (curry 1 2)))
|
(check-exn exn:fail:contract? (λ () (curry 1 2)))
|
||||||
; (check-exn exn:fail:contract? (λ () (curry 1)))
|
(check-exn exn:fail:contract? (λ () (curry 1)))
|
||||||
|
|
|
@ -75,9 +75,15 @@
|
||||||
curried))))
|
curried))))
|
||||||
;; curry is itself curried -- if we get args then they're the first step
|
;; curry is itself curried -- if we get args then they're the first step
|
||||||
(define curry
|
(define curry
|
||||||
(case-lambda [(f) (define (curried . args) (curry* f args '() '()))
|
(case-lambda
|
||||||
|
[(f)
|
||||||
|
(unless (procedure? f)
|
||||||
|
(raise-argument-error (if right? 'curryr 'curry) "procedure?" f))
|
||||||
|
(define (curried . args) (curry* f args '() '()))
|
||||||
curried]
|
curried]
|
||||||
[(f . args) (curry* f args '() '())]))
|
[(f . args)
|
||||||
|
(curry* f args '() '())]))
|
||||||
|
|
||||||
(make-keyword-procedure (lambda (kws kvs f . args) (curry* f args kws kvs))
|
(make-keyword-procedure (lambda (kws kvs f . args) (curry* f args kws kvs))
|
||||||
curry))
|
curry))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user