Chapter 4 Discussion II
Discussion on first half of the reading guide for Chapter 4.
sub_posn
- Two ordered pair inputs.
- Ordered pair output.
- Subtract corresponding coordinates.
sub_posn (5,7) (1,2) == (4,5)
Dot Product
Multiply the corresponding parts and add.
dot_product (1,3) (4,7) == 1*4 + 3*7
First of
first_of [5,1,2,3] ==
"The first element of [5,1,2,3] is 5."
Pattern
Write a function creating this pattern.
n | 0 | 1 | 2 | 3 | 4 | 5 | 6 |
---|---|---|---|---|---|---|---|
value | “a” | “b” | “c” | “ab” | “bc” | “cab” | “abbc” |
What?
whaa (a,b,c) wow@(x:y:z:ws) = a : z : wow
whaa (5,2,1) [2,4..10] == ?`