首页 > 其他 > 详细

Skill扫描list中是否含有某元素

时间:2020-05-05 16:30:22      阅读:118      评论:0      收藏:0      [点我收藏+]
  • code
unless(fboundp(‘InListp)
    procedure(InListp(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

InListp(1 list(1 2 3 2 1 2 1))
=>2
InListp(1 list(2 3 2 2))
=>nil

Skill扫描list中是否含有某元素

原文:https://www.cnblogs.com/yeungchie/p/12830408.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!