TABLE OF CONTENTS
::pwtk::seq
SYNOPSIS
proc ::pwtk::seq {args} {
DESCRIPTION
Analogous to Unix seq command. It returns a range of numbers.
USAGE
::pwtk::seq last ::pwtk::seq first last ::pwtk::seq first increment last
SOURCE
set nargs [llength $args] if { $nargs < 1 || $nargs > 3 } { pwtk::error "wrong # args: must be one of\n seq last\n seq first last\n seq first increment last\n\nbut got [concat seq $args]" 1 } set first 1 set increment 1 set last [lindex $args end] if { $nargs >= 2 } { set first [lindex $args 0] if { $nargs == 3 } { set increment [lindex $args 1] } } if { $increment == 0 } { pwtk::warning "invalid zero increment value; setting increment to 1" set increment 1 } set len [seq_flen_ $first $increment] set result {} while { [expr {$increment > 0 ? $first <= $last : $first >= $last}] } { if { $len == 0 } { lappend result $first } else { lappend result [format %.${len}f $first] } set first [format %.${len}f [expr $first + $increment]] } return $result }