Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
7
Task/Catamorphism/Tcl/catamorphism-1.tcl
Normal file
7
Task/Catamorphism/Tcl/catamorphism-1.tcl
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
proc fold {lambda zero list} {
|
||||
set accumulator $zero
|
||||
foreach item $list {
|
||||
set accumulator [apply $lambda $accumulator $item]
|
||||
}
|
||||
return $accumulator
|
||||
}
|
||||
5
Task/Catamorphism/Tcl/catamorphism-2.tcl
Normal file
5
Task/Catamorphism/Tcl/catamorphism-2.tcl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
set 1to5 {1 2 3 4 5}
|
||||
|
||||
puts [fold {{a b} {expr {$a+$b}}} 0 $1to5]
|
||||
puts [fold {{a b} {expr {$a*$b}}} 1 $1to5]
|
||||
puts [fold {{a b} {return $a,$b}} x $1to5]
|
||||
3
Task/Catamorphism/Tcl/catamorphism-3.tcl
Normal file
3
Task/Catamorphism/Tcl/catamorphism-3.tcl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
puts [::tcl::mathop::+ {*}$1to5]
|
||||
puts [::tcl::mathop::* {*}$1to5]
|
||||
puts x,[join $1to5 ,]
|
||||
Loading…
Add table
Add a link
Reference in a new issue