So, if you go to the bank, there is a device from which you can withdraw the number.
I want to write such a function. Therefore, every time this function is called, we get the next number in the series.
So, if this function is called for the first time, we get 1. the second time we get 2 .... so on and so forth.
this is what i wrote so far
let X = let myseq = seq {1 .. 100} let GetValue = Seq.head (Seq.take 1 myseq) GetValue;; let p = X;; p;; p;; p;;
But it always returns 1. I hope that since the sequence is a closure, every time I do this, I get the next number.
I also tried this
let X = let mutable i = 1 let GetValue = i <- i + 1 i GetValue;; let p = X;; p;; p;; p;;
This one only prints 2 ...
source share