3 ms·
nothing about s-expressions is bad for using state and little nesting. something about C/etc is bad for nesting heavily. Edit: example. both lisp-style versio
by curi 19y ago
nothing about s-expressions is bad for using state and little nesting.
something about C/etc is bad for nesting heavily.
Edit: example. both lisp-style versions are nicer. if C has advantages, it isn't in making state work better.
(def avg (numbers)
(/ (sum numbers) (count numbers)))
(def avg (numbers)
(= total-number (sum numbers))
(= total-count (count numbers))
(= result (/ total-number total-count))
result)
function avg (numbers) {
/(sum(numbers) count(numbers))
}
function avg(numbers) {
=(total-number sum(numbers))
=(total-count count(numbers))
=(result /(total-number(total-count))
result
}
- greendestiny 19y agoState in procedural languages has more to do with side effects than nice syntax for it. This article has a nice description of how why explicit state is good in procedural languages sometimes: http://prog21.dadgum.com/3.html http://prog21.dadgum.com/3.html