Combining higher-order functions
Take ["a", "b", "c"] as input and produce ["c-0", "b-1", "a-2"]. You can't use a for loop, only higher-order functions. Which functions would you combine, and in what order?
Take ["a", "b", "c"] as input and produce ["c-0", "b-1", "a-2"]. You can't use a for loop, only higher-order functions. Which functions would you combine, and in what order?
First reversed() to flip the order, then enumerated() to number the flipped order from 0, then map to interpolate element and index into a string. enumerated numbers whatever order it's called on, so reversed has to come first for c to get 0.
SwiftMultiple choiceBasics
What does this code print? …
#map
SwiftShort answerBasics
In Swift, what exactly does a KeyPath like \.name represent as a value?
#functional
SwiftShort answerAdvanced
Suppose there were no question-mark optional syntax and no standard Optional. If you had…
#map
CS fundamentals and algorithmsMultiple choiceBasics
Which of these are pure functions (same output for the same input, no side effects)?…
#functional