Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Initializing an infinite list of BigIntegers

Ok, So I need a list of all the positive integers. What first comes to mind is:

let numbers:Seq<bigint>=Seq.initInfinite n...

but initInfite isn't actually infitint: http://msdn.microsoft.com/en-us/library/ee370429.aspx (unlike bigint) its only: Int32.MaxValue = 2,147,483,647 which is nowhere near big enough.

Currently my plan is to replace the sequence with some kind of handmade class (possibly implimenting IEnumerable). It would be simple (and possibly more effiecint for my use) but i want to know how to do this

like image 859
Lyndon White Avatar asked Jun 09 '11 06:06

Lyndon White


1 Answers

Seq.unfold (fun n -> Some(n, n + 1I)) 0I
like image 91
Brian Avatar answered Sep 17 '22 14:09

Brian