4 ms·
I find it tremendously helpful to move the function out of the flow of logic so it is modularized. When I read scala or haskell code where as soon as you see ma
by mlthoughts2018 8y ago
I find it tremendously helpful to move the function out of the flow of logic so it is modularized. When I read scala or haskell code where as soon as you see map or filter or something you know you’re gonna get some crazy anonymous function to follow, I get sad because it’s a miserable and confusing way to write code instead of pulling the function out into a separate definition with documentation, and then having the map or filter part be extremely concise using only predefined functions.
- jcelerier 8y ago> I get sad because it’s a miserable and confusing way to write code you just have to visualize it as a tree
- mlthoughts2018 8y agoYes, that is a confusing way to write and read code, rather than a linear flow, like flattening the tree by extracting functions into separate definitions.
- deleted 8y ago[deleted]
- jcelerier 8y ago> Yes, that is a confusing way to write and read code, rather than a linear flow, like flattening the tree by extracting functions into separate definitions. I don't understand. It's harder to flatten the tree: you have to unflatten it in your mind afterwards to understand what's happening. It's easier to just visualize, say, this lisp function as a tree directly. (defun good-enough-p (guess x) (format t "~% Guess =~7,4f Guess^2 = ~7,4f Error= ~7,4f" guess (* guess guess) (abs (- (* guess guess) x))) (< (abs (- (* guess guess) x)) .001))