Regarding nil safe functions, @neumann, I believe you said that nth
is not nil safe, but (nth nil 0)
is nil. Maybe you thought about using function application on vectors? (x 0)
isn't nil safe, because the function would be nil.
@lodin.johan Yeah, I wasn't super clear on that point, was I? I think my real issue with nth
is that the collection isn't at the end like the typical sequence functions. It's more like the map-related functions that put the collection second.
Yeah, that's an annoyance most of the time. And you do get a null pointer exception if you use it in a ->>
and the sequence is null. 😉
@lodin.johan you are absolutely right that passing a nil for the collection puns correctly
I think in this case, passing nil for the index doesn't pun well and you get a NPE
very interesting point you made about vectors as functions
I never thought to use them like that, but they do behave correctly
of course, when they are not nil
Oh. I see. What would you expect (nth coll nil)
to do?
I can't think of a reasonable default