3 ms·
> I imagine bc is using some sort of power series There is also a cool Haskell package, numbers, that has all arithmetics defined via power series: $ cabal
by lelf 7y ago
> I imagine bc is using some sort of power series
There is also a cool Haskell package, numbers, that has all arithmetics defined via power series:
$ cabal v2-repl -b numbers
⡇
λ> import Data.Number.CReal
λ> cos pi + 1 :: CReal
0.0
λ> :set +s
λ> showCReal 10000 pi
"3.141592653589793238462643383279502884197169399375105820…
(2.69 secs, 688,668,864 bytes)
- jandrese 7y ago> 688,668,864 bytes That's an eye popping number for what should be a pretty simple calculation.
- lelf 7y agoWelcome to the world of functional programming! This is how much memory the garbage collector has freed during the computation. It does not mean REPL actually used that much at any given moment.
- giornogiovanna 7y agoYep! Most of the allocations die very young.