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
Can't seem to find any functions that check if a structure is empty.
Though it can be implemented by composing isNothing with head but this is O(n) on any structure other than array.
While i can't figure out a O(1) version of isNothing, or head for that matter, an alternative empty checker could be implemented this other way:
// isEmpty :: (Monoid a, Setoid a) => a -> Boolean
const isEmpty = (a) => equals (a) (empty(a))
This is different from the standard implementation, as it doesn't even require it to be a foldable, but provides arguably the same functionality (at least on most structures)
Either implementation would be nice to have IMO.
The text was updated successfully, but these errors were encountered:
Can't seem to find any functions that check if a structure is empty.
Though it can be implemented by composing
isNothing
withhead
but this is O(n) on any structure other than array.While i can't figure out a O(1) version of
isNothing
, orhead
for that matter, an alternative empty checker could be implemented this other way:This is different from the standard implementation, as it doesn't even require it to be a foldable, but provides arguably the same functionality (at least on most structures)
Either implementation would be nice to have IMO.
The text was updated successfully, but these errors were encountered: