文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>《TCL 教程英文版》 笔记§17 更多的LIST命令-l..

《TCL 教程英文版》 笔记§17 更多的LIST命令-l..

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

§17   更多的LIST命令-lsearch, lsort, lrange

 

lsearch list pattern

 

lsort list

 

lrange list first last

 

实例:

 

13  ch14  ch15  ch16  ch17  ch2  ch3  ch4  ch5  ch6  ch7  ch8  ch8-1  ch9

[root@localhost tcl]# cat ch17

# !/bin/bash

# \

exec tclsh "$0" "$@"

 

set list [list {Washington 1789} {Adams 1797} {Jefferson 1801} \

               {Madison 1809} {Monroe 1817} {Adams 1825} ]

 

set x [lsearch $list Washington*]

set y [lsearch $list Madison*]

incr x

incr y -1                        ;# Set range to be not-inclusive

 

set subsetlist [lrange $list $x $y]

 

puts "The following presidents served between Washington and Madison"

foreach item $subsetlist {

    puts "Starting in [lindex $item 1]: President [lindex $item 0] "

}

 

set x [lsearch $list Madison*]

 

set srtlist [lsort $list]

set y [lsearch $srtlist Madison*]

 

puts "\n$x Presidents came before Madison chronologically"

puts "$y Presidents came before Madison alphabetically"

 

执行结果:

 

# ./ch17

The following presidents served between Washington and Madison

Starting in 1797: President Adams

Starting in 1801: President Jefferson

 

3 Presidents came before Madison chronologically

3 Presidents came before Madison alphabetically

 

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

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载