mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
34 lines
435 B
Go
34 lines
435 B
Go
package main
|
|
|
|
import "iter"
|
|
|
|
func main() {
|
|
testFuncRange(counter)
|
|
testIterPull(counter)
|
|
println("go1.23 has lift-off!")
|
|
}
|
|
|
|
func testFuncRange(it iter.Seq[int]) {
|
|
for i := range it {
|
|
println(i)
|
|
}
|
|
}
|
|
|
|
func testIterPull(it iter.Seq[int]) {
|
|
next, stop := iter.Pull(it)
|
|
defer stop()
|
|
for {
|
|
i, ok := next()
|
|
if !ok {
|
|
break
|
|
}
|
|
println(i)
|
|
}
|
|
}
|
|
|
|
func counter(yield func(int) bool) {
|
|
for i := 10; i >= 1; i-- {
|
|
yield(i)
|
|
}
|
|
}
|