Amb: Difference between revisions

60 bytes added ,  15 years ago
→‎{{header|Tcl}}: renamed 'fit' to 'joins', for better comparison with other languages
(→‎{{header|Tcl}}: renamed 'fit' to 'joins', for better comparison with other languages)
Line 415:
Brute force, with quick kill of failing attempts:
<lang Tcl>
procset amb list {set list}
{the that a}
{frog elephant thing}
{walked treaded grows}
{slowly quickly}
 
proc fitjoins {a b} {
expr {[string index $a end] eq [string index $b 0]}
}
 
foreach i [lindex $amb {the that a}0] {
foreach j [lindex $amb {frog elephant thing}1] {
if ![fitjoins $i $j] continue
foreach k [lindex $amb {walked treaded grows}2] {
if ![fitjoins $j $k] continue
foreach l [amblindex {slowly$amb quickly}3] {
if [fitjoins $k $l] {
puts [list $i $j $k $l]
}
Line 433 ⟶ 438:
}
}
}</lang>
</lang>
Anonymous user