Data update
This commit is contained in:
parent
72eb4943cb
commit
4d5544505c
2347 changed files with 62432 additions and 16731 deletions
|
|
@ -1,8 +1,11 @@
|
|||
set ary {}
|
||||
# empty list
|
||||
set arr {}
|
||||
|
||||
lappend ary 1
|
||||
lappend ary 3
|
||||
# 10 integers
|
||||
set arr [list 1 2 3 4 5 6 7 8 9 10 ]
|
||||
|
||||
lset ary 0 2
|
||||
|
||||
puts [lindex $ary 0]
|
||||
lappend arr 11
|
||||
lappend arr 12
|
||||
|
||||
puts stdout "$arr"
|
||||
|
|
|
|||
|
|
@ -1 +1,8 @@
|
|||
puts $ary; # Print the whole array
|
||||
set x [lindex $arr 4] ; # x <= 5
|
||||
|
||||
foreach n $arr {
|
||||
set idx [expr n -1]
|
||||
lset arr $idx [expr $n * $n]
|
||||
}
|
||||
|
||||
puts stdout "$arr"
|
||||
|
|
|
|||
2
Task/Arrays/Tcl/arrays-3.tcl
Normal file
2
Task/Arrays/Tcl/arrays-3.tcl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
set slice [lrange $arr 5 10]
|
||||
puts stdout "$slice"
|
||||
2
Task/Arrays/Tcl/arrays-4.tcl
Normal file
2
Task/Arrays/Tcl/arrays-4.tcl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
puts stdout "arr has [llength $arr] items."
|
||||
puts stdout "slice has [llength $slice] items."
|
||||
4
Task/Arrays/Tcl/arrays-5.tcl
Normal file
4
Task/Arrays/Tcl/arrays-5.tcl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
set r [lreverse $arr]
|
||||
set s [lsort -integer $r]
|
||||
puts stdout $r
|
||||
puts stdout $s
|
||||
10
Task/Arrays/Tcl/arrays-6.tcl
Normal file
10
Task/Arrays/Tcl/arrays-6.tcl
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
set term "calico"
|
||||
set fd [open "cats.txt" "r"]
|
||||
set contents [read $fd]
|
||||
set lines [split $contents "\n"]
|
||||
|
||||
foreach line $lines {
|
||||
if { [lsearch $line $term] > 0 } {
|
||||
puts "found $term in \"$line\""
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue