Two chunks but No allocation
rkompass
rkompass at gmx.de
Wed Mar 27 20:50:05 UTC 2024
On Wednesday, 27 March 2024 at 13:38:29 UTC, Salih Dincer wrote:
> So, not works this:
>
> ```d
> fib(1, 1).take(48)
> //.array
> .chunks(2)
> .map!"a[1] / a[0]"
> .back
> .writeln; // 1.61803
> ```
>
> Thanks...
>
> SDB at 79
This works:
```d
import std.stdio;
import std.range;
import std.algorithm;
void main() {
auto fib = (real a, real b) => recurrence!"a[n-1] + a[n-2]"(a,
b);
auto golden = fib(1, 1).drop(46).take(2).fold!((a, e) => a/e);
writefln("%.20f", golden);
writeln("0.61803398874989484820");
}
```
More information about the Digitalmars-d-learn
mailing list