if 0 {[Richard Suchenwirth] 2003-06-26 - Re-reading an old book on DR [Logo], I found this funny little program that produces random recipes (please correct my re-translations to English where needed). Small as it is, it can produce 900 different recipes, though they might not be to everybody's taste... but may be helpful when we [teach programming to children]? [http://mini.net/files/cookbook.jpg] The basic idea is to pick an arbitrary element from a list, which is easily done in Tcl with the following:} proc ? L { lindex $L [expr {int(rand()*[llength $L])}] } if 0 {This is used several times in:} proc recipe {} { set a { {3 eggs} {an apple} {a pound of garlic} {a pumpkin} {20 marshmallows} } set b { {Cut in small pieces} {Dissolve in lemonade} {Bury in the ground for 3 months} {Bake at 300 degrees} {Cook until tender} } set c {parsley snow nutmeg curry raisins cinnamon} set d { ice-cream {chocolate cake} spinach {fried potatoes} rice {soy sprouts} } return " Take [? $a]. [? $b]. Top with [? $c]. Serve with [? $d]." } if 0 {And as modern programs always need a GUI, here is a minimal one that appears when you source this file at top level, and shows a new recipe every time you click on it:} if {[file tail [info script]]==[file tail $argv0]} { package require Tk pack [text .t -width 40 -height 5] bind .t <1> {showRecipe %W; break} proc showRecipe w { $w delete 1.0 end $w insert end [recipe] } showRecipe .t } ---- [TV] Good, me like. Looks like the beginning of a little expert system. Maybe one would want ot value the various combinations and suggest a taste base.. ---- [Arts and crafts of Tcl-Tk programming]