From 9c608c32a9387a1dd1cb045e5822733ad181ccf8 Mon Sep 17 00:00:00 2001 From: Determinant Date: Sun, 28 May 2017 20:29:11 -0400 Subject: finish vol 2 --- 11-20/20.hs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 11-20/20.hs (limited to '11-20/20.hs') diff --git a/11-20/20.hs b/11-20/20.hs new file mode 100644 index 0000000..c6a3ba8 --- /dev/null +++ b/11-20/20.hs @@ -0,0 +1,6 @@ +removeAt :: Int -> [a] -> (Maybe a, [a]) + +removeAt k (x:xs) + | k > 1 = let (a, b) = removeAt (k - 1) xs in (a, x:b) + | k == 1 = (Just x, xs) +removeAt _ l = (Nothing, l) -- cgit v1.2.3-70-g09d2