summaryrefslogtreecommitdiff
path: root/H3.hs
diff options
context:
space:
mode:
Diffstat (limited to 'H3.hs')
-rw-r--r--H3.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/H3.hs b/H3.hs
new file mode 100644
index 0000000..7c8604d
--- /dev/null
+++ b/H3.hs
@@ -0,0 +1,7 @@
+elementAt :: [a] -> Integer -> Maybe a
+
+elementAt [] _ = Nothing
+elementAt (x:xs) 1 = Just x
+elementAt (x:xs) n
+ | n>1 = elementAt xs (n-1)
+ | otherwise = Nothing