文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>《TCL 教程英文版》 笔记 §15 TCL数据结构101-LIST

《TCL 教程英文版》 笔记 §15 TCL数据结构101-LIST

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

§15   TCL数据结构101-LIST

       创建LIST的方法:

              set lst {{item 1} {item 2} {item 3}}

              set lst [split "item 1.item 2.item 3" "."]

              set lst [list "item 1" "item 2" "item 3"]

可以使用如下方法访问:

       foreach varname list body

 

实例

# cat ch15

# !/bin/bash

# \

exec tclsh "$0" "$@"

 

set x "a b c"

puts "Item at index 2 of the list {$x} is: [lindex $x 2]\n"

 

set y [split 7/4/1776 "/"]

puts "We celebrate on the [lindex $y 1]'th day of the [lindex $y 0]'th month\n"

 

set z [list puts "arg 2 is $y" ]

puts "A command resembles: $z\n"

 

set i 0

foreach j $x {

    puts "$j is item number $i in list x"

    incr i

}

 

执行结果:

# ./ch15

Item at index 2 of the list {a b c} is: c

 

We celebrate on the 4'th day of the 7'th month

 

A command resembles: puts {arg 2 is 7 4 1776}

 

a is item number 0 in list x

b is item number 1 in list x

c is item number 2 in list x

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载