curry checks that a single argument is a procedure (notified by #1839)

This commit is contained in:
Milo Turner 2017-10-08 18:40:42 -04:00 committed by Ben Greenman
parent 48092bdc0c
commit 27ec348a62
2 changed files with 10 additions and 4 deletions

View File

@ -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)))

View File

@ -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))