X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=exercises%2Fassignment3_hints.mdwn;fp=exercises%2Fassignment3_hints.mdwn;h=b63a70a8856f2ba0e35ca31312b1dffb21ce3e11;hp=0000000000000000000000000000000000000000;hb=dea3d44a63cf46683806bc739fe236fd238b1374;hpb=020566910974049e4cd9cbc9279a781768e1817c diff --git a/exercises/assignment3_hints.mdwn b/exercises/assignment3_hints.mdwn new file mode 100644 index 00000000..b63a70a8 --- /dev/null +++ b/exercises/assignment3_hints.mdwn @@ -0,0 +1,13 @@ +## 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. + +## Lists + +7. Continuing to encode lists in terms of their left-folds, how should we write `head`? This is challenging. + +*Here is a hint*