[Pharo-users] Is lazy evaluation of infinite series possible?

Evan Donahue emdonahu at gmail.com
Sun May 29 11:28:17 EDT 2016


Hello,

I know infinite series are mentioned in the numerical methods book, although
I haven't worked with those classes specifically.

http://files.pharo.org/books/numerical-methods/2016-04-NumericalMethods.pdf

You could also use a LazyList, depending on what you were doing, from
http://smalltalkhub.com/#!/~EvanDonahue/Lazy/

x := 3.
Float e raisedTo: x. " = 20.085536923187664"

eX := LazyList wholes collect: [ :n | (x raisedTo: n) / n factorial ].
(eX take: 20) sum asFloat. " = 20.085536921517672"

2 * (Float e raisedTo: x). " = 40.17107384637533"

twoEX := eX with: eX collect: [ :a :b | a + b ].
(twoEX take: 20) sum asFloat. " = 40.171073843035344"

Will either of those work?

Evan



--
View this message in context: http://forum.world.st/Is-lazy-evaluation-of-infinite-series-possible-tp4897956p4898015.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.




More information about the Pharo-users mailing list