https://www.cnblogs.com/yeungchie/
发现有自带函数实现这个功能了
member
,需要计数再用这个新轮子。。
- code
procedure(ycInListp(scan keylist)
prog((times)
times = 0
foreach(key keylist
if(scan == key then
times++
)
)
if(times > 0 then
return(times)
else
return(nil)
)
)
)
-
describe
扫描keylist中是否含有scan并计数,有则返回计数,否则返回nil。 -
example
ycInListp(1 list(1 2 3 2 1 2 1))
=>2
ycInListp(1 list(2 3 2 2))
=>nil