/ Published in: Haskell
URL: http://www.haskell.org/haskellwiki/99_questions/11_to_20
Problem 18: Extract a slice from a list.
Given two indices, i and k, the slice is the list containing the elements between the i'th and k'th element of the original list (both limits included). Start counting the elements with 1.
Example:
*Main> slice ['a','b','c','d','e','f','g','h','i','k'] 3 7
"cdefg
9 Problem 19 - Rotate a list N places to the left.
*Main> rotate ['a','b','c','d','e','f','g','h'] 3
"defghabc"
*Main> rotate ['a','b','c','d','e','f','g','h'] (-2)
"ghabcdef"
(This one is so easy it feels like cheating...)
Expand |
Embed | Plain Text
where -- More efficient solution (from the solutions): -- I forgot all about take when solving this...
You need to login to post a comment.
