3 ms·
Great read - I worked through it in JavaScript in the console. Writing Scheme-ish code in JS is so much nicer with ES6 than it was with ES5! const iterativ
by mrspeaker 10y ago
Great read - I worked through it in JavaScript in the console. Writing Scheme-ish code in JS is so much nicer with ES6 than it was with ES5!
const iterativeImprove = (guess, improve, goodEnough) =>
goodEnough(guess) ?
guess :
iterativeImprove(improve(guess), improve, goodEnough);
I think the example used (and the intermediate functions) come straight from SICP. I always intend to do the exercises in this book, but never have... This post actually got me to do it, so hat's off to you!
- throwaway7645 10y agoYea I immediately thought this is from SICP
- bogomipz 10y agoOn that note(SICP in Clojure) there is also this which has been mentioned here on HN before: http://www.sicpdistilled.com/ http://www.sicpdistilled.com/