File: example2.tcl

package info (click to toggle)
tcl-sugar 0.1-1.1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 176 kB
  • sloc: tcl: 647; sh: 13; makefile: 2
file content (18 lines) | stat: -rw-r--r-- 382 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package require sugar

sugar::macro inlist {name list element} {
    list expr "\{\[lsearch -exact $list $element\] != -1\}"
}

sugar::proc test {} {
    set list {tcl c ada python scheme forth joy smalltalk}
    foreach lang {pascal scheme php ada tcl} {
	if {[inlist $list $lang]} {
	    puts "$lang is in the list"
	} else {
	    puts "$lang is not in the list"
	}
    }
}

test