Re: is possible to have a proc within a proc?
- From: miguel <msofer@xxxxxxxxxxxx>
- Date: Thu, 29 May 2008 17:16:35 -0300
ZB wrote:
Dnia 29.05.2008 chedderslam <chedderslam@xxxxxxxxx> napisał/a:
Thank you.I am working on a proc which calls itself recursively. Is it possiblePascal will do this. Tcl will not.
for a proc to have a proc within itself? I am trying to group the
code together.
Mike
Actually you can nest a function using "apply" - a very simplistic example:
proc makeSomething { x y } {
puts "$x | $y"
apply {{x y} {expr $x*$y}} $x $y
}
tclsh8.5 [~]makeSomething 3 4
3 | 4
12
Even better (or rather, closer to what I guess the original poster wants):
% proc makeSomething { x y } {
puts "$x | $y"
set p [list ::apply {{x y} {expr $x*$y}}]
puts [{*}$p $x $y]
puts [{*}$p $x [incr y]]
}
% makeSomething 3 4
3 | 4
12
15
.
- References:
- Re: is possible to have a proc within a proc?
- From: chedderslam
- Re: is possible to have a proc within a proc?
- From: ZB
- Re: is possible to have a proc within a proc?
- Prev by Date: Re: is possible to have a proc within a proc?
- Next by Date: Re: is possible to have a proc within a proc?
- Previous by thread: Re: is possible to have a proc within a proc?
- Next by thread: dtp.kit
- Index(es):
Relevant Pages
|