Tcl 中是否有速记来获取数字的顺序数组? [英] Is there shorthand in Tcl to get a sequential array of numbers?

查看:24
本文介绍了Tcl 中是否有速记来获取数字的顺序数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,在 Perl 中,要获得从 1 到 10 的连续数字数组,您可以简单地执行以下操作:

For example, in Perl, to get a sequential array of numbers from 1 to 10, you could simply do:

@myArray = (1 .. 10);

这两个句点用作此操作的简写,而不是进行 for 循环或手动写出整个内容.我用过的其他语言也有类似的东西.

The two periods serve as shorthand for this operations instead of making a for loop or writing the whole thing out manually. Other languages I've used have something similar also.

Tcl 中是否存在类似的速记?

Does a similar shorthand exist in Tcl?

推荐答案

不是这个,而是

% package require struct::list
1.6.1
% struct::list iota 10
0 1 2 3 4 5 6 7 8 9

同时在this中搜索iota"关键字,看看如何使用一个-班轮.

Also search this for the "iota" keyword to see how this can be done using a one-liner.

这篇关于Tcl 中是否有速记来获取数字的顺序数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆