فهرست منبع

Implement applyi

DricomDragon 5 سال پیش
والد
کامیت
51226f5096
1فایلهای تغییر یافته به همراه5 افزوده شده و 0 حذف شده
  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