Version 1 of Sugar macros collection

Updated 2004-03-23 19:04:25

A page to collect useful Sugar macros.

This one was suggested by Richard Suchenwirth (but the implementation is mine (SS), so even possible bugs):

 sugar::macro inlist argv {
     if {[llength $argv] != 3} {error "Bad number of arguments"}
     list expr \
         "\{\[lsearch -exact [lindex $argv 1] [lindex $argv 2]\] != -1\}"
 }

This expands

 inlist $list $foo

in

 expr {[lsearch -exact $list $foo] != -1}