0 | module Data.List.Extra
8 | mapi : ((n : Nat) -> (a -> b))
12 | h : Nat -> ((n : Nat) -> (a -> b))
16 | h i f (x :: xs) = f i x :: h (S i) f xs
22 | filterLoc : (a -> Bool) -> List a -> (List a, List Nat)
23 | filterLoc p = h 0 where
24 | h : Nat -> List a -> (List a, List Nat)
26 | h lvl (x :: xs) = if p x
27 | then let (ms, ns) = h (S lvl) xs in (x :: ms, lvl :: ns)
33 | filterLoc' : (a -> Bool) -> List a -> List (a, Nat)
34 | filterLoc' p = h 0 where
35 | h : Nat -> List a -> List (a, Nat)
37 | h lvl (x :: xs) = if p x
38 | then (x, lvl) :: h (S lvl) xs