parent:
a0fb899af5cbe112b45e7fa277bbaef831fa652b
Nick Mykins <nickmykins@transfix.io>
2018-02-02T12:45:17-05:00
be a little more concise
diff --git a/99_problems.hs b/99_problems.hs index 07402cf2c9913a9418308113d1fbf10742e5cde7..59c7e76219e123f556eeed2f69c6ca21f2d6baf6 100644 --- a/99_problems.hs +++ b/99_problems.hs @@ -134,7 +134,7 @@ -- 16. Drop every n'th element from a list dropEvery :: [a] -> Int -> [a] -dropEvery list n = map fst [x | x <- zip list [1..], snd x `mod` n /= 0] +dropEvery list n = [fst x | x <- zip list [1..], snd x `mod` n /= 0] -- 17. Split a list into two parts, given the length of the first part @@ -147,8 +147,7 @@ -- 18. Extract a slice from a list slice :: [a] -> Int -> Int -> [a] -slice list i j = map fst enumerated - where enumerated = [x | x <- zip list [1..], snd x >= i, snd x <= j] +slice list i j = [fst x | x <- zip list [1..], snd x >= i, snd x <= j] -- 19. Rotate a list n places to the left