tcltk -2

Tcl supports the following mathematical functions in expressions:

 

abs         acos        asin        atan
atan2       bool        ceil        cos
cosh        double      entier      exp
floor       fmod        hypot       int
isqrt       log         log10       max
min         pow         rand        round
sin         sinh        sqrt        srand
tan         tanh        wide


    * switch string { pattern1 body1 ?pattern2 body2?...?patternN bodyN? }
    * while test body
    * for start test next body
for {set i 0} {$i < 10} {incr i} {
    puts "I inside first loop: $i"
}

    * proc name args body
proc example {required {default1 a} {default2 b} args} {...}


list ?arg1? ?arg2? ... ?argN?
    makes a list of the arguments
split string ?splitChars?
    Splits the string into a list of items wherever the splitChars occur in the code. SplitChars defaults to being whitespace. Note that if there are two or more splitChars then each one will be used individually to split the string. In other words: split  "1234567" "36" would return the following list: {12 45 7}.
lindex list index
    Returns the index'th item from the list. Note: lists start from 0, not 1, so the first item is at index 0, the second item is at index 1, and so on.
llength list
    Returns the number of elements in a list.

lsearch list pattern
    Searches list for an entry that matches pattern, and returns the index for the first match, or a -1 if there is no match. By default, lsearch uses "glob" patterns for matching. See the section on globbing.
lsort list
    Sorts list and returns a new list in the sorted order. By default, it sorts the list into alphabetic order. Note that this command returns the sorted list as a result, instead of sorting the list in place. If you have a list in a variable, the way to sort it is like so: set lst [lsort $lst]
lrange list first last
    Returns a list composed of the first through last entries in the list. If first is less than or equal to 0, it is treated as the first list element. If last is end or a value greater than the number of elements in the list, it is treated as the end. If first is greater than last then an empty list is returned.

posted @ 2010-12-04 23:39  greencolor  阅读(164)  评论(0编辑  收藏  举报