new files
This commit is contained in:
parent
3af7344581
commit
86c034bb8b
1364 changed files with 21352 additions and 0 deletions
36
Task/Binary-strings/Tcl/binary-strings.tcl
Normal file
36
Task/Binary-strings/Tcl/binary-strings.tcl
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
# string creation
|
||||
set x "hello world"
|
||||
|
||||
# string destruction
|
||||
unset x
|
||||
|
||||
# string assignment with a null byte
|
||||
set x a\0b
|
||||
string length $x ;# ==> 3
|
||||
|
||||
# string comparison
|
||||
if {$x eq "hello"} {puts equal} else {puts "not equal"}
|
||||
set y bc
|
||||
if {$x < $y} {puts "$x is lexicographically less than $y"}
|
||||
|
||||
# string copying; cloning happens automatically behind the scenes
|
||||
set xx $x
|
||||
|
||||
# check if empty
|
||||
if {$x eq ""} {puts "is empty"}
|
||||
if {[string length $x] == 0} {puts "is empty"}
|
||||
|
||||
# append a byte
|
||||
append x \07
|
||||
|
||||
# substring
|
||||
set xx [string range $x 0 end-1]
|
||||
|
||||
# replace bytes
|
||||
set y [string map {l L} "hello world"]
|
||||
|
||||
# join strings
|
||||
set a "hel"
|
||||
set b "lo w"
|
||||
set c "orld"
|
||||
set d $a$b$c
|
||||
Loading…
Add table
Add a link
Reference in a new issue