Comment detail

アレイのuniq (Nested Flatten)
特にこれが一般的な Tcl 風スタイルというわけではありませんが tcllib の struct::list を使うと fold もできますという例です。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
package require struct::list

proc lappend_uniq {l e} {
  if {[lsearch $l $e] == -1} {lappend l $e}
  set l
}

proc uniq {l} {
  ::struct::list fold $l {} lappend_uniq
}

# % uniq {3 1 4 1 5 9 2 6 5 3 5 8 9 7 9}
# 3 1 4 5 9 2 6 8 7

Index

Feed

Other

Link

Pathtraq

loading...