Fork me on GitHub
#specter
<
2017-01-07
>
wei01:01:19

I’m confused with the result of (sp/walker sequential?)

(sm/select (sp/walker sequential?) {:b [1 2 nil 3]}) => [[:b [1 2 nil 3]]]
I would have expected [1 2 nil 3]

wei01:01:24

as a followup question, what would be the specter-y way to remove nils from sequences?

nathanmarz01:01:11

@wei looks like clojure.walk navigates to the key/value pairs of maps, which it considers sequences

nathanmarz01:01:28

for removing nils, use com.rpl.specter.zipper

nathanmarz01:01:48

or navigate to the sequence and use filter

nathanmarz01:01:31

if https://github.com/nathanmarz/specter/issues/117 is implemented will be able to do (setval [ALL nil?] NONE data)

wei21:01:02

@nathanmarz thanks for the tips. can zipper remove all nils an a nested structure? having some trouble putting it together

nathanmarz21:01:35

@wei like this: (setval [z/VECTOR-ZIP z/DOWN z/RIGHT z/NODE-SEQ] [] [1 2 3 4])

nathanmarz21:01:04

@wei removing nils: (setval [z/VECTOR-ZIP z/DOWN z/NEXT-WALK (selected? z/NODE nil?) z/NODE-SEQ] [] [1 2 nil 3 nil])

nathanmarz21:01:04

obviously the approach in #117 would be more elegant as well as more performant