Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I’m disturbed that he needed a for loop to compute 100*(1-0.9^10)


> I’m disturbed that he needed a for loop to compute 100*(1-0.9^10)

I assumed that he just wanted a reason to include at least a _little_ elisp. (Though, even so, he could at least have run the calculation recursively; in Raku, I'd probably have written

  (-> $_, $i { $i ?? &?BLOCK($_ × .9, $i-1) !! $_ })(100, 10)
if I wanted an alternative to `100 × (1 - .9¹⁰)`


I'm disturbed by this awful loop, every time I see `setq' gives me the heretic though, that most of the eslip code is just Perl with parentheses.

  (cl-loop
    for sum = 0 then (+ sum (* total 0.1))
    for total = 100 then (* total 0.9)
    repeat 10
    finally (return (list sum total)))


For absolute throwaway, get-something-done code, I think it was fine. If you’re trying to hack out an answer, points for style, mathematical or programming-wise, don’t count.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: