You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
proc pipe* args {
|
|
|
|
set r [uplevel 1 [lindex $args 0]]
|
|
|
|
for {set i 1} {$i < [llength $args]} {incr i} {
|
|
|
|
set e [lindex $args $i]
|
|
|
|
if {[llength $e] == 1} {
|
|
|
|
if {$e eq {>}} {
|
|
|
|
incr i
|
|
|
|
uplevel 1 [list set [lindex $args $i] $r]
|
|
|
|
} else {
|
|
|
|
set r [uplevel 1 [list $e $r]]
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
set cmd {}
|
|
|
|
set substdone 0
|
|
|
|
foreach arg $e {
|
|
|
|
if {$arg eq {*}} {
|
|
|
|
lappend cmd $r
|
|
|
|
set substdone 1
|
|
|
|
} else {
|
|
|
|
lappend cmd $arg
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if {$substdone == 0} {
|
|
|
|
lappend cmd $r
|
|
|
|
}
|
|
|
|
set r [uplevel 1 $cmd]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $r
|
|
|
|
}
|
|
|
|
|
|
|
|
set s " supercalifragilisticexpialidocious "
|
|
|
|
#set s " supercalifragilistichespiralitoso "
|
|
|
|
pipe* {string trim $s} {split * {}} {lsort -unique} {join * {}} > s \
|
|
|
|
{string length} > l
|
|
|
|
puts $s
|
|
|
|
puts $l
|
|
|
|
|
|
|
|
#test running of patternmatching pipelines within pipe*
|
|
|
|
set x [list a b blah etc]
|
|
|
|
pipe* {set x} {,'a'@0/0= |@0> {puts $data; set data} <| *} {val *}
|
|
|
|
|
|
|
|
pipe* {set x} {,'a'@0/0= |@0> {
|
|
|
|
puts $data
|
|
|
|
set data
|
|
|
|
} <| *} {val *}
|
|
|
|
|
|
|
|
|
|
|
|
|