Skip to content

Commit

Permalink
Added quotation argument. If this argument is specified, the element …
Browse files Browse the repository at this point in the history
…will be quoted and concatenated if the element already contains a pause argument.
  • Loading branch information
manualChair committed Feb 22, 2020
1 parent 1aa7b0b commit 480f3e8
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions strings/unword.LSP
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
;;;
;;;pause : string, list, symbol, variant(string or safe-array), safe-array(integer)
;;;
;;;quotation : string, list, symbol, variant(string or safe-array), safe-array(integer)
;;;
;;;retrun : string or list etc.

;;; +------------------------------------------------------+
Expand All @@ -17,47 +19,54 @@
;;; https://opensource.org/licenses/mit-license.php
;;; +------------------------------------------------------+

;;;_$ (unword 'STR '("A" "B" "C") ":")
;;;_$ (unword 'STR '("A" "B" "C") ":" nil)
;;;"A:B:C"
;;;_$ (unword 'SLIST '("A" "B" "C") ":")
;;;_$ (unword 'SLIST '("A" "B" "C") ":" nil)
;;;(65 58 66 58 67)
;;;_$ (unword 'STR nil ":")
;;;""
;;;_$ (unword 'SLIST nil ":")
;;;_$ (unword 'SLIST nil ":" nil)
;;;nil
;;;_$ (unword 'STR '((65) (66) (67)) '(58))
;;;"A:B:C"
;;;_$ (unword 'STR '(A B C) ":")
;;;_$ (unword 'STR nil ":" nil)
;;;""
;;;_$ (unword 'STR '((65) (66) (67)) '(58) nil)
;;;"A:B:C"
;;;_$ (unword 'SYM '(A B C) ":")
;;;A:B:C
;;;_$ (unword 'VARIANT '("A" "B" "C") ":")
;;;_$ (unword 'STR '("A" "B:2:3" "C") ":" "\"")
;;;"A:\"B:2:3\":C"
;;;_$ (unword 'VARIANT '("A" "B" "C") ":" nil)
;;;#<variant 8 A:B:C>
;;;_$ (unword 'SAFEARRAY '("A" "B" "C") ":")
;;;#<safearray...>

(include 'member-of-option-p "./common/member-of-option-p")
(include 'coerce "./types/coerce")
(include 'endp "./conses/endp")
(include 'characterp "./characters/characterp")
(include 'char-equal "./characters/char-equal")
(include 'stringp "./strings/stringp")
(include 'concatenate "./sequences/concatenate")
(include 'to-variantp-string "./strings/_to-variantp-string")
(include 'search "./sequences/search")
(include 'concatenate "./sequences/concatenate")
(include 'affix "./sequences/affix")

(defun unword:quote (sequence)
(if (and quotation (search pause sequence 'char-equal nil nil nil))
(affix sequence quotation 'BOTH)
sequence
)
)

(defun unword:sub (slist)
(if (and (not (endp slist)) (cdr slist))
(cons (car slist) (cons pause (unword:sub (cdr slist))))
slist
(if (and slist (cdr slist))
(cons (unword:quote (car slist)) (cons pause (unword:sub (cdr slist))))
(list (apply 'unword:quote slist))
)
)

(defun unword (atype list-string pause)
(defun unword (atype list-string pause quotation)
(if (and (member-of-option-p
'unword
'atype
'(STR SLIST SYM VARIANT SAFEARRAY VECTOR)
)
(vl-every 'stringp list-string)
(stringp pause)
(stringp quotation)
)
(if (not (endp list-string))
(coerce (to-variantp-string
Expand Down

0 comments on commit 480f3e8

Please sign in to comment.