[ Skill ] 返回list中的倒数第二个数据

https://www.cnblogs.com/yeungchie/

  • code
procedure(ycLast2(list "l")
    prog((index ouput)
        index = length(list) - 1
        ouput = nth(index - 1 list)
        return(ouput)
    )
)
  • describe
    RT,返回倒数第二个数据,省事。

  • extend
    返回第一个:car(list)
    返回第二个:cadr(list)
    返回倒数第一个:car(last(list))

  • example

ycLast2(list(1 2 3 4))
=>3
ycLast2(1234)
=>*WARNING* 
原文地址:https://www.cnblogs.com/yeungchie/p/12861318.html