Amb: Difference between revisions
Content added Content deleted
(→{{header|Tcl}}: Added a coroutine-based version) |
m (→{{header|Tcl}}: formatting) |
||
Line 414:
=={{header|Tcl}}==
Brute force, with quick kill of failing attempts:
<lang Tcl>set amb {
{the that a}
{frog elephant thing}
Line 439 ⟶ 438:
}
}</lang>
A more sophisticated using Tcl 8.6's coroutine facility that avoids the assumption of what the problem is in the code structure:
<lang Tcl>proc cp {args} {
coroutine cp.[incr ::cps] apply {{list args} {
yield [info coroutine]
Line 481 ⟶ 478:
{walked treaded grows} \
{slowly quickly}
while 1 { puts [words] }</lang>
|