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
Takanori Ishibashi

Takanori Ishibashi

Software engineer

More from Medium

The Visitor Pattern — Design Pattern Experiments with C++ 20

LC 706 Design HashMap

Need of different Sorting Technique

C++ Arrays Study Guide and Practice Questions