Last active
July 27, 2023 21:19
-
-
Save tluyben/ce5a0d9b949ab0dbbd47fb2743f0c24c to your computer and use it in GitHub Desktop.
unicode handling, basic string to list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun string-to-list (string) | |
(mapcar #'princ-to-string (coerce string 'list))) | |
;; (string-to-list "123πππ 456") | |
;; > ("1" "2" "3" "π" "π" "π " "4" "5" "6") | |
;; and | |
(defun list-to-string (list) | |
(let ((result "")) | |
(loop for x in list | |
do (setq result (concatenate 'string result x))) | |
result)) | |
;; CL-USER> (list-to-string (string-to-list "123πππ 456")) | |
;; "123πππ 456" | |
;; nicer; | |
(defun concat (x y) | |
(concatenate 'string x y)) | |
(defun list-to-string2 (list) | |
(reduce #'concat list)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment