From 1d561b082a16a191e4b7a4cdb44aea755780c946 Mon Sep 17 00:00:00 2001 From: Rickard Andersson Date: Sat, 29 May 2021 13:40:25 +0300 Subject: [PATCH] add more notes for pipeline exercises Mentions `elem`, might spark usage in `dropWhile`, also mentions `any` explicitly. --- basics/01-values-and-functions.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/basics/01-values-and-functions.md b/basics/01-values-and-functions.md index 85742f7..14c6a34 100644 --- a/basics/01-values-and-functions.md +++ b/basics/01-values-and-functions.md @@ -709,15 +709,19 @@ solution upperBound divisors = ### Exercises (Pipelines using partial application) 1. Define a function using a pipeline that takes a list of `Int`, gets all the even numbers in it, - multiplies them all by two and returns the sum[1]. Create a version that uses a named argument - and one that does not. + multiplies them all by two and returns the sum[1]. Define versions that use: + - a named argument; with `&` + - an unnamed argument; with `>>>` 2. Define a function using a pipeline that takes a list of `Int`, gets all the even numbers in the beginning of the list[2], multiplies them all by two, sums them up and returns whether or not the - sum is even. Create a version that uses a named argument and one that does not. + sum is even. Define versions that use: + - a named argument; with `&` + - an unnamed argument; with `>>>` 3. Define a function using a pipeline that takes a list of strings, takes all the strings beginning - with "#", then discards all leading "#" or " " from the resulting strings. + with "#", then discards all leading "#" or " " from the resulting strings. Take note of what kind + of structure you are working with and what we need to do to work with the structures inside. #### Exercise notes (Pipelines using partial application) @@ -727,6 +731,8 @@ solution upperBound divisors = 2. See examples and previous notes for inspiration and help with this 3. [dropWhile](https://www.stackage.org/haddock/lts-17.12/base-4.14.1.0/Prelude.html#v:dropWhile) 4. [isPrefixOf](https://www.stackage.org/haddock/lts-17.12/base-4.14.1.0/Data-List.html#v:isPrefixOf) +5. [any](https://www.stackage.org/haddock/lts-17.12/base-4.14.1.0/Prelude.html#v:any) +6. [elem](https://www.stackage.org/haddock/lts-17.12/base-4.14.1.0/Prelude.html#v:elem) ## A note on functions, their parameter order and partial application