fncounter(start: int) {
letmut n = start
returnIter.from_fn(|| {
let val = n
n = n +1return val
})
}
let c =counter(10) |>Iter.take(4) |>Iter.collect()
print(c) // [10, 11, 12, 13]
Goal: Create a Fibonacci iterator using Iter.from_fn and take the first 8 terms.