(def s "(- a b)"))のような文字列があるとき, 実行時に決まる値で a や b を束縛して, この式を評価したいとする.
(let [a 4 b 3] (eval (read-string s)))| (require '[clojure.test :refer (with-test are run-tests)]) | |
| (with-test | |
| (defn awtp [cs a] | |
| ((fn f [[h & r] a] | |
| (cond | |
| (zero? a) #{{}} | |
| (nil? h) #{} | |
| :else (set | |
| (mapcat (fn [c] |
(def s "(- a b)"))のような文字列があるとき, 実行時に決まる値で a や b を束縛して, この式を評価したいとする.
(let [a 4 b 3] (eval (read-string s)))| (require '[clojure.test :refer (with-test is run-tests)]) | |
| (with-test | |
| (defn- trns "盤を転置します" | |
| [b] (vec (apply (partial map vector) b))) | |
| ; テスト | |
| (is (= (trns [[:a :b] | |
| [:c :d]]) | |
| [[:a :c] |
記述能力の高い Clojure.
よくあるプログラミングの演習問題を Clojure で解いてみます.
| (require '[clojure.test :refer (with-test is run-tests)]) | |
| (with-test | |
| (defn mapf [f m & args] | |
| ((fn g [n] | |
| (if (map? n) | |
| (into {} (map (fn [[k v]] [k (g v)]) n)) | |
| (apply f n args))) | |
| m)) |
Assumed that you have set leiningen up and can use it.
Copy project.clj, repl-test.cljs and brepl-test.html from this gist
or git clone this gist and move or copy repl-test.cljs under src directory.
$ git clone https://gist.github.com/6183122.git
$ cd 6183122/
You can do this without compojure. Refer [A minimum setting to use browser REPL of ClojureScript] (https://gist.github.com/kohyama/6183122).
Assumed that you have set leiningen up and can use it.
Copy project.clj, repl-test.cljs, minimum_httpd.clj
Prepare an environment according to A minimum setting to use browser REPL of ClojureScript.
Input lines of dom-example.cljs to the REPL.
Here's a SCREEN CAST.
Enjoy!
| " part of my .vimrc | |
| " -- neobundle | |
| set nocompatible | |
| filetype off | |
| if has('vim_starting') | |
| set runtimepath+=~/.vim/bundle/neobundle.vim | |
| call neobundle#rc(expand('~/.vim/bundle')) | |
| endif | |
| set shell=/bin/sh |