Clojureの永続データ構造

irb(main):001:0> foo = [0, 1, 2, 3, 4, 5, 6, 7, 8]
=> [0, 1, 2, 3, 4, 5, 6, 7, 8]
irb(main):002:0> foo[6] = 9
=> 9
irb(main):003:0> foo
=> [0, 1, 2, 3, 4, 5, 9, 7, 8] # fooが変更されている
user=> (def foo [0 1 2 3 4 5 6 7 8])
#'user/foo
user=> (assoc foo 6 9)
[0 1 2 3 4 5 9 7 8]
user=> (println foo)
[0 1 2 3 4 5 6 7 8] ; fooは元のまま
nil
  • Leaf nodeのみにベクタの要素を持つ
  • 左から順に格納する
  • 深さが均一である
  • ベクタの長さを持つ

参考

--

--

Software engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store