Subject: Re: trig functions in tk - DN [1]
"Richard.Suchenwirth" <Richard.Suchenwirth@kst.siemens.de> - 09 Aug 1999 - comp.lang.tcl
Cameron Laird wrote:
>> Here's an example usage:
> set result [expr sin(0.1)]
> Give [expr] a chance at all your arithmetic calcu-
> lations. You'll do fine.
>
After I saw a similar query on "int not working", I devoted this
weekend's fun project to the philosophy of Tcl commands and expr
functions. Out came this cute exporter, that makes some or all expr
built-in functions available as Tcl procs:
proc expr:import {args} {
set names {
abs acos asin atan atan2 ceil cos cosh double exp floor fmod
hypot int log log10 pow rand round sin sinh sqrt srand tan
tanh
}
switch -- $args {
"*" - all {set args $names}
names {return [join $names]}
}
foreach name $args {
if {[lsearch $names $name]<0} {
error "$name is not one of $names"
}
proc $name args [list eval expr ${name}(\[join \$args ,\])]
}
}
So, if you want sin and cos available as Tcl command, just say
expr:import sin cos
and have them. Detailed discussion:
http://mini.net/cgi-bin/wikit/541.html
--
Schoene Gruesse/best regards, Richard Suchenwirth - +49-7531-86 2703
RC DT2, Siemens Electrocom, Buecklestr. 1-5, D-78467 Konstanz,Germany
-------------- http://purl.org/thecliff/tcl/wiki//Richard*Suchenwirth
Last modified
1999-09-27
1999-09-27
(195.108.246.50)
Note: you are looking at
the snapshot of an old wiki
- much of this information
is likely to be very outdated
