-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.lisp
31 lines (23 loc) · 872 Bytes
/
list.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
;;;; list.lisp
(in-package #:convertify)
(defgeneric listify (arg)
(:documentation
"Turn LIST CHARACTER STRING SYMBOL NUMBER or ARRAY into a list.
A LIST returns itself.
A CHARACTER will return character in a list.
A STRING will return a list of character.
A SYMBOL will return a list of characters, unless symbol is made of numbers in which case it returns a list of numbers.
A NUMBER will return a list of the digits of the numbers.
An ARRAY will return a list of the array elements as list."))
(defmethod listify ((lst list))
lst)
(defmethod listify ((char character))
(list char))
(defmethod listify ((str string))
(coerce str 'list))
(defmethod listify ((sym symbol))
(listify (format nil "~A" sym)))
(defmethod listify ((num number))
(mapcar #'numberify (listify (format nil "~A" num))))
(defmethod listify ((arr array))
(coerce arr 'list))