Kaynağa Gözat

Implement applyi

DricomDragon 5 yıl önce
ebeveyn
işleme
51226f5096
1 değiştirilmiş dosya ile 5 ekleme ve 0 silme
  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