实现了数组的拼接与显示,即将多个数组合并为一个数组,并能将数组的内容以格式化字符串的形式显示。
List1 := [1, 2, 3]
List2 := [4, 5, 6]
cList := Arr_concatenate(List1, List2)
MsgBox % Arr_disp(cList) ; [1, 2, 3, 4, 5, 6]
MsgBox % cList.MaxIndex()
MsgBox % ["apple","orange"].MaxIndex()
Arr_concatenate(p*) {
res := Object()
For each, obj in p
For each, value in obj
res.Insert(value)
return res
}
Arr_disp(arr) {
for each, value in arr
res .= ", " value
return "[" SubStr(res, 3) "]"
}
List1 := [1, 2, 3]
List2 := [4, 5, 6]
cList := Arr_concatenate(List1, List2)
MsgBox % Arr_disp(cList) ; [1, 2, 3, 4, 5, 6]
MsgBox % cList.MaxIndex()
MsgBox % ["apple","orange"].MaxIndex()
Arr_concatenate(p*) {
res := Object()
For each, obj in p
For each, value in obj
res.Insert(value)
return res
}
Arr_disp(arr) {
for each, value in arr
res .= ", " value
return "[" SubStr(res, 3) "]"
}
List1 := [1, 2, 3]
List2 := [4, 5, 6]
cList := Arr_concatenate(List1, List2)
MsgBox % Arr_disp(cList) ; [1, 2, 3, 4, 5, 6]
MsgBox % cList.MaxIndex()
MsgBox % ["apple","orange"].MaxIndex()
Arr_concatenate(p*) {
res := Object()
For each, obj in p
For each, value in obj
res.Insert(value)
return res
}
Arr_disp(arr) {
for each, value in arr
res .= ", " value
return "[" SubStr(res, 3) "]"
}
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)