infinite-sequence Questions

3

Solved

Prelude In Raku there's a notion called infinite list AKA lazy list which is defined and used like: my @inf = (1,2,3 ... Inf); for @inf { say $_; exit if $_ == 7 } # => OUTPUT 1 2 3 4 5 6 7 I'...
Clarinda asked 21/1, 2021 at 16:26

10

Solved

I am trying to solve Project Euler problem #12: The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28...
Jaipur asked 16/6, 2011 at 14:14

5

Solved

I have a piece of code which would code as follows: val e2 = for (e <- elements if condition(expensiveFunction(e))) yield { expensiveFunction(e) } Where the condition will be true for a few...
Unwish asked 28/11, 2012 at 1:38

5

Solved

Given a starting number, imagine an infinite sequence of its successive halves. 1, 0.5, 0.25, 0.125, ... (Ignore any numerical instabilities inherent in double.) Can this be done in a single ex...
Suspensoid asked 22/2, 2012 at 17:17

5

Solved

What is the most optimal way to find repetition in a infinite sequence of integers? i.e. if in the infinite sequence the number '5' appears twice then we will return 'false' the first time and 'tr...

3

Solved

What are some clever uses for infinite generators? I've seen lots of seemingly trivial examples like "list all even numbers", but I assume there must be others that have more applicability to...
Sevigny asked 9/2, 2011 at 19:58

4

Solved

Given a finite list of elements, how can I create a (lazily-evaluated, thanks LINQ!) infinite list that just keeps iterating over my initial list? If the initial list is {1, 2, 3}, I want the new ...
Garner asked 26/8, 2010 at 13:46

3

Solved

I am not a Google App Engine user. However, I understand you're billed for CPU time and other resources. What are the consequences if you happen to create an infinite loop? Will Google ever t...
Woaded asked 1/6, 2010 at 6:0

2

Solved

I am looking through some example Fibonacci sequence clojure code: (def fibs (lazy-cat [1 2] (map + fibs (rest fibs)))) I generally understand what is going on, but don't get the point of lazy-...
Dexamyl asked 31/5, 2010 at 15:59
1

© 2022 - 2024 — McMap. All rights reserved.