on master help sign in
added repeat and replicate
commitc9051be62b0340406950d5ec31528c932b47b506 authorMekeor Melire <mekeor@ymail.com> dateSun 3 Jun 2012, 23:55 (14 years ago) parentab12e51
1 file changed+7−1
lib/prelude/list.idr+7−1
lib/prelude/list.idr+7−1
@@ -109,13 +109,19 @@ length [] = 0
109109length (x::xs) = 1 + length xs
110110
111111--------------------------------------------------------------------------------
112−-- Building bigger lists
112+-- Building (bigger) lists
113113--------------------------------------------------------------------------------
114114
115115(++) : List a -> List a -> List a
116116(++) [] right = right
117117(++) (x::xs) right = x :: (xs ++ right)
118118
119+repeat : a -> List a
120+repeat x = x :: repeat x
121+
122+replicate : Nat -> a -> List a
123+replicate n x = take n (repeat x)
124+
119125--------------------------------------------------------------------------------
120126-- Instances
121127--------------------------------------------------------------------------------