dd64c6912f70d9215ef616f253e29ce552b15df3
[lice.git] / src / fns.lisp
blobdd64c6912f70d9215ef616f253e29ce552b15df3
1 ;;; fns.lisp --- compatibility function from emacs
3 (in-package "LICE")
5 (defun concat (&rest strings)
6 "Concatenate all the arguments and make the result a string.
7 The result is a string whose elements are the elements of all the arguments.
8 Each argument must be a string."
9 (apply 'concatenate 'string strings))
11 (defun cdr-safe (object)
12 "Return the cdr of OBJECT if it is a cons cell, or else nil."
13 (when (consp object)
14 (cdr object)))
16 ;; XXX: get rid of this function and all callers
17 (defun assq (prop list)
18 "Return non-nil if key is `eq' to the car of an element of list.
19 The value is actually the first element of list whose car is key.
20 Elements of list that are not conses are ignored."
21 (assoc prop (remove-if 'listp list)))
23 (depricate substring subseq)
24 (defun substring (string from &optional (to (length string)))
25 "Return a substring of string, starting at index from and ending before to.
26 to may be nil or omitted; then the substring runs to the end of string.
27 from and to start at 0. If either is negative, it counts from the end.
29 This function allows vectors as well as strings."
30 (when (< from 0)
31 (setf from (max 0 (+ (length string) from))))
32 (when (< to 0)
33 (setf to (max 0 (+ (length string) to))))
34 (subseq string from to))
36 (depricate memq member)
37 (defun memq (elt list)
38 "Return non-nil if ELT is an element of LIST.
39 Comparison done with `eq'. The value is actually the tail of LIST
40 whose car is ELT."
41 (member elt list :test 'eq))