dagda1
dagda1

Reputation: 28930

clojure - add item to nested set

Say I have a set like this:

#{#{"a"} #{"b"} #{"c"}}

Say I wanted to updated the middle set to make s become:

#{#{"a"} #{"be"} #{"c"}}

How would I achieve this?

Upvotes: 0

Views: 278

Answers (1)

Diego Basch
Diego Basch

Reputation: 13079

(-> #{#{"a"} #{"b"} #{"c"}} (disj #{"b"}) (conj #{"be"}))

=> #{#{"a"} #{"be"} #{"c"}}

(of course there's no ordering in sets, it could well be shown in any order).

Upvotes: 4

Related Questions