Browse code

Added string operation 'last' and 'reverse'

Jaidyn Lev authored on 2018-12-10 03:52:25
Showing 4 changed files
... ...
@@ -60,6 +60,7 @@
60 60
     :word-cdddar :word-cdar :word-cdaaar :word-cddddr :word-cdddr
61 61
     :word-cdaadr :word-cdadar :word-cddadr :word-cdaddr :word-cdadr
62 62
     :word-cddar :word-cddr :word-cddaar :word-cdaar
63
+    :word-last :word-reverse
63 64
 
64 65
 
65 66
     ;; STRING/LINE
... ...
@@ -84,6 +85,7 @@
84 85
     :line-cdddar :line-cdar :line-cdaaar :line-cddddr :line-cdddr
85 86
     :line-cdaadr :line-cdadar :line-cddadr :line-cdaddr :line-cdadr
86 87
     :line-cddar :line-cddr :line-cddaar :line-cdaar
88
+    :line-last :line-reverse
87 89
 
88 90
 
89 91
     ;; STRING/CHAR
... ...
@@ -106,6 +108,7 @@
106 108
     :char-cdddar :char-cdar :char-cdaaar :char-cddddr :char-cdddr
107 109
     :char-cdaadr :char-cdadar :char-cddadr :char-cdaddr :char-cdadr
108 110
     :char-cddar :char-cddr :char-cddaar :char-cdaar
111
+    :char-last :char-reverse
109 112
 
110 113
 
111 114
     ;; LIST
... ...
@@ -21,8 +21,12 @@
21 21
   "Convert a list of chars into a string"
22 22
 
23 23
   (cond
24
-    ((eq (length char-list) 1)
25
-     (string (car char-list)))
24
+    ((eq 'STANDARD-CHAR (type-of char-list))
25
+     (format nil "~A" char-list))
26
+
27
+    ((eq 1 (length char-list))
28
+     (format nil "~A" (car char-list)))
29
+
26 30
     ('T
27 31
      (reduce
28 32
        (lambda (char-a char-b)
... ...
@@ -121,3 +125,6 @@
121 125
 (create-string-manip char-cddr #'nih:char-list #'nih:char-string #'cddr)
122 126
 (create-string-manip char-cddaar #'nih:char-list #'nih:char-string #'cddaar)
123 127
 (create-string-manip char-cdaar #'nih:char-list #'nih:char-string #'cdaar)
128
+
129
+(create-string-manip char-last #'nih:char-list #'nih:char-string #'last)
130
+(create-string-manip char-reverse #'nih:char-list #'nih:char-string #'reverse)
... ...
@@ -117,3 +117,6 @@
117 117
 (create-string-manip line-cddr #'nih:line-list #'nih:line-string #'cddr)
118 118
 (create-string-manip line-cddaar #'nih:line-list #'nih:line-string #'cddaar)
119 119
 (create-string-manip line-cdaar #'nih:line-list #'nih:line-string #'cdaar)
120
+
121
+(create-string-manip line-reverse #'nih:line-list #'nih:line-string #'reverse)
122
+(create-string-manip line-last #'nih:line-list #'nih:line-string #'last)
... ...
@@ -116,3 +116,6 @@
116 116
 (create-string-manip word-cddr #'nih:word-list #'nih:word-string #'cddr)
117 117
 (create-string-manip word-cddaar #'nih:word-list #'nih:word-string #'cddaar)
118 118
 (create-string-manip word-cdaar #'nih:word-list #'nih:word-string #'cdaar)
119
+
120
+(create-string-manip word-reverse #'nih:word-list #'nih:word-string #'reverse)
121
+(create-string-manip word-last #'nih:word-list #'nih:word-string #'last)