Created
May 23, 2017 01:18
-
-
Save fbanados/d6e0134ff226abe71984a2221bbc7234 to your computer and use it in GitHub Desktop.
F#'s pipe operator for racket.
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
(define pipe | |
; Inspired on F#'s Forward pipe operator (|>) | |
(lambda args | |
(let ((v (car args)) | |
(functions (cdr args))) | |
(foldl (λ (f v) (f v)) v functions)))) | |
(test (pipe 1 | |
add1 | |
number->string | |
println) | |
(println | |
(number->string | |
(add1 1)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment