4 ms·
Not sure if I like the 'some?' operation. It's short for (not (nil? x)).. And has nothing to do with 'every?' -which checks if every element of a collection mat
by pi-rat 13y ago
Not sure if I like the 'some?' operation. It's short for (not (nil? x)).. And has nothing to do with 'every?' -which checks if every element of a collection matches a predicate - ex (every? odd? [1 3 5])
To check if some elements match you need to use (some odd? [2 3 4]) - note the lack of '?'
Bet it will confuse people.
- dpassen1 13y agoAgreed. Seems like a very unnecessary addition.
- puredanger 13y agoThe non-nil checks are particularly useful in core.async code as nil is a special value for channels (indicating they've been closed). This family of functions can be used to more concisely determine if a value from a channel is a value or means "close".
- dpassen1 13y agoThanks!
- emiljbs 13y agoI'd love to hear the reasoning behind that choice if it's Rich Hickey that did it, since it's called some and every in Common Lisp and he's written a great deal in that language.
- puredanger 13y agoThe names were chosen by Rich. Many choices were considered and they all had pros and cons. The new some?/if-some/when-some functions follow the "not nil" notion in "some->" (but break with the meaning in "some"). Naming is hard. :)