Less Than
There are many elisp functions for comparisons. The "less than" sign
< is a mathematical sign to compare inequality. Elisp has the
function < to compare Number or Marker.
(< 1 2) t (< 2 1) nil
It is obvious enough that no explanation is needed.
String Less Than
Elisp also has a "less than" function for Strings, called string-lessp.
(string-lessp "abc" "def") t (string-lessp "abc" "ab") nil
It is a predicate function, meaning that it returns t if the first
string, "abc" in the first example, is less than the second strings
"def", or nil otherwise.
Elisp have a convention, as noted in elisp info, to end a predicate
function with letter "p". Thus, following this convention,
string-lessp ends with "p".
Elisp does have string< as an alias for string-lessp. So that you
can write the above example:
(string< "abc" "def") t (string< "abc" "ab") nil
"<" vs "p" vs "-p"
It seems like a majority of "less than" functions follow this "lessp"
convention, however, there are other functions in Emacs. Here is an
incomplete list of "less than" functions I have got from my Emacs with
M-x apropos <$\|lessp$\|less-p$.
What functions do you have in your Emacs?
Incomplete List of "less than" functions
<<<bibtex-lesspbyte-string<coding-system-lesspcustomize-version-lesspelmo-time-less-pelmo-time<file-attributes-lesspgnus-pseudos<gnus-string<ido-file-extension-lesspido-file-lesspmailcap-viewer-lessporg-entries-lessporg-table-formula-less-porg-time<recentf-string-lessps-less-pskk-string-lessp-in-coding-systemskk-string<string-lesspstring<time-less-pversion-list-<version<
No comments :
Post a Comment