summaryrefslogtreecommitdiff
path: root/11-20/20.hs
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2017-05-28 20:29:11 -0400
committerDeterminant <ted.sybil@gmail.com>2017-05-28 20:29:11 -0400
commit9c608c32a9387a1dd1cb045e5822733ad181ccf8 (patch)
tree9464fd3f8e218c6000783c80e2db7b573c30ea80 /11-20/20.hs
parentb2d6f0e28dac922ac4ed5c55f79d0dd38f4765d2 (diff)
finish vol 2
Diffstat (limited to '11-20/20.hs')
-rw-r--r--11-20/20.hs6
1 files changed, 6 insertions, 0 deletions
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)