Parcourir la source

Implement applyi

DricomDragon il y a 5 ans
Parent
commit
51226f5096
1 fichiers modifiés avec 5 ajouts et 0 suppressions
  1. 5 0
      tp/mine-sweeper/main.hs

+ 5 - 0
tp/mine-sweeper/main.hs

@@ -94,6 +94,11 @@ updateGrid g m =
     let Grid cm = g in
     Grid (zipWith (zipWith updateCell) cm m)
 
+applyi::(a -> a) -> Int -> [a] -> [a]
+applyi f i xs =
+    let (xs1, xs2) = splitAt i xs in
+    concat [xs1, ( (f (head xs2)) : tail xs2 )]
+
 
 -- Testing data