diff options
Diffstat (limited to 'lec03/Golf.hs')
-rw-r--r-- | lec03/Golf.hs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lec03/Golf.hs b/lec03/Golf.hs index e4fa9a3..de3af42 100644 --- a/lec03/Golf.hs +++ b/lec03/Golf.hs @@ -4,9 +4,10 @@ module Golf where -- Explanation: -- takeNth takes the nth value of a list without crashing. First, it drops all --- the first `n - 1` elements from the list. Then, it takes the desired element. --- This function is total and can be thought of as the total version of the --- partial function `!!`. +-- the first `n - 1` elements from the list. Then, it takes the desired element +-- and returns it as a list. If the element can't be found, it returns an empty +-- list. This function is total and can be thought of as the total version of +-- the partial function `!!`. takeNth :: [a] -> Int -> [a] takeNth l n = take 1 $ drop (n-1) l |