3 ms·
Why the heck would you write the functional recipe the way he wrote it? 1. Take an oven and apply 175 C setting on it, producing a preheated oven. Set this asi
by typon 11y ago
Why the heck would you write the functional recipe the way he wrote it?
1. Take an oven and apply 175 C setting on it, producing a preheated oven. Set this aside.
2. Take two 8 inch round pans and some grease and flour, produce two 8 inch round pans with grease and flour applied on them.
3. Take a small bowl, some flour, baking soda, salt, salt and a whisk (a first-class function), return a small bowl with flour, baking soda and salt whisked in it.
and so on.
When you think of functional programs as series of operations chained together, it becomes really natural. In most recipes you don't need to loop back to an existing state.a
- pekk 11y agoThe real cake recipe can specify how to achieve the results instead of just saying that they should be achieved. It does not have to deal with issues like lazy evaluation or defining a batter monad. It does not have to trail off into "and so on" or else go on for far too many lines because of how tortured an exercise it is to make "pure functional" cake recipes. If you want to argue with this, just deny that cake recipes are a good metaphor for programming, since they are essentially imperative and that is begging the question. But you aren't going to convince people that weirdly abstracted cake recipes are easier to write or follow.
- DrScump 11y agoPlus, you can do multiple iterations, skipping step 1 for subsequent iterations.