span (< 3) [1,2,3,4,1,2,3,4] == ([1,2],[3,4,1,2,3,4]) span (< 9) [1,2,3] == ([1,2,3],[]) span (< 0) [1,2,3] == ([],[1,2,3])span p xs is equivalent to (takeWhile p xs, dropWhile p xs)
'span' p xs == ('takeWhile' p xs, 'dropWhile' p xs) xs == ys ++ zs where (ys, zs) = 'span' p xs
spanEnd (not.isSpace) "x y z" == ("x y ","z")and
spanEnd (not . isSpace) ps == let (x,y) = span (not.isSpace) (reverse ps) in (reverse y, reverse x)
spanAntitone p xs = (takeWhileAntitone p xs, dropWhileAntitone p xs) spanAntitone p xs = partitionWithKey (k _ -> p k) xsNote: if p is not actually antitone, then spanAntitone will split the map at some unspecified point where the predicate switches from holding to not holding (where the predicate is seen to hold before the first key and to fail after the last key).
spanAntitone p xs = (takeWhileAntitone p xs, dropWhileAntitone p xs) spanAntitone p xs = partition p xsNote: if p is not actually antitone, then spanAntitone will split the set at some unspecified point where the predicate switches from holding to not holding (where the predicate is seen to hold before the first element and to fail after the last element).