【发布时间】:2015-02-18 13:28:49
【问题描述】:
我想创建一个列表,其中包含适用于某些 csh 中的条件。
如何在不预先确定的情况下以动态方式添加到列表或数组中 列表或数组的大小?
c shell中有list.add之类的吗?
谢谢
【问题讨论】:
我想创建一个列表,其中包含适用于某些 csh 中的条件。
如何在不预先确定的情况下以动态方式添加到列表或数组中 列表或数组的大小?
c shell中有list.add之类的吗?
谢谢
【问题讨论】:
您可以只使用set my_list = ( $my_list more ) 的形式。例如:
# Create original list
% set my_list = ( hello world )
% echo $my_list
hello world
# Append to the list
% set my_list = ( $my_list hey there )
% echo $my_list
hello world hey there
# Loop over the list to verify it does what we expect it to do
% foreach item ($my_list)
foreach? echo "-> $item"
foreach? end
-> hello
-> world
-> hey
-> there
【讨论】: