-
-
Save tioover/8142955 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(define (curry f) | |
(define (min-arity arity) | |
(if (number? arity) arity (arity-at-least-value arity))) | |
(define (curry-aux f args arity) | |
(lambda (a) | |
(let ((new-args (cons a args))) | |
(cond ((= arity 1) | |
(apply f (reverse new-args))) | |
((> arity 1) | |
(curry-aux f new-args (- arity 1))) | |
; fail otherwise | |
)))) | |
(curry-aux f '() (min-arity (procedure-arity f)))) | |
(define (appc . l) | |
(if (eq? (cdr l) '()) | |
(car l) | |
(apply appc | |
(cons ((car l) (cadr l)) (cdr (cdr l)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example