Commit 1028aa63 authored by Sandra Dylus's avatar Sandra Dylus

Revise higher-order lecture

parent 4ac5c0f4
......@@ -180,7 +180,24 @@ Instead of always defining a local function we can instead use _anonymous functi
> decYCoordWithMapLambda :: Integer -> CoordMap -> CoordMap
> decYCoordWithMapLambda decY cm = mapCoordMap (\coord -> decXY 0 decY coord) cm
Note that we can use lambda functions like ordinary functions; the following example uses a unary and binary lambda function, respectively, and applies it to the corresponding number of arguments.
> (\x -> if x then 42 else 14) True
> (\x -> if x then 42 else 14) False
> (\x y -> if x then 42 else y) True 14
> (\x y -> if x then 42 else y) False 14
Here we need to use parentheses for the lambda functions in order to explictely mark the end of the right-hand side of the function.
Otherwise an expression like
\x -> if x then 42 else 14 True
reads as if we apply `14` to `True`, which, of course, makes no sense.
## Folding function
The last remaining functions `countCoordMap` and `hasCoord` we have seen on Monday can be generalised as well, but for now only in a restricted way.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment