Following java program creates an infinite fibonacci sequence
(stream) an takes the first 42 values of it.
import java.util.function.UnaryOperator;
import java.util.stream.IntStream;
import java.util.stream.Stream;
public class test3 {
public static void main(String[] args) {
int b
On 4/20/22 19:11, Alain De Vos wrote:
> Maybe there are multiple solutions ?
Indeed. :)
I have a Range struct here:
http://ddili.org/ders/d.en/ranges.html#ix_ranges.infinite%20range
Another one with fibers here:
http://ddili.org/ders/d.en/fibers.html
The same chapter uses Generator:
h
On Thursday, 21 April 2022 at 03:41:24 UTC, Ali Çehreli wrote:
On 4/20/22 19:11, Alain De Vos wrote:
> Maybe there are multiple solutions ?
Indeed. :)
I have a Range struct here:
http://ddili.org/ders/d.en/ranges.html#ix_ranges.infinite%20range
My favorite is the struct range. Because
On Thursday, 21 April 2022 at 04:36:13 UTC, Salih Dincer wrote:
On Thursday, 21 April 2022 at 03:41:24 UTC, Ali Çehreli wrote:
On 4/20/22 19:11, Alain De Vos wrote:
> Maybe there are multiple solutions ?
Indeed. :)
I have a Range struct here:
http://ddili.org/ders/d.en/ranges.html#ix_rang
On Thursday, 21 April 2022 at 05:00:53 UTC, Alain De Vos wrote:
This example limits the maximum value returned by the fibonacci
function. f(n) < limit
But it does not allow to return the n-th element of a fibonacci
function.
You are free to use ```take():```
```d
struct FibonacciRange(long
On Thu, Apr 21, 2022 at 02:11:03AM +, Alain De Vos via Digitalmars-d-learn
wrote:
> Following java program creates an infinite fibonacci sequence (stream)
> an takes the first 42 values of it.
[...]
> How would this program look converted to dlang ?
> Maybe there are multiple solutions ?
Code
On Thursday, 21 April 2022 at 04:36:13 UTC, Salih Dincer wrote:
My favorite is the struct range. Because it is more
understandable and personalized. Moreover, you can limit it
without using ```take()```.
And it's inherently lazy, so no extra processing/calculation
other than what's request