for sequence expression is designed to look just like its more famous cousin, the imperative for-loop. It "loops" through a sequence and evaluates the body of each iteration into the sequence it is generating. Just like everything sequence related, it is NOT mutable.
yield and yield!
In sequence workflows, yield adds a single item into the sequence being built. (In monadic terminology, it is return.)
yield! (pronounced yield bang) inserts all the items of another sequence into this sequence being built. Or, in other words, it appends a sequence. (In relation to monads, it is bind.)
Sequences created by sequence workflows are also lazy, meaning that items of the sequence don't actually get evaluated until they're needed. A few ways to force items include calling Seq.take (pulls the first n items into a sequence), Seq.iter (applies a function to each item for executing side effects), or Seq.toList (converts a sequence to a list). Combining this with recursion is where yield! really starts to shine.
This modified text is an extract of the original Stack Overflow Documentation created by following contributors and released under CC BY-SA 3.0