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
user=> (ns there) | |
nil | |
there=> (defmulti ^:private doit identity) | |
#'there/doit | |
there=> (defmethod doit 1 [x] x) | |
#<MultiFn clojure.lang.MultiFn@d2de489> | |
there=> (doit 1) | |
1 | |
there=> (in-ns 'user) | |
#<Namespace user> |
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
(page "index.html" | |
(:require [clojure.string :as string])) | |
(def my-contacts | |
(cell #{{:first "Ben" :last "Bitdiddle" :email "benb@mit.edu"} | |
{:first "Alyssa" :middle-initial "P" :last "Hacker" :email "aphacker@mit.edu"} | |
{:first "Eva" :middle "Lu" :last "Ator" :email "eval@mit.edu"} | |
{:first "Louis" :last "Reasoner" :email "prolog@mit.edu"} | |
{:first "Cy" :middle-initial "D" :last "Effect" :email "bugs@mit.edu"} | |
{:first "Lem" :middle-initial "E" :last "Tweakit" :email "morebugs@mit.edu"}})) |
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
(page "rot13.html") | |
(defn make-rot13 [start] | |
(->> (for [from (range 27), | |
:let [to (mod (+ 13 from) 26)]] | |
[(char (+ start from)) (char (+ start to))]) | |
(into {}))) | |
(let [table (merge (make-rot13 97) (make-rot13 65))] | |
(defn rot13 [s] |
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
(page "index.html") | |
(defn class! [elem c] | |
(let [asetc (cell= (aset elem "className" c))] | |
(specify! elem cljs.core/IMeta (-meta [_] asetc)))) | |
(defn declass! [elem] | |
(destroy-cell! (meta elem))) | |
(defc the-class "foo") |
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
(page "index.html") | |
(def people (cell {"Hatfield" | |
#{{:first "William" :gender :male} | |
{:first "Victoria" :gender :female} | |
{:first "Henry" :gender :male} | |
{:first "Elliott" :gender :male} | |
{:first "Elizabeth" :gender :female}} | |
"McCoy" | |
#{{:first "Randolph" :gender :male} |
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
(defc c1 1) | |
(defc c2 2) | |
(defc c3 3) | |
(defc= show (print c1 c2 c3)) | |
;;; show happens once with initial values 1 2 3 | |
(doseq [c [c1 c2 c3]] | |
(set! (.-state c) (inc (.-state c)))) |
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
(page "index.html") | |
(defc c1 10) | |
(defc c2 20) | |
(defc c3 30) | |
(defn inc-c1c2! [also] | |
(dosync | |
(also) | |
(swap! c1 inc) |
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
/* %% ['/home/alan/projects/snippets/lispfl.pl']. */ | |
:- use_module(library(clpfd)). | |
%% functional forms | |
ff(def). | |
ff(const). | |
ff(comp). | |
ff(juxt). |
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
(page "index.html" | |
(:require | |
[tailrecursion.hoplon.reload :refer [reload-all]])) | |
(reload-all 1000) | |
(defn register! [fname lname email pass pass2] | |
(println "register! called with:" fname lname email "***" "***")) | |
(with-init! |
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
;;; list todos | |
(fn get-todos (shortcode) | |
(let [list-id (code2id shortcode) | |
s "SELECT todo, state FROM todos t INNER JOIN lists l ON t.list_id = l.id WHERE l.id=? ORDER BY t.id" | |
stmt (-> *conn* (prepare s))] | |
(-> stmt (bind_param "i" list-id)) | |
(-> stmt (execute)) | |
(fn fetch (arr) | |
(-> stmt (bind_result todo state)) |