Modified run-length encoding. Modify the result of item 10 in such a way that if an element has no duplicates it is simply copied into the result list. Only elements with duplicates are transferred as (n,e) lists.
Decode a run-length encoded list. Given a run-length code list generated as specified in item 11. Construct its uncompressed version.
Run-length encoding of a list. Implement the so-called run-length encoding data compression method directly. I.e. don’t explicitly create the sublists containing the duplicates, as in item 9, but only count them. As in item 11, simplify the result list by replacing the singleton lists (1,x) by x.
Duplicate the elements of a list.
Replicate the elements of a list a given number of times.
Drop every n-th element from a list.
Split a list into two parts; the length of the first part is given. Do not use any predefined predicates.
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.
Rotate a list n places to the left. Hint: Use the predefined functions length and (++).
Remove the k-th element from a list.
Scoring
Each item scores 10 points.
Input
encodeModified "aaaabccaadeeee" decodeModified [Multiple 4 'a',Single 'b',Multiple 2 'c',Multiple 2 'a',Single 'd',Multiple 4 'e'] encodeDirect "aaaabccaadeeee" dupli [1, 2, 3] repli "abc" 3 dropEvery "abcdefghik" 3 split "abcdefghik" 3 slice "abcdefghik" 3 7 rotate "abcdefgh" 3 rotate [1..10] (-2) removeAt 2 "abcd"
Output
[Multiple 4 'a',Single 'b',Multiple 2 'c',Multiple 2 'a',Single 'd',Multiple 4 'e'] "aaaabccaadeeee" [Multiple 4 'a',Single 'b',Multiple 2 'c',Multiple 2 'a',Single 'd',Multiple 4 'e'] [1,1,2,2,3,3] "aaabbbccc" "abdeghk" ("abc","defghik") "cdefg" "defghabc" [9,10,1,2,3,4,5,6,7,8] ('b',"acd")