Re:A Million Digits of Pi in 9 Lines of JavaScript
by foxes on Thursday September 12, 2019 @10:57PM
(#20958782)
Not sure if I can golf it anymore
[ Parent
| on HN ]
Re:A Million Digits of Pi in 9 Lines of JavaScript
by minitech on Friday September 13, 2019 @02:44AM
(#20959782)
That version already doesn’t work… once you fix the arrow function, there’s also the issue that most engines today don’t support proper tail calls, so nothing recursive will be portable. (But if it did, you could save a lot of characters by dropping unnecessary parentheses, expanding (i+1n)×4n to 4n×i+4n, replacing the const with a comma, removing semicolons…)
Re:A Million Digits of Pi in 9 Lines of JavaScript
by sqnguyen on Friday September 13, 2019 @03:02AM
(#20959852)
this is my perl golf version of the same series. You can probably can do something similar with js:
map$l+=(-1)$_/(1-$_2)4,1..<>;die$l
Re:A Million Digits of Pi in 9 Lines of JavaScript
by NieDzejkob on Friday September 13, 2019 @03:32AM
(#20959974)
Doesn't work for me [0]. Perhaps HN messed it up somehow?
[0]: https://tio.run/##K0gtyjH9/z83sUAlR9tWQ9dQUyVeX8NQVyXeSNNEx1...