tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
|
|
@ -0,0 +1,9 @@
|
|||
package require Tcl 8.6
|
||||
proc partial {f1 f2} {
|
||||
variable ctr
|
||||
coroutine __curry[incr ctr] apply {{f1 f2} {
|
||||
for {set x [info coroutine]} 1 {} {
|
||||
set x [{*}$f1 $f2 [yield $x]]
|
||||
}
|
||||
}} $f1 $f2
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
proc fs {f s} {
|
||||
set r {}
|
||||
foreach n $s {
|
||||
lappend r [{*}$f $n]
|
||||
}
|
||||
return $r
|
||||
}
|
||||
proc f1 x {expr {$x * 2}}
|
||||
proc f2 x {expr {$x ** 2}}
|
||||
set fsf1 [partial fs f1]
|
||||
set fsf2 [partial fs f2]
|
||||
foreach s {{0 1 2 3} {2 4 6 8}} {
|
||||
puts "$s ==f1==> [$fsf1 $s]"
|
||||
puts "$s ==f2==> [$fsf2 $s]"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue