文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>《TCL 教程英文版》 笔记 §16 添加删除LIST成员

《TCL 教程英文版》 笔记 §16 添加删除LIST成员

时间:2008-08-26  来源:oychw

§16   添加删除LIST成员

concat ?arg1 arg2 ... argn?

lappend listName ?arg1 arg2 ... argn?

linsert listName index arg1 ?arg2 ... argn?

lreplace listName first last ?arg1 ... argn?

lset varName index newValue

 

 

实例:

 

# cat ch16

# !/bin/bash

# \

exec tclsh "$0" "$@"

 

set b [list a b {c d e} {f {g h}}]

puts "Treated as a list: $b\n"

 

set b [split "a b {c d e} {f {g h}}"]

puts "Transformed by split: $b\n"

 

set a [concat a b {c d e} {f {g h}}]

puts "Concated: $a\n"

 

lappend a {ij K lm}                        ;# Note: {ij K lm} is a single element

puts "After lappending: $a\n"

 

set b [linsert $a 3 "1 2 3"]               ;# "1 2 3" is a single element

puts "After linsert at position 3: $b\n"

 

set b [lreplace $b 3 5 "AA" "BB"]

puts "After lreplacing 3 positions with 2 values at position 3: $b\n"

 

执行结果:

 

# ./ch16 

Treated as a list: a b {c d e} {f {g h}}

 

Transformed by split: a b \{c d e\} \{f \{g h\}\}

 

Concated: a b c d e f {g h}

 

After lappending: a b c d e f {g h} {ij K lm}

 

After linsert at position 3: a b c {1 2 3} d e f {g h} {ij K lm}

 

After lreplacing 3 positions with 2 values at position 3: a b c AA BB f {g h} {ij K lm}

 

相关阅读 更多 +
排行榜 更多 +
无敌流浪汉3手机版下载

无敌流浪汉3手机版下载

飞行射击 下载
龙珠巅峰对决手游下载

龙珠巅峰对决手游下载

飞行射击 下载
杀戮尖塔mod手机版下载

杀戮尖塔mod手机版下载

棋牌卡牌 下载