for (1) I misread the line as it was quite dense, my bad!
It’s not clear to me what (float) % (float) is meant to mean anyway, but JS is weird!
(2) and (3) are really down to the same thing, interpretation of what a
map should be
map refers to using a pure function that uses only the element of a list it’s currently operating on with no side effects
It makes reasoning about things that happen to large lists very easy, all you need to do is look at the function, think about what it does to a single (number/list/whatever) and you know what the final list looks like.
There’s also room with pure maps (of which JS can’t guarantee )for some really cool optimisations where the array can be operated on in parallel and things like that
fold as it’s known elsewhere is an incredible tool - I won’t spoil how but it’s more general than the rest of these, and the rest of these can be implemented with it (and it’s still pure)
forEach is the abstraction that’s like
map that’s associated with impure side effects such as mutation
The following should be in JS and aren’t:
zip is the abstraction that takes two lists and combines them to a list of pairs which can later be merged together
zipWith is the abstraction that takes two lists, examines the elements of each list together and calls a function of two variables on their elements
zipWith is like a map over two arrays at once with a function of two variables