Difference between revisions of "W1349 Higher Order Functions"
From Coder Merlin
Line 387: | Line 387: | ||
'''C''' | '''C''' | ||
<syntaxhighlight lang="swift"> | <syntaxhighlight lang="swift"> | ||
let totalPriceInGalleons = pricesInKnuts.map {$0 / knutsPerSickle}.map {$0 / sicklesPerGalleon}.reduce(0.0, +) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
'''D''' | '''D''' | ||
<syntaxhighlight lang="swift"> | <syntaxhighlight lang="swift"> | ||
let totalPriceInGalleons = pricesInKnuts.filter {$0 > knutsPerSickle}.filter {$0 > sicklesPerGalleon}.reduce(0.0, +) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
|type="[]"} | |type="[]"} |
Revision as of 16:16, 24 March 2019
Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder
Exercises[edit]
Professor Snape needs your help to organize ingredients for a wide variety of potions. You'll need to verify blocks of code to ensure that they're doing exactly what Professor Snape needs. Be careful! Any mistakes can be hazardous to his health. In some cases, more than one answer will be correct.