Clojure
http://www.slideshare.net/takkanm/carconsこういう配色とか私は好きです。 内容もさることながら、見せ方という意味でも勉強のためにリンクしておく。
http://github.com/jonromero/music-as-dataどうやらClojureで音楽できるらしい。
どう書く?org(http://ja.doukaku.org/)の課題から、回文日付を表示するプログラム。http://gist.github.com/863639clojarsのclj-timeを使用。("01011010" "01100110" ... "92800829" "92900929")という結果が出る。
http://github.com/functional-koans/clojure-koansClojure exercise. あとでやってみよう。
http://gist.github.com/8619343*3魔方陣。このくらいなら新人研修で使えるかな。
http://gist.github.com/861902新人研修のアルゴリズム教材用に演習問題を作ろう! ということで、小町算の総当たりプログラム。Clojureではできたけど、Javaに直すのが面倒であきらめた・・・。
http://gist.github.com/861720こちらを参考に。 http://www.arcfn.com/2009/03/y-combinator-in-arc-and-java.html呼び出しの様子を展開して表示させたいんだが。
最近ACMをうろちょろして見つけたものなど。 「Modeling Ontologies as Executable Domain Specific Languages」Dragan Djuric他,ISEC '10 オントロジー記述にDSL(MagicPotion http://code.google.com/p/magicpotion/wiki/BasicTutorial) を適用した研究です…
第14回Formal Methods 勉強会で、 clojure.contrib.seq-utils.indexedのn次元版が欲しい、 とのことだったので試験実装。http://gist.github.com/856980ツリー構造を考えるときは、やたら再帰するんじゃなくて、 (map func list) を使って下位のリストに関数…
"Modeling Ontologies as Executable Domain Specific Languages" Dragan Djuric,Jelena Jovanovic,Vladan Devedzic,Ramo SendeljACM Digital Libraryでオントロジーの検索をしていたら Clojureでのオントロジー言語の論文が出ていた。使っているのはMagicPot…
http://groups.google.com/group/clojure/browse_thread/thread/d79392e4c79f8cde の記事より。Stuart Sierraのコードでdoseqの後ろに[]が無かったので追加しただけ。 http://gist.github.com/836798
((fn [x] (list x (list (quote quote) x))) (quote (fn [x] (list x (list (quote quote) x))))) 参考資料から、なんのひねりもない。 http://www.ipsj.or.jp/07editj/promenade/4703.pdf
やっとまともに動いた。http://gist.github.com/834831factsで使用した変数記号と同じものを前提で使用したのが失敗の原因。 置換が終わらないのは当然だった。次はVerifierいってみよう!
なんにせよ、プログラミングにデバッグはつきもの。 先人の知恵をリンク。 Debugging in Clojure http://stackoverflow.com/questions/2352020/debugging-in-clojure トレースの使い方 (use 'clojure.contrib.trace) (defn fib[n] (if (< n 2) n (+ (fib (- …
"Programming Language Theory and its Implementation" を流し読みして、Common Lispで書かれたThorem Proverを Clojureで書き直し。http://gist.github.com/823632・・・なんですが、イマイチ動きません。 以下の例は動いているけど。 (rewrite '(((not (x…
F#の単位の扱いはある意味面白いなー、 と思ってたらClojureにもあった。http://code.google.com/p/clj-units/source/browse/test/si-tests.clj試してるんだが、なぜか動かない。 時間が出来たら調査しよう。
自作。 (defn foldr [f init lst] (if (empty? lst) init (f (first lst) (foldr f init (rest lst))))) うーむ、しかし再帰を外すことはできるのか?http://lispuser.net/memo/lisp/2007-05-29-23-08.html に習ってfoldの実験。 user=> (reduce #(cons %2 %…
第13回Formal Methods勉強会にて、 「再帰を使わずにfoldrで書く」という話があったので、 Clojureの場合reduceでやってみる。 (defn factorial [n] (reduce * 1 (take n (iterate inc 1)))) (defn fib [n] ((reduce (fn [[a b] _] [b (+ a b)]) [0 1] (rang…
Clojureにはpowerset関数がないのかな。 ということでベタで作ってみた。https://gist.github.com/796299Clojureらしいコンパクトなコードにならないものか・・・。と思ったら、Clojure-jaにて紹介してもらった。 clojure.contrib.combinatorics/subsets が…
MATLABよりも簡単にできるんじゃないか、と思って、 Interface Oct,2007 の記事のコードを変換。 (use '(incanter core stats charts)) ; 平均μと分散σ^2を指定して、正規分布から標本を抽出する。 (defn randncq [mu variance n-samples] (let [sigma (sqrt…
Clojureでawkのようなフィルタ処理をやろう・・・ といろいろ考えていたが、楽にできることがわかった。 準備 この辺りを使えば簡単。 (use '[clojure.contrib.duck-streams :only (reader read-lines)] '[clojure.contrib.str-utils :only (re-split)]) 先…
OAuthは一度やってしまえば何度も認証はいらないらしいので、手順だけまとめてみる。 1 consumer-keyとconsumer-secretの取得 twitter.comで先に自分のアプリケーションを登録し、consumer-keyとconsumer-secretをしておく。 2 必要なライブラリのインポート…
TwitterのUIとしてのClojureを模索してみる。https://gist.github.com/775816 (import '(twitter4j Query QueryResult Tweet Twitter TwitterException TwitterFactory) '(twitter4j.http AccessToken RequestToken) '(java.util List Properties)) (defn se…
学生のころはawkで書いてたなぁ。https://gist.github.com/775780 ; touch typing program (def random (java.util.Random.)) (def keychars "fjdkslaghvmcxzbnrueiwoqpty;,./") (def *initial-level* 2) (defn make-problem-word [level] (apply str (for […
https://gist.github.com/774229 (def digit {\0 "" \1 "一" \2 "二" \3 "三" \4 "四" \5 "五" \6 "六" \7 "七" \8 "八" \9 "九"}) (defn digit-keta [d m] (if (= (digit d) "") "" (if (and (not= m "") (= (digit d) "一")) m (str (digit d) m)))) (defn…
TAPL読書会(2011/1/9)で第6章にて出てきた、s式の変数名に一意な数値を割り当てるアルゴリズム。https://gist.github.com/774055 (use '[clojure.contrib.seq-utils]) (defn position [f coll] (first (positions f coll))) (defn de-brujin-index [x coll] …
Clojureで引っかかった論文 "Multi-core Parallelization in Clojure – a Case Study.",Johann M. Kraus "Modeling Ontologies as Executable Domain Specific Languages",Dragan Djuric
(defmacro もし [test then t-exp else f-exp] `(if ~test (do ~@t-exp) (do ~@f-exp))) こうすれば、 echoserver=> (もし true ならば (println "a") でなければ (println "b")) "a" と出来るわけだ。
TAPLのラムダ計算の箇所をちょっとメモ書き。 (def tru (fn [t f] t)) (def fls (fn [t f] f)) (def iff (fn [c t f] (c t f)))
https://gist.github.com/736375 とりあえず動く状態。