Created
May 6, 2019 08:02
-
-
Save blippy/da87666a996c161966c13dcaaef33458 to your computer and use it in GitHub Desktop.
Chain procures together
This file contains 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 (chain arg0 . lambdas) | |
(let loop ((arg arg0) (lambdas lambdas)) | |
(if (empty? lambdas) | |
arg | |
(loop ((car lambdas) arg) (cdr lambdas))))) | |
; example usage | |
(define (add1 n) (+ 1 n)) | |
(define (adder by) (lambda (n) (+ by n))) | |
(chain 10 add1 add1 add1 (adder 2)) ; 15 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment