I was wondering what the equivalent Scala code would be for this short F# snippet:
seq {
for i in 1..10 do
printfn "%d"
yield i
}
Is it actually possible to have something like that in Scala?
What I'm actually attempting to implement, though, is shown in the following bit of code:
module BST =
type t =
| Node of int * t * t
| Empty
let rec toSeq tree = seq {
match tree with
| Empty -> ()
| Node(value, left, right) ->
yield! toSeq left
yield value
yield! toSeq right
}
I know how to define discriminated-unions (as case calsses) in Scala, but I'm not so sure how to go about implementing an iterator based on sequences..?
Thanks