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
8
votes
3 answers

How to create an infinite iterator to generate an incrementing alphabet pattern?

I've created a function that generates a list of alphabets incrementing continuously. A, B, C ..., Z. After Z, it goes to AA, AB, AC ...AZ. This pattern repeats. This is similar to MS Excel's column names. At the moment, this function generates a…
bluprince13
  • 4,607
  • 12
  • 44
  • 91
8
votes
5 answers

Is there any way to separate infinite and finite lists?

For example, I am writing some function for lists and I want to use length function foo :: [a] -> Bool foo xs = length xs == 100 How can someone understand could this function be used with infinite lists or not? Or should I always think about…
ais
  • 2,514
  • 2
  • 17
  • 24
8
votes
1 answer

Create endless cgpath without framedrops

I need to create a cgpath continuously. At the moment I do it like that: func createLine(){ var rand = randomBetweenNumbers(1, 2) currentY-- if rand < 1.5{ currentX-- CGPathAddLineToPoint(leftPath,…
Christian
  • 22,585
  • 9
  • 80
  • 106
8
votes
1 answer

Passing variable through URL with angular js

I am using angular to make an e-commerce, and I'm setting an infinite scroll to the products list page. Everything worked fine, but I want to use the URL to set the page, so the user can access an specific page through URL. how do I set a variable…
Daniel Ortiz
  • 901
  • 2
  • 7
  • 14
8
votes
6 answers

Haskell- Two lists into a list of tuples

I am trying to implement a function (described below) that takes two lists (each or both may be infinite) and return a list of tuples of all the possible pairs of elements between the lists zipInf :: [a] -> [b] -> [(a,b)] (e.g the output should be…
lopezrican304
  • 175
  • 1
  • 2
  • 7
7
votes
4 answers

WebView infinitely expands - how can this be prevented?

I am using a webview in my android app, however after it finishes loading - which I can detect via onPageFinished(WebView webview, String url) - the page continues to infinitely grow in height. How can I prevent this from happening? Here's what I…
Nar Gar
  • 2,591
  • 2
  • 25
  • 28
7
votes
8 answers

Produce the infinite list [0, 1, -1, 2, -2, ... in Haskell

So suppose we want to produce the list [0, 1, -1, 2, -2, ...in Haskell. What is the most elegant way of accomplishing this? I came up with this solution: solution = [0] ++ foldr (\(a,b) c->a:b:c) [] zip [1..] $ map negate [1..] But I am sure there…
Jsevillamol
  • 2,425
  • 2
  • 23
  • 46
7
votes
3 answers

Tidying up a list comprehension in Haskell

So I'm trying to generate a list of taxicab numbers in Haskell. Taxicab numbers are numbers that can be written as the sum of two distinct cubes in two different ways - the smallest is 1729 = 1^3 + 12^3 = 9^3 + 10^3. For now, I'm just bothered about…
A.M.
  • 239
  • 2
  • 11
7
votes
3 answers

Value-equals and circular references: how to resolve infinite recursion?

I have some classes that contain several fields. I need to compare them by value, i.e. two instances of a class are equal if their fields contain the same data. I have overridden the GetHashCode and Equals methods for that. It can happen that these…
Kjara
  • 2,504
  • 15
  • 42
7
votes
1 answer

Type error when implementing finger trees

I wanted to play around with 2-3 finger trees as described in the (Haskell) paper by Hinze (see also this blog). type Node<'a> = | Node2 of 'a * 'a | Node3 of 'a * 'a * 'a static member OfList = function | [a; b] -> Node2(a, b) …
primfaktor
  • 2,831
  • 25
  • 34
7
votes
2 answers

Haskell infinite recursion

The following function computes the Fibonacci sequence: fib = 0 : 1 : (zipWith (+) fib (tail fib)) If we run it, we will get an infinite list, but how does the recursion work? Why does it get to print numbers on the screen if it the function keeps…
7
votes
1 answer

Infinite Blue Noise

I am looking for an algorithm which produces a point placement result similar to blue noise. However, it needs to work for an infinite plane. Where a bounding box is given, and it returns the locations of all points which fall inside. Any help…
7
votes
2 answers

Adding wheel factorization to an indefinite sieve

I’m modifying an indefinite sieve of Eratosthenes from here so it uses wheel factorization to skip more composites than its current form of just checking all odds. I’ve worked out how to generate the steps to take to reach all the gaps along the…
7
votes
2 answers

Is equality testing possible between two infinite data structure in Haskell?

In a project I'm working on, data of a certain type may sometimes contain themselves in it. For example, data Example = Apple Int | Pear Int Example a = Pear 10 a b = Pear 10 b As a programmer I know that a and b are equal, but when I…
Enzo
  • 969
  • 1
  • 8
  • 23
7
votes
3 answers

Performance of seq vs Lazy> in F#

There is a well known solution for generating an infinite stream of Hamming numbers (i.e. all positive integers n where n = 2^i * 3^j * 5^k). I have implemented this in two different ways in F#. The first method uses seq. The solution is…
Fysx
  • 805
  • 1
  • 6
  • 12