htcc-0.0.0.1: The full scratch implementation of tiny C compiler (x86_64)
Copyright(c) roki 2019
LicenseMIT
Maintainerfalgon53@yahoo.co.jp
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe
LanguageHaskell2010

Htcc.Utils.List

Description

List utilities

Synopsis

Extra functions for lists

takeWhileLen :: (a -> Bool) -> [a] -> (Int, [a]) Source #

takeWhileLen, applied to a predicate f and a list xs, returns the longest prefix (possibly empty) of xs of elements that satisfy f and the length of the list taken. The time complexity of this function is equivalent to takeWhile.

splitAtLen :: Int -> [a] -> (Int, [a], [a]) Source #

splitAtLen, simmilar to splitAt but also returns the length of the splited list.

spanLen :: (a -> Bool) -> [a] -> (Int, [a], [a]) Source #

Almost the same as span, but returns the number of elements in the list that satisfy f at the same time.

lastInit :: (a -> Bool) -> [a] -> Maybe [a] Source #

lastInit returns Just (init xxs) when f (last x) == True for then given list xxs. Otherwise, returns Nothing