on master help sign in
added repeat and replicate
c9051beMekeor Melire
lib/prelude/list.idr+7−1
@@ -109,13 +109,19 @@ length [] = 0
109length (x::xs) = 1 + length xs
109length (x::xs) = 1 + length xs
110
110
111--------------------------------------------------------------------------------
111--------------------------------------------------------------------------------
112−-- Building bigger lists
112+-- Building (bigger) lists
113--------------------------------------------------------------------------------
113--------------------------------------------------------------------------------
114
114
115(++) : List a -> List a -> List a
115(++) : List a -> List a -> List a
116(++) [] right = right
116(++) [] right = right
117(++) (x::xs) right = x :: (xs ++ right)
117(++) (x::xs) right = x :: (xs ++ right)
118
118
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+
119--------------------------------------------------------------------------------
125--------------------------------------------------------------------------------
120-- Instances
126-- Instances
121--------------------------------------------------------------------------------
127--------------------------------------------------------------------------------