factorial: 階乗 (引数は非負整数)
gamma: ガンマ関数 (階乗の拡張. 引数 n が 1以上の整数ならば, n - 1 の階乗に等しい)
sum: 総和
sum-of-squares: 平方の総和
prod: 総積
" 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 |
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!
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
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/
(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)) |
記述能力の高い Clojure.
よくあるプログラミングの演習問題を Clojure で解いてみます.
(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] |
(def s "(- a b)"))
のような文字列があるとき, 実行時に決まる値で a や b を束縛して, この式を評価したいとする.
(let [a 4 b 3] (eval (read-string s)))