- 序文
- 1 手続きによる抽象の構築
- 1.1 プログラムの要素
- 1.1.1 式
- 1.1.2 名前と環境
- 1.1.3 組合せの評価
- 1.1.4 合成手続き
- 1.1.5 手続き作用の置換えモデル
- 1.1.6 条件式と述語
- 1.1 プログラムの要素
- 問題 1.1
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
dev> (defrecord Tree [left right]) | |
dev.Tree | |
dev> (defn ->list [tree] | |
(letfn [(rec [acc {:keys [left right] :as t}] | |
(if (instance? Tree t) | |
(if (instance? Tree left) | |
(recur acc (->Tree (:left left) (->Tree (:right left) right))) | |
(recur (cons left acc) right)) | |
(cons t acc)))] | |
(reverse (rec [] tree)))) |
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
{:deps | |
{io.forward/yaml {:mvn/version "1.0.9"}}} |
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
cljs.user=> (defn leibniz [n-terms] | |
#_=> (->> (iterate inc 1) | |
#_=> (filter odd?) | |
#_=> (map / (cycle [1 -1])) | |
#_=> (take n-terms) | |
#_=> (apply +) | |
#_=> (* 4.0))) | |
#'cljs.user/leibniz | |
cljs.user=> (time (leibniz 10000)) | |
"Elapsed time: 51.138105 msecs" |
(defprofile lagénorhynque
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
;;; unless | |
user> (defmacro unless [cond then] | |
`(if (not ~cond) | |
~then)) | |
#'user/unless | |
user> (macroexpand-1 '(unless foo? bar)) | |
(if (clojure.core/not foo?) bar) | |
;;; case | |
user> (defmacro case-table [k m] | |
`(case ~k |
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
(defn fib [n] | |
(case n | |
0 0 | |
1 1 | |
(+ (fib (- n 1)) | |
(fib (- n 2))))) | |
(let [x (-> *command-line-args* | |
first | |
js/parseInt)] |
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
(defn english->french [words] | |
(clojure.walk/postwalk-replace '{are vas | |
book livre | |
friend ami | |
hello bonjour | |
how comment | |
my mon | |
red rouge | |
you tu | |
today aujourd'hui} |
Clojurianのlagénorhynque (a.k.a. カマイルカ)です。
先日、Shibuya.lisp lispmeetup #62で「re-frame à la spec」と題してre-frameというClojureScriptフレームワークの概要とclojure.specとの統合方法の一例について発表しました。
本記事では、その発表内容に関連してClojureScriptとre-frameでのSPA開発の流れについてご紹介します。
@ababup1192 さんのElmについての素晴らしい記事 Elm開発における思考フロー からサンプルコードと本文の構成を参考にさせていただきました。
こちらの記事と比較してみると、両言語/アーキテクチャの共通点や差異が見られて面白いかもしれません。
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
{:paths ["."] | |
:deps {org.clojure/algo.generic {:mvn/version "0.1.2"}}} |