Skip to content

Notes for Week 2 Getting Started

ssanj edited this page Nov 19, 2011 · 28 revisions

Links:

Exercises:

  1. Rewrite the following with the use of the notElem (not an element of) function:

    [x | x <- [10..20], x /= 13, x /= 15, x /=19]

  2. Write the replicate function, in terms of repeat and take. Eg:

    replicate 3 10 == ??

  3. Write the sum of the numbers in each sublist of xxs without flattening it:

    let xxs = [ [1,3,5,2,3,1,2,4,5],[1,2,3,4,5,6,7,8,9],[1,2,4,2,1,6,3,1,3,2,3,6] ]

    Eg: [ [x], [y], [z] ], where x,y,z are totals.

  4. What is the type of the tuple in the following expression:

    ([1,2,3], "hello", ['a','b'], (1, 'c', True))

    Eg. (True, 'a') is a (Bool, Char)

Clone this wiki locally