3 ms·
I would say it is the difference between first-order and higher-order. While loops are first-order, thus easier to understand, while map is higher-order, thus m
by auggierose 8y ago
I would say it is the difference between first-order and higher-order. While loops are first-order, thus easier to understand, while map is higher-order, thus more difficult to understand.
- Nullabillity 8y ago"Higher order" functions are about whether a function takes code as a tuneable parameter, rather than "just" (user) data. A regular function call is first-order: foo(bar: Int): Int While is usually a magical special case, but conceptually it's just a higher-order function that takes two functions: while(keepGoing: () => Boolean, action: () => Unit): Unit Or, if you want to be pedantic: while[M: Monad](keepGoing: Monad[Boolean], action: Monad[Unit]): Monad[Unit]
- auggierose 8y agoYour higher-order while construct certainly mimics the normal first-order while one. But that's not really the point.