You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my opinion, findonly, filterfirst, filteronly and filterlast are too trivial to be a good idea. These can straightforwardly be written in terms of lazy operations which are much more generically useful that what's proposed here:
findonly -> Iterators.findall + only
filterfirst -> Iterators.filter + first
filteronly -> Iterators.filter + only
filterlast -> Iterators.reverse + Iterators.filter + first
Aside from Iterators.findall not existing, it breaks the straightforward symmetry: first - findfirst(A) vs only - only(Iterators.findall(A)).
I can easily see people using findfirst for simplicity when they really need findonly. It's the same as was before introducing only to Julia: many used first instead.
Also, uniqueonly probably cannot be made performant without a dedicated function for it.
It's slightly annoying that the most useful versions of filter, reverse, etc. are in the Iterators namespace.
Idk, the Base ones are definitely the most useful for me. The return types and performance model of eager operations is the more straightforward one in Julia, compared to lazy Iterators.xxx. Eg, doing filter on an array (or table) gives you the same kind of object back – not some generic iterator.
I'd like to propose adding a bunch of simple functions to Julia:
findonly
: complementsfindfirst
andfindlast
, throws if there are multiple matchesfilterfirst
,filteronly
, maybefilterlast
: same asfirst/last/only(filter(pred, collection))
but fasteruniqueonly
: likeonly(unique(collection))
, but fasterThese are straightforward to implement, and the motivation to include them is similar to that of
only()
: mostly for safety and convenience.The text was updated successfully, but these errors were encountered: