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
| (defmonad | |
| :name :parser | |
| :do parsing | |
| :bind (fn [mv f] | |
| (fn [s] | |
| (when-let [[v s*] (mv s)] | |
| ((f v) s*)))) | |
| :return (fn [v] (fn [s] [v s])) | |
| :zero (fn [s] nil) | |
| :plus (fn [a b] (fn [s] (or (a s) (b s)))) |
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
| ;;;; this cps style code | |
| (anf-name x (fn [a] | |
| (anf y (fn [b] | |
| (anf z (fn [c] | |
| (k [:if a b c]))) | |
| ;;;; becomes | |
| (run-cps |
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 parenja.reader | |
| (:refer-clojure :rename {list clj-list | |
| symbol clj-symbol | |
| keyword clj-keyword | |
| vector clj-vector} | |
| :exclude [unquote unquote-splicing read]) | |
| (:use somnium.yap | |
| combinatrix.parser | |
| combinatrix.parser.text | |
| [combinatrix.util :only [definitions]])) |
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 poet.prelude) | |
| (def prelude | |
| '[(syntax-rule if () | |
| (_ X Y Z) (if* (op* === X true) Y | |
| (if* (op* === X false) Z | |
| (throw "if requires a boolean value")))) | |
| (syntax-rule if-not () | |
| (_ X Y Z) (if X Z Y)) |
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
| space_283 = (function (ST_729) { | |
| var rtn734_, v_440_; | |
| v_440_ = re_267("\\s"); | |
| rtn734_ = v_440_(ST_729); | |
| return rtn734_; | |
| }); | |
| spaces_284 = (function (ST_730) { | |
| var v_441_, rtn735_; | |
| v_441_ = many_261(space_283); | |
| rtn735_ = v_441_(ST_730); |
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
| ;;;; pairs | |
| (define-type Pair a b) | |
| (define-type Empty) | |
| (define Pair:foldl | |
| f x (Pair a b) -> (foldl f (f x a) b)) | |
| (define Pair:first | |
| (Pair a _) -> (Some a)) |
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
| ;;;; red-black-trees, based on the Functional Pearls article: | |
| ;;;; 'Red-Black Trees in a Functional Setting' by Chris Okasaki, 1993 | |
| (define-type R | B) ;; red black | |
| (define-type T color left elt right) ;; tree | |
| (define rbt:insert | |
| x t -> (match (rbt:insert* x t) | |
| (T _ a y b) -> (T B a y b))) |
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
| ;;;; structural types + pattern matching in Clojure | |
| ;;;; with the obligatory unbalanced binary tree example | |
| (define-struct leaf value) | |
| (define-struct node left elt right) | |
| (define insert | |
| nil x -> (leaf x) | |
| (leaf a) x -> (cond (or (nil? a) (= a x)) (leaf a) | |
| (< x a) (node (leaf x) a nil) |
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
| ;; SFML/System.h | |
| ;; //////////////////////////////////////////////////////////// | |
| ;; #ifndef SFML_SYSTEM_H | |
| ;; #define SFML_SYSTEM_H | |
| ;; //////////////////////////////////////////////////////////// | |
| ;; // Headers | |
| ;; //////////////////////////////////////////////////////////// |
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
| const h1 = { | |
| a: { | |
| b: { | |
| c: { | |
| foo: "bar" | |
| } | |
| } | |
| } | |
| } |