我有 2 个列表:
alist: [a b c d]
blist: [1 2 3 4]
(实际上它们是很长的列表)。如何一次性将 alist 中的变量分配给 blist 中的相应值?因此 a 变为 1,b 变为 2,依此类推。
我试过了:
foreach i alist j blist [i: j]
但它给出以下错误:
*** Script Error: j has no value
*** Where: foreach
*** Stack:
我也试过:
i: 1
while [true] [
if i > (length? alist) [break]
alist/i: blist/i
i: i + 1
]
但它也不起作用:
*** Script Error: cannot set none in path alist/i:
*** Where: set-path
*** Stack:
alist/i
并blist/i
返回none
(使用打印命令检查)。
其他语言也有类似的问题,例如:PHP 中的并行数组分配和Java 中的并行分配?. 谢谢你的帮助。