Below is the trace from class, walking through Clojure for the Brave and True chapter 3.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
Dr-Schlegels-MacBook-Pro-2:~ danielschlegel$ lein repl nREPL server started on port 60372 on host 127.0.0.1 - nrepl://127.0.0.1:60372 REPL-y 0.3.7, nREPL 0.2.12 Clojure 1.8.0 Java HotSpot(TM) 64-Bit Server VM 1.8.0_73-b02 Docs: (doc function-name-here) (find-doc "part-of-name-here") Source: (source function-name-here) Javadoc: (javadoc java-object-or-class-here) Exit: Control+D or (exit) or (quit) Results: Stored in vars *1, *2, *3, an exception in *e user=> (+ 1 2) 3 user=> "abc" "abc" user=> 12 12 user=> + #object[clojure.core$_PLUS_ 0x2a0d0041 "clojure.core$_PLUS_@2a0d0041"] user=> (doc +) ------------------------- clojure.core/+ ([] [x] [x y] [x y & more]) Returns the sum of nums. (+) returns 0. Does not auto-promote longs, will throw on overflow. See also: +' nil user=> (+) 0 user=> (+ 3) 3 user=> (+ 1 2 3 4 5) 15 user=> (if (> 5 3) "Yes" "No") "Yes" user=> (if (< 5 3) "Yes" "No") "No" user=> [] [] user=> [1 2 3 4 5] [1 2 3 4 5] user=> (do (println "Hi there") 5) Hi there 5 user=> (println "Hi there") Hi there nil user=> (if "abc" 3) 3 user=> (true? "abc") false user=> (if nil 3 5) 5 user=> (def failed-protagonist-names #_=> ["Larry Potter" "Doreen the Explorer" "The Incredible Bulk"]) #'user/failed-protagonist-names user=> failed-protagonist-names ["Larry Potter" "Doreen the Explorer" "The Incredible Bulk"] user=> 1/5 1/5 user=> (* 3 1/5) 3/5 user=> (= 1/5 0.2) false user=> (type 0.2) java.lang.Double user=> (type 1/5) clojure.lang.Ratio user=> (* 0.2 1/5) 0.04000000000000001 user=> (float 1/5) 0.2 user=> (* 2 (float 1/5)) 0.4000000059604645 user=> (float (* 2 1/5)) 0.4 user=> (* 2 (double 1/5)) 0.4 user=> (str "abc" "123" "def" "456") "abc123def456" user=> (type {}) clojure.lang.PersistentArrayMap user=> (get {:a 0 :b 1 :c 4} :c "unicorns?") 4 user=> (get {:a 0 :b 1 :c 4} :z "unicorns?") "unicorns?" user=> ({:a 0 :b 1 :c 4} :b) 1 user=> (:b {:a 0 :b 1 :c 4}) 1 user=> (nil :b) CompilerException java.lang.IllegalArgumentException: Can't call nil, form: (nil :b), compiling:(/private/var/folders/85/lz9shyg5205_jbcx7z3kvhsr0000gr/T/form-init1004257437900257562.clj:1:1) user=> (:b nil) nil user=> (.charAt "abc" 2) \c user=> (type (.charAt "abc" 2)) java.lang.Character user=> (def vec1 [1 2 3]) #'user/vec1 user=> vec1 [1 2 3] user=> (conj vec1 4) [1 2 3 4] user=> vec1 [1 2 3] user=> ("a" "b "c") #_=> user=> ("a" "b" "c") ClassCastException java.lang.String cannot be cast to clojure.lang.IFn user/eval1319 (form-init1004257437900257562.clj:1) user=> '("a" "b" "c") ("a" "b" "c") user=> (+ 1 2) 3 user=> '(+ 1 2) (+ 1 2) user=> (eval '(+ 1 2)) 3 user=> |