Index: doc/example-scripts/rosetta-multiple-distinct.tcl =================================================================== diff -u -r8648ec770a59ed911769dd51cf2658045110c748 -rae081c0f1926da915e0584d8561abaa8a2a022a4 --- doc/example-scripts/rosetta-multiple-distinct.tcl (.../rosetta-multiple-distinct.tcl) (revision 8648ec770a59ed911769dd51cf2658045110c748) +++ doc/example-scripts/rosetta-multiple-distinct.tcl (.../rosetta-multiple-distinct.tcl) (revision ae081c0f1926da915e0584d8561abaa8a2a022a4) @@ -2,9 +2,9 @@ # == Rosetta example: Multiple distinct objects # # -# Create a sequence (array, list, whatever) consisting of n distinct, -# initialized items of the same type. n should be determined at -# runtime. +# Create a sequence (array, list, whatever) consisting of "n" +# distinct, initialized items of the same type. The value of "n" +# should be determined at runtime. # # https://rosettacode.org/wiki/Multiple_distinct_objects # @@ -13,22 +13,23 @@ package req nx::test # -# The class +Klass+ defines and implements the item type. It can also +# The class +Foo+ defines and implements the item type. It can also # be used to query its population of instances. # -nx::Class create Klass +nx::Class create Foo set n 100; # runtime parameter # -# Wrong: Only a single item (object) is created, its (command) name is replicated +n+ times. +# Wrong: Only a single item (object) is created, its (command) name is +# replicated +n+ times. # -? {llength [Klass info instances]} 0; +? {llength [Foo info instances]} 0; -set theList [lrepeat $n [Klass new]] +set theList [lrepeat $n [Foo new]] -? {llength [Klass info instances]} 1; +? {llength [Foo info instances]} 1; ? {llength [lsort -unique $theList]} 1; [lindex $theList 0] destroy @@ -38,13 +39,13 @@ # created and stored in the list. # -? {llength [Klass info instances]} 0; +? {llength [Foo info instances]} 0; set theList {} for {set i 0} {$i<$n} {incr i} { - lappend theList [Klass new] + lappend theList [Foo new] } -? {llength [Klass info instances]} 100; +? {llength [Foo info instances]} 100; ? {llength [lsort -unique $theList]} 100;