From 3e74cb14c8d06b27e45432924c5964b9b70e807e Mon Sep 17 00:00:00 2001 From: Jaidyn Lev Date: Sun, 9 Dec 2018 21:52:25 -0600 Subject: [PATCH] Added string operation 'last' and 'reverse' --- src/package.lisp | 3 +++ src/string/char.lisp | 11 +++++++++-- src/string/line.lisp | 3 +++ src/string/word.lisp | 3 +++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/package.lisp b/src/package.lisp index edafc94..3ed061d 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -60,6 +60,7 @@ :word-cdddar :word-cdar :word-cdaaar :word-cddddr :word-cdddr :word-cdaadr :word-cdadar :word-cddadr :word-cdaddr :word-cdadr :word-cddar :word-cddr :word-cddaar :word-cdaar + :word-last :word-reverse ;; STRING/LINE @@ -84,6 +85,7 @@ :line-cdddar :line-cdar :line-cdaaar :line-cddddr :line-cdddr :line-cdaadr :line-cdadar :line-cddadr :line-cdaddr :line-cdadr :line-cddar :line-cddr :line-cddaar :line-cdaar + :line-last :line-reverse ;; STRING/CHAR @@ -106,6 +108,7 @@ :char-cdddar :char-cdar :char-cdaaar :char-cddddr :char-cdddr :char-cdaadr :char-cdadar :char-cddadr :char-cdaddr :char-cdadr :char-cddar :char-cddr :char-cddaar :char-cdaar + :char-last :char-reverse ;; LIST diff --git a/src/string/char.lisp b/src/string/char.lisp index 1712d98..0629e5b 100644 --- a/src/string/char.lisp +++ b/src/string/char.lisp @@ -21,8 +21,12 @@ "Convert a list of chars into a string" (cond - ((eq (length char-list) 1) - (string (car char-list))) + ((eq 'STANDARD-CHAR (type-of char-list)) + (format nil "~A" char-list)) + + ((eq 1 (length char-list)) + (format nil "~A" (car char-list))) + ('T (reduce (lambda (char-a char-b) @@ -121,3 +125,6 @@ (create-string-manip char-cddr #'nih:char-list #'nih:char-string #'cddr) (create-string-manip char-cddaar #'nih:char-list #'nih:char-string #'cddaar) (create-string-manip char-cdaar #'nih:char-list #'nih:char-string #'cdaar) + +(create-string-manip char-last #'nih:char-list #'nih:char-string #'last) +(create-string-manip char-reverse #'nih:char-list #'nih:char-string #'reverse) diff --git a/src/string/line.lisp b/src/string/line.lisp index 4bb5fe1..ef174e1 100644 --- a/src/string/line.lisp +++ b/src/string/line.lisp @@ -117,3 +117,6 @@ (create-string-manip line-cddr #'nih:line-list #'nih:line-string #'cddr) (create-string-manip line-cddaar #'nih:line-list #'nih:line-string #'cddaar) (create-string-manip line-cdaar #'nih:line-list #'nih:line-string #'cdaar) + +(create-string-manip line-reverse #'nih:line-list #'nih:line-string #'reverse) +(create-string-manip line-last #'nih:line-list #'nih:line-string #'last) diff --git a/src/string/word.lisp b/src/string/word.lisp index 3d54d88..0a9d74e 100644 --- a/src/string/word.lisp +++ b/src/string/word.lisp @@ -116,3 +116,6 @@ (create-string-manip word-cddr #'nih:word-list #'nih:word-string #'cddr) (create-string-manip word-cddaar #'nih:word-list #'nih:word-string #'cddaar) (create-string-manip word-cdaar #'nih:word-list #'nih:word-string #'cdaar) + +(create-string-manip word-reverse #'nih:word-list #'nih:word-string #'reverse) +(create-string-manip word-last #'nih:word-list #'nih:word-string #'last)