PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.27.5
Code Block Pro – Beautiful Syntax Highlighting v1.27.5
1.27.1 1.27.2 1.27.3 1.27.4 1.27.5 1.27.6 1.27.7 1.28.0 1.3.0 1.4.0 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.8.0 1.9.0 1.9.1 1.9.2 1.9.3 trunk 1.1.0 1.10.0 1.11.0 1.11.1 All 63 releases
code-block-pro / build / shiki / samples / tcl.sample

tcl.sample in Code Block Pro – Beautiful Syntax Highlighting 1.27.5, at build/shiki/samples/tcl.sample

52 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 proc set'contains {set el} {expr {[lsearch -exact $set $el]>=0}}
2
3 e.g. {set'contains {A B C} A} -> 1
4 e.g. {set'contains {A B C} D} -> 0
5
6 proc set'add {_set args} {
7 upvar 1 $_set set
8 foreach el $args {
9 if {![set'contains $set $el]} {lappend set $el}
10 }
11 set set
12 }
13
14 set example {1 2 3}
15 e.g. {set'add example 4} -> {1 2 3 4}
16 e.g. {set'add example 4} -> {1 2 3 4}
17
18 proc set'remove {_set args} {
19 upvar 1 $_set set
20 foreach el $args {
21 set pos [lsearch -exact $set $el]
22 set set [lreplace $set $pos $pos]
23 }
24 set set
25 }
26
27 e.g. {set'remove example 3} -> {1 2 4}
28
29 proc set'intersection {a b} {
30 foreach el $a {set arr($el) ""}
31 set res {}
32 foreach el $b {if {[info exists arr($el)]} {lappend res $el}}
33 set res
34
35 e.g. {set'intersection {1 2 3 4} {2 4 6 8}} -> {2 4}
36
37 proc set'union {a b} {
38 foreach el $a {set arr($el) ""}
39 foreach el $b {set arr($el) ""}
40 lsort [array names arr]
41 }
42
43 e.g. {set'union {1 3 5 7} {2 4 6 8}} -> {1 2 3 4 5 6 7 8}
44
45 proc set'difference {a b} {
46 eval set'remove a $b
47 }
48
49 e.g. {set'difference {1 2 3 4 5} {2 4 6}} -> {1 3 5}
50
51 # https://en.wikibooks.org/wiki/Tcl_Programming/Examples
52