What | stream |
Where | https://github.com/lawrencewoodman/stream_tcl |
Description | A Tcl module providing streams. The implementation is based on streams in SICP with the functions operating on them inspired by those in Racket. |
Requirements | Tcl 8.5+ |
License | MIT |
Updated | 2015-06-15 |
The following example comes from the project's README.
package require stream proc naturals {{start 0}} { set nextNum [expr {$start + 1}] stream create $start [list naturals $nextNum] } namespace import ::tcl::mathop::+ proc addThousand {num} { expr {$num + 1000} } proc isEven {num} { expr {$num % 2 == 0} } set thousands [stream map addThousand [naturals]] set evenThousands [stream select isEven $thousands] set tenThousands [stream take 10 $evenThousands] set sum [stream foldl + 0 $tenThousands] puts "sum: $sum"