【问题标题】:Operation on `nil` in emacs lisp在 emacs lisp 中对 `nil` 的操作
【发布时间】:2012-12-28 18:09:13
【问题描述】:

这样的表达会导致错误

(= nil 3)


Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
=(nil .......

那么有没有一种简单的方法(例如,另一个名为 my-eq 的函数)让这个表达式返回 nil(表示 False),如下所示:

(my-eq nil 3)
=> nil

【问题讨论】:

    标签: emacs lisp elisp


    【解决方案1】:

    那是eqequal

    (当量 3 无)

    => 无

    (eq OBJ1 OBJ2)
    
    Return t if the two args are the same Lisp object.
    
    (equal O1 O2)
    
    Return t if two Lisp objects have similar structure and contents.
    They must have the same data type.
    Conses are compared by comparing the cars and the cdrs.
    Vectors and strings are compared element by element.
    Numbers are compared by value, but integers cannot equal floats.
     (Use `=' if you want integers and floats to be able to be equal.)
    Symbols must match exactly.
    

    【讨论】:

    • 还有null谓词; (null nil) => t
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-07
    相关资源
    最近更新 更多