阿小信大人的头像
Life is short (You need Python) Bruce Eckel

clojure-koans练习笔记2016-05-19 12:09

#### strings笔记

**get**使用姿势

get returns a value mapped to key, not-found or nil if not present. So to get \C we have to pass in the index 0.

:::clojure
koan-engine.runner=> (get "asd" 0)
\a
koan-engine.runner=> (get "asd" 1)
\s
koan-engine.runner=> (get "asd" -1)

......
#Clojure#   评论[0]阅读全文[1018]

Clojure中defstruct、deftype和defrecord使用区别2016-05-17 16:43

#### defstruct

:::clojure
user=> (defstruct Point1 :x :y)
#'user/Point1
user=> (def p1 (struct-map Point1 :x 3 :y 4))
#'user/p1
user=> (prn p1)
{:x 3, :y 4}
nil
user=> (prn (:x p1))
3
nil
user=> (prn (struct-map Point1 3 5))
{:x nil,

......
#Clojure#   评论[0]阅读全文[1104]