Skip to content

Instantly share code, notes, and snippets.

@kurogelee
Created January 5, 2015 13:05
Show Gist options
  • Save kurogelee/f0992d2ead1fc447ac52 to your computer and use it in GitHub Desktop.
Save kurogelee/f0992d2ead1fc447ac52 to your computer and use it in GitHub Desktop.
挿入した順序を保証するMap, Set ref: http://qiita.com/kurogelee/items/02fdd51c88dc8f2d2be0
[org.flatland/ordered "1.5.2"]
(ns sample-ordered
(:use [flatland.ordered.set :only [ordered-set]]
[flatland.ordered.map :only [ordered-map]]))
(-> (assoc (ordered-map :a 1 :b 2) :c 3 :d 4)
(assoc :e 5)
(#(apply assoc % (range 20)))
keys)
(-> (ordered-set :a :b :c 1 2)
(conj :d :e)
(#(apply conj % (range 20)))
seq)
(:a :b :c :d :e 0 2 4 6 8 10 12 14 16 18)
(:a :b :c 1 2 :d :e 0 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment