Questions tagged [infinite]

An infinite structure or process is one which does not terminate. Infinite loops or structures may be bugs in certain contexts, but also may be desired behavior, particularly in server-processes or lazy languages.

An infinite structure or process is one which does not terminate. Infinite loops or structures may be bugs in certain contexts, but also may be desired behavior, particularly in server-processes or lazy languages.

1090 questions
4
votes
1 answer

Infinite stream of effectful actions

I would like to parse an infinite stream of bytes into an infinite stream of Haskell data. Each byte is read from the network, thus they are wrapped into IO monad. More concretely I have an infinite stream of type [IO(ByteString)]. On the other hand…
abitbol
  • 487
  • 4
  • 8
4
votes
1 answer

SICP exercise 3.67 - producing all pairs of integers without restrictions

From SICP: This is an infinite stream of ones: (define ones (cons-stream 1 ones)) This is an infinite stream of positive integers: ; add-streams takes two streams and produces a stream of their elementwise sum (define integers (cons-stream 1…
lightning_missile
  • 2,821
  • 5
  • 30
  • 58
4
votes
2 answers

Return/break out of infinite foreach in kotlin

For class I have to make a program that calculates the birthday problem Now I'm having trying to learn kotlin at the same time and I'm having trouble with a little snippet of code: val checkSet = mutableSetOf() generateSequence{…
Typhaon
  • 828
  • 8
  • 27
4
votes
0 answers

Infinte scroll slider, make DIV infinite

I want to make my vertical scroll slider infinite; so when you scroll down to the last item and scroll again the first items appears again. The div (id="carousel") has to be infinite. Basics of my HTML:
4
votes
1 answer

Parsing String of parenthesis to nested List in Haskell

My goal was to write a function to parse string of nested parentheses into a corresponding list: parseParens "()" --> [] parseParens "(())" --> [[]] parseParens "((()()))" --> [[[],[]]] First off I discovered that I can't specify easily define a…
Rene Saarsoo
  • 13,580
  • 8
  • 57
  • 85
4
votes
8 answers

Are infinite lists useful for any real world applications?

I've been using haskell for quite a while now, and I've read most of Real World Haskell and Learn You a Haskell. What I want to know is whether there is a point to a language using lazy evaluation, in particular the "advantage" of having infinite…
dom96
  • 1,012
  • 1
  • 9
  • 22
4
votes
2 answers

Haskell - infinite list -

I have this data and types: data Cliente = Uncliente {nombre::String,resistencia::Int,bebidas::[Bebida],amigos::[Cliente]} deriving (Show) type Bebida = Cliente -> Cliente type Nombre = String type Duracion = Float type Acciones = [Bebida] type…
4
votes
2 answers

Zipping with an infinite sequence that is true then always false

I made a extension method: public static IObservable RateLimit(this IObservable source, TimeSpan minDelay) { return source.TimeInterval() .Select( (x, i) => …
spender
  • 117,338
  • 33
  • 229
  • 351
4
votes
1 answer

Haskell how to generate infinite number of lists of infinite random numbers for simulation?

In a simulation problem, I need to generate thousands of agent objects behaving independantly of each other. For this I need to pass each of these agents a different random number generator. How to do this in Haskell? In a language like C, I can…
mntk123
  • 905
  • 6
  • 18
4
votes
2 answers

Compute an (infinite) tree from fixpoint operator using delay modality

Here is a functional programming puzzle involving loop-tying and infinite data structures. There is a bit of background, so hang tight. The setting. Let us define a data type representing recursive data types: type Var = String data STerm = SMu Var…
Edward Z. Yang
  • 26,325
  • 16
  • 80
  • 110
4
votes
3 answers

How does one signify an infinite list to be ascending for elem checks?

I have an infinite list of primes initialized by the following list comprehension: primes = [x | x <- [2..], 0 `notElem` map (x `mod`) [2..(x `quot` 2)]] This allows me to make checks like 17 `elem` primes to confirm that 17 is a prime. However,…
Someone
  • 133
  • 1
  • 10
4
votes
1 answer

Replace Inf in R data.table / Show number of Inf in colums

I can't figure out how to use an is.na(x) like function for infinite numbers in R with a data table or show per column how many Inf's there are: colSums(is.infinite(x)) I use the following example data set: DT <-…
Tim_Utrecht
  • 1,459
  • 6
  • 24
  • 44
4
votes
3 answers

"takeWhile" within a list comprehension

I have something like the following: [bla z|n<-[0..], let z = foo n, z < 42] The thing is, I want the list comprehension to end as soon as z < 42 fails, as if it were a takeWhile. I know I could refactor this into a bunch of filters and maps, but…
PyRulez
  • 10,513
  • 10
  • 42
  • 87
4
votes
4 answers

Pattern matching and infinite lists

I'm having trouble understanding this simple snippet of code: -- This works: foldr go1 [] [1..] -- This doesn't: foldr go2 [] [1..] go1 a b = a : b go2 a [] = a : [] go2 a b = a : b Folding with go1 immediately starts returning values, but…
user1902824
4
votes
1 answer

Infinite While Loop - Memory Use?

I am trying to figure out how a while loop determines how much memory to use. At the basic level: while True: pass If I did a similar thing in PHP, it would grind my localhost to a crawl. But in this case I would expect it to use next to…
1Up
  • 994
  • 2
  • 12
  • 24