BigInteger Infinity

• Question

• Hello again,

As an F# sequence can store an infinite number (aleph-0) of elements (because it uses lazy initialization), I'd like to know how can one be created (in F#, of course, however the used feature may be from .NET or any other compatible library). For expl., from negative infinite to 125.

João Miguel

Sunday, November 11, 2012 6:21 PM

• ```let infSeq = seq {
let current = ref 0I
while true do
yield !current
current := !current + 1I
};;```

Or

`Seq.unfold (fun c -> Some(c, c+1I)) startNumber;;`

You can't obviously get a seq from negative infinity to 125, because seq is only iterable from start to end. What would be the first number in that seq?

• Marked as answer by Monday, November 12, 2012 7:57 PM
Monday, November 12, 2012 12:17 AM

All replies

• ```let infSeq = seq {
let current = ref 0I
while true do
yield !current
current := !current + 1I
};;```

Or

`Seq.unfold (fun c -> Some(c, c+1I)) startNumber;;`

You can't obviously get a seq from negative infinity to 125, because seq is only iterable from start to end. What would be the first number in that seq?

• Marked as answer by Monday, November 12, 2012 7:57 PM
Monday, November 12, 2012 12:17 AM
• You can't obviously get a seq from negative infinity to 125, because seq is only iterable from start to end. What would be the first number in that seq?

Maybe I can represent that by iterating backwards. The first number wouldn't exist, only the last (125, that would be actually, the first). This was just my curiosity working.

Thanks for the help,

João Miguel

Monday, November 12, 2012 8:00 PM