Created
November 16, 2012 11:38
-
-
Save duckyuck/4086642 to your computer and use it in GitHub Desktop.
en veldig basal implementasjon av 'let' ved hjelp av identity monad. lett!
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
(defn bind [v f] (f v)) | |
(defmacro lett [[sym expr & more] & body] | |
(if more | |
`(bind ~expr | |
(fn [~sym] (lett ~more ~@body))) | |
`(bind ~expr | |
(fn [~sym] ~@body)))) | |
; eksempel | |
(lett [a 1 | |
b (inc a) | |
c (+ a b)] | |
(* a b c)) | |
; => 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment