如果元素在列表中,如何测试?

Joh*_*ood 0 rexx

如果给定元素在Rexx的列表中,是否有内置函数可以测试?

我找不到一个.另一种方法是循环遍历列表并手动检查每个元素.

Bru*_*tin 5

不(除非事情发生变化); 只是遍历列表.

替代方案是/也有查找变量

lookup. = 0  /* not all versions of Rexx support 
                default initialisation like this */

      ....

addToList:
parse arg item
    numberInList = numberInList + 1
    list.numberInList = item
    lookup.item = 1
return
Run Code Online (Sandbox Code Playgroud)

然后,您可以检查项目是否在列表中

if lookup.item = 1 then do
    ......
Run Code Online (Sandbox Code Playgroud)