プログラミングClojure第1章
- 作者: Stuart Halloway,川合史朗
- 出版社/メーカー: オーム社
- 発売日: 2010/01/26
- メディア: 単行本(ソフトカバー)
- 購入: 10人 クリック: 338回
- この商品を含むブログ (72件) を見る
ログをメモっとく。
$ wget http://media.pragprog.com/titles/shcloj/code/shcloj-code.tgz $ tar xzf shcloj-code.tgz $ ls code shcloj-code.tgz $ cd code $ ls LICENSE bin classes examples lib public snippets user.clj Rakefile book com lancet output reader test $ bin/repl.sh Clojure 1.1.0-alpha-SNAPSHOT user=> (println "hello world") hello world nil user=> (defn hello [name] (str "Hello, " name)) #'user/hello user=> (hello "Stu") "Hello, Stu" user=> #{} #{} user=> (conj #{} "Stu") #{"Stu"} user=> (def visitors (ref #{})) #'user/visitors user=> (alter visitors conj "Str") java.lang.IllegalStateException: No transaction running (NO_SOURCE_FILE:0) user=> ( dosync (alter visitors conj "Str")) #{"Str"} user=> @visitors #{"Str"} user=> (defn hello "Writes hello message to *out*. Calls you by username. Knows if you hava been here before." [username] (dosync (let [past-visitor (@visitors username)] (if past-visitor (str "Welcome back, " username) (do (alter visitors conj username) (str "Hello, " username)))))) #'user/hello user=> (hello "Rich") "Hello, Rich" user=> *1 "Hello, Rich" user=> (hello "Rich") "Welcome back, Rich" user=> (require 'clojure.contrib.str-utils) nil user=> (require 'examples.introduction) nil user=> (take 10 examples.introduction/fibs) (0 1 1 2 3 5 8 13 21 34) user=> (doc hello) ------------------------- user/hello ([username]) Writes hello message to *out*. Calls you by username. Knows if you hava been here before. nil user=> (use 'clojure.contrib.repl-utils) nil user=> (source identity) (defn identity "Returns its argument." [x] x) nil user=> (show java.util.HashMap) === public java.util.HashMap === [ 0] <init> () [ 1] <init> (Map) [ 2] <init> (int) [ 3] <init> (int,float) [ 4] clear : void () [ 5] clone : Object () [ 6] containsKey : boolean (Object) [ 7] containsValue : boolean (Object) [ 8] entrySet : Set () [ 9] equals : boolean (Object) [10] get : Object (Object) [11] getClass : Class () [12] hashCode : int () [13] isEmpty : boolean () [14] keySet : Set () [15] notify : void () [16] notifyAll : void () [17] put : Object (Object,Object) [18] putAll : void (Map) [19] remove : Object (Object) [20] size : int () [21] toString : String () [22] values : Collection () [23] wait : void () [24] wait : void (long) [25] wait : void (long,int) nil