Skip to content

Instantly share code, notes, and snippets.

@duckyuck
Created November 16, 2012 11:38
Show Gist options
  • Save duckyuck/4086642 to your computer and use it in GitHub Desktop.
Save duckyuck/4086642 to your computer and use it in GitHub Desktop.
en veldig basal implementasjon av 'let' ved hjelp av identity monad. lett!
(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