on master help sign in
More operations on lists
commit9e751321ce7fef08f90ed50e243f5308df4848e3 authorJohn Dobronszki <janosdobronszki@citromail.hu> dateSun 13 Apr 2014, 23:23 (13 years ago) parentb283c0d
1 file changed+10
libs/prelude/Prelude/List.idr+10
libs/prelude/Prelude/List.idr+10
@@ -439,6 +439,16 @@ partition p (x::xs) =
439439 else
440440 (lefts, x::rights)
441441
442+inits : List a -> List (List a)
443+inits xs = [] :: case xs of
444+ [] => []
445+ x :: xs' => map (x ::) (inits xs')
446+
447+tails : List a -> List (List a)
448+tails xs = xs :: case xs of
449+ [] => []
450+ _ :: xs' => tails xs'
451+
442452--------------------------------------------------------------------------------
443453-- Predicates
444454--------------------------------------------------------------------------------