[Pharo-users] Is lazy evaluation of infinite series possible?
emdonahu at gmail.com
Sun May 29 11:28:17 EDT 2016
I know infinite series are mentioned in the numerical methods book, although
I haven't worked with those classes specifically.
You could also use a LazyList, depending on what you were doing, from
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?
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