tcl:lsort
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédente | |||
tcl:lsort [2024/05/12 15:54] – [Exemples] crazycat | tcl:lsort [2025/03/10 14:11] (Version actuelle) – crazycat | ||
---|---|---|---|
Ligne 36: | Ligne 36: | ||
puts [lshuffle $abc] | puts [lshuffle $abc] | ||
# p g l x c b r y h o t j z d q w s k a v i f n u m e</ | # p g l x c b r y h o t j z d q w s k a v i f n u m e</ | ||
+ | |||
+ | Un autre exemple utilisant **-index**: | ||
+ | |||
+ | <code tcl># list of users: nick, words, lines | ||
+ | set random { | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | proc order {ulist {type "" | ||
+ | | ||
+ | words { set idx 1; set opt " | ||
+ | lines { set idx 2; set opt " | ||
+ | default { set idx 0; set opt " | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | |||
+ | puts "order by names" | ||
+ | foreach l [order $random] { | ||
+ | puts " | ||
+ | } | ||
+ | |||
+ | puts "order by words" | ||
+ | foreach l [order $random words] { | ||
+ | puts " | ||
+ | } | ||
+ | |||
+ | puts "order by lines" | ||
+ | foreach l [order $random lines] { | ||
+ | puts " | ||
+ | }</ | ||
===== Voir aussi ===== | ===== Voir aussi ===== | ||
[[: | [[: | ||
{{tag> | {{tag> | ||
tcl/lsort.txt · Dernière modification : 2025/03/10 14:11 de crazycat