Interesting framing by Carl Masak:
Code generation and stone soup
Every type of control flow in programming languages is just convenient sugar for
if
statements andwhile
loops.
if
s andwhile
s are the stone soup to which all the rest of our control flow can be added as seasoning.if
s let you conditionally skip ahead in code, andwhile
s allow you to conditionally skip back. That's all you need.
Hadn't quite heard it put it like that before.
I'm as likely as not to try and turn a given task into an operation on lists -- filter with grep
, process with map
, repeat and fade.
I guess if you could squint you could look at map
as a flavor of while
and grep
as your if
.