Posted to tcl by daedra at Wed Jul 20 16:01:43 GMT 2011view raw
- set fruits {a b c}
- proc expandAbbrevFruit {frt} {switch $frt {a {return "Apples"} b {return "Bananas"} c {return "Coconuts"}}
- proc map2List {mapfn map} {set tmp {} foreach el $map { lappend tmp [$mapfn $el] } return $tmp }
- puts "fruit is one of: $fruits ([map2List expandAbbrevFruit $fruits], respectively)"
Comments
Posted by aku at Wed Jul 20 16:09:16 GMT 2011 [text] [code]
set fruits {a b c} proc expandAbbrevFruit {frt} {switch $frt {a {return "Apples"} b {return "Bananas"} c {return "Coconuts"}}} proc map2List {mapfn map} {set tmp {} ; foreach el $map { lappend tmp [$mapfn $el] } ; return $tmp } puts "fruit is one of: $fruits ([map2List expandAbbrevFruit $fruits], respectively)"
Posted by aku at Wed Jul 20 16:09:56 GMT 2011 [text] [code]
Meh, stupid thing runs the comment into a single line :(