specter

itaied 2025-08-13T08:57:24.274779Z

FIRST stops navigation if the collection is empty. i want to use the nil->val at the end [:coll FIRST :x :y :z (nil->val 42)] is there a nav that doesn't stop navigation equivalent for FIRST?

itaied 2025-08-13T09:10:27.821059Z

in the meantime i have created my own nav

(sp/defnav FIRST []
  (select* [this structure next-fn] (next-fn (first structure)))
  (transform* [this structure next-fn]
              (let [structurev (vec structure)
                    ret (next-fn (first structure))]
                (if (vector? structure)
                  (assoc structurev 0 ret)
                  (cons ret (rest structure))))))

Samuel Ludwig 2025-08-13T14:24:10.045999Z

not exactly what you're looking for but this, i think, would also give you an equivalent outcome, at the cost of some slight verbosity/repetition `(select-one [:coll (s/nil->val [42]) FIRST :x :y :z (s/nil->val 42)] []) ;=> 42` (edit: might be incorrect for how your data is actually structured)

nathanmarz 2025-08-13T15:30:31.854709Z

in a select you can just do (view first)

🙌 1