We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6cc8ea8 commit 6d5fb94Copy full SHA for 6d5fb94
1 file changed
src/Solutions/DataTypes.idr
@@ -204,9 +204,11 @@ lastMaybe (x :: Nil) = Just x
204
lastMaybe (_ :: xs) = lastMaybe xs
205
206
initMaybe : List a -> Maybe (List a)
207
-initMaybe Nil = Nothing
208
-initMaybe (x :: Nil) = Just Nil
209
-initMaybe (x :: xs) = mapMaybe (x ::) (initMaybe xs)
+initMaybe l = case l of
+ Nil => Nothing
+ x :: xs => case initMaybe xs of
210
+ Nothing => Just Nil
211
+ Just ys => Just (x :: ys)
212
213
foldList : (acc -> el -> acc) -> acc -> List el -> acc
214
foldList fun vacc Nil = vacc
0 commit comments