X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=exercises%2Fassignment3_hint1.mdwn;fp=exercises%2Fassignment3_hint1.mdwn;h=c222c09194042dfbfbdc30791ce780162cdf5960;hp=0000000000000000000000000000000000000000;hb=e241399e18ff5f4eeb99bab8d4ca1a2f95b7ab63;hpb=957c10dcb822689bffd79fecf63236470dd7049d;ds=sidebyside diff --git a/exercises/assignment3_hint1.mdwn b/exercises/assignment3_hint1.mdwn new file mode 100644 index 00000000..c222c091 --- /dev/null +++ b/exercises/assignment3_hint1.mdwn @@ -0,0 +1,7 @@ +## Comprehensions + +3. Using either Kapulet's or Haskell's list comprehension syntax, write an expression that transforms `[3, 1, 0, 2]` into `[3, 3, 3, 1, 2, 2]`. + +*Here is a hint* + +Define a function `dup (n, x)` that creates a list of *n* copies of `x`. Then use list comprehensions to transform `[3, 1, 0, 2]` into `[[3, 3, 3], [1], [], [2, 2]]`. Then use `join` to "flatten" the result.