Commit 55c2611a authored by Martin Wierich's avatar Martin Wierich
Browse files

added handy new macro for searching lists

parent 0d2a3ca8
......@@ -180,6 +180,17 @@ foldrArraySt f a st
# (ai, a) = a![i]
= foldr_a_st (i-1) a (f ai st)
firstIndex p l :== first_index l 0
where
first_index [] i
= (i-i)-1
first_index [h:t] i
| p h
= i
= first_index t (i+1)
optCons :: !(Optional .a) !u:[.a] -> (!v:[.a], !Int) ,[u <= v]
revAppend :: ![a] ![a] -> [a] // Reverse the list using the second argument as accumulator.
......
......@@ -266,6 +266,15 @@ foldrArraySt f a st
# (ai, a) = a![i]
= foldr_a_st (i-1) a (f ai st)
firstIndex p l :== first_index l 0
where
first_index [] i
= (i-i)-1
first_index [h:t] i
| p h
= i
= first_index t (i+1)
optCons :: !(Optional .a) !u:[.a] -> (!v:[.a], !Int) ,[u <= v]
optCons No l
= (l, 0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment