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
sealed trait EdnExpr { | |
def value : Expr | |
def mdata : Map[Expr,Expr] | |
override def equals(other : Any) = other match { | |
case that : EdnExpr => this.value == that.value | |
case _ => false | |
} | |
} | |
type Expr = Any | |
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
(ns ^{:doc "Playing with Church Boolean Logic." | |
:author "Mathieu Gauthron"} | |
net.matlux.church-boolean) | |
(def ZERO (fn [f] (fn [x] x))) | |
(def ONE (fn [f] (fn [x] (f x)))) | |
(def TWO (fn [f] (fn [x] (f (f x))))) | |
(def AND (fn [p] (fn [q] ((p q) p) ))) | |
(def pred (fn [n] (fn [f] (fn [x] (((n (fn [g] (fn [h] (h (g f))))) (fn [u] x) ) (fn [u] u) ) )))) |
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
(ns transducers.core) | |
(defn my-filter [pred coll] | |
(reduce #(if (pred %2) (conj %1 %2) %1) [] coll)) | |
(defn my-map [f coll] | |
(reduce (fn [r x] | |
(conj r (f x))) [] coll)) | |
(comment |
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
package langtonsant | |
import scala.annotation.tailrec | |
import scala.collection.immutable.Map | |
object Ants extends App { | |
val columnNb = 50 | |
val rowNb = 50 |
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
(ns chain-map-keys.core) | |
(def mymap {"key1" {"key2" {"key3" "value3"}}}) | |
;(--> mymap "key1" "key2" "key3") | |
;; => | |
;(-> (mymap "javahome") (get "key2") (get "key3")) | |
(defmacro --> [m firstkey & keys] | |
(let [a (map #(list 'get %) keys)] | |
`(-> (~m ~firstkey) ~@a))) |