fork download
  1. (defun splitStr (str)
  2. "Appends characters from str to my-string unless the character is a space. When a space is encountered, add the current my-string to a new list."
  3. (setq my-string "") ;; Initialize my-string as an empty global string
  4. (setq result-list '()) ;; Initialize an empty list to store parts of the string
  5. (setq len (length str)) ;; Get the length of the input string
  6.  
  7. (dotimes (i len)
  8. (setq curr-char (char str i)) ;; Get the character at index `i`
  9. (if (char/= #\Space curr-char) ;; If the character is not a space
  10. (setq my-string (concatenate 'string my-string (string curr-char))) ;; Append character to my-string
  11. (when (> (length my-string) 0) ;; If my-string is not empty
  12. (push my-string result-list) ;; Add my-string to result-list
  13. (setq my-string "")))) ;; Reset my-string to empty string
  14.  
  15. ;; After the loop, add the final my-string if it's not empty
  16. (when (> (length my-string) 0)
  17. (push my-string result-list))
  18.  
  19. (nreverse result-list)) ;; Return the reversed list to maintain original order
  20.  
  21. ;; Example usage
  22. (princ (splitStr "I feel joy")) ;; Output: ("I" "feel" "joy")
  23.  
Success #stdin #stdout #stderr 0.02s 9588KB
stdin
Standard input is empty
stdout
(I feel joy)
stderr
Warning: reserving address range 0x80000c0000...0x1fffffffffff that contains memory mappings. clisp might crash later!
Memory dump:
  0x8000000000 - 0x80000bffff
  0x14e827000000 - 0x14e8272e4fff
  0x14e827415000 - 0x14e827439fff
  0x14e82743a000 - 0x14e8275acfff
  0x14e8275ad000 - 0x14e8275f5fff
  0x14e8275f6000 - 0x14e8275f8fff
  0x14e8275f9000 - 0x14e8275fbfff
  0x14e8275fc000 - 0x14e8275fffff
  0x14e827600000 - 0x14e827602fff
  0x14e827603000 - 0x14e827801fff
  0x14e827802000 - 0x14e827802fff
  0x14e827803000 - 0x14e827803fff
  0x14e827880000 - 0x14e82788ffff
  0x14e827890000 - 0x14e8278c3fff
  0x14e8278c4000 - 0x14e8279fafff
  0x14e8279fb000 - 0x14e8279fbfff
  0x14e8279fc000 - 0x14e8279fefff
  0x14e8279ff000 - 0x14e8279fffff
  0x14e827a00000 - 0x14e827a03fff
  0x14e827a04000 - 0x14e827c03fff
  0x14e827c04000 - 0x14e827c04fff
  0x14e827c05000 - 0x14e827c05fff
  0x14e827cf3000 - 0x14e827cf6fff
  0x14e827cf7000 - 0x14e827cf7fff
  0x14e827cf8000 - 0x14e827cf9fff
  0x14e827cfa000 - 0x14e827cfafff
  0x14e827cfb000 - 0x14e827cfbfff
  0x14e827cfc000 - 0x14e827cfcfff
  0x14e827cfd000 - 0x14e827d0afff
  0x14e827d0b000 - 0x14e827d18fff
  0x14e827d19000 - 0x14e827d25fff
  0x14e827d26000 - 0x14e827d29fff
  0x14e827d2a000 - 0x14e827d2afff
  0x14e827d2b000 - 0x14e827d2bfff
  0x14e827d2c000 - 0x14e827d31fff
  0x14e827d32000 - 0x14e827d33fff
  0x14e827d34000 - 0x14e827d34fff
  0x14e827d35000 - 0x14e827d35fff
  0x14e827d36000 - 0x14e827d36fff
  0x14e827d37000 - 0x14e827d64fff
  0x14e827d65000 - 0x14e827d73fff
  0x14e827d74000 - 0x14e827e19fff
  0x14e827e1a000 - 0x14e827eb0fff
  0x14e827eb1000 - 0x14e827eb1fff
  0x14e827eb2000 - 0x14e827eb2fff
  0x14e827eb3000 - 0x14e827ec6fff
  0x14e827ec7000 - 0x14e827eeefff
  0x14e827eef000 - 0x14e827ef8fff
  0x14e827ef9000 - 0x14e827efafff
  0x14e827efb000 - 0x14e827f00fff
  0x14e827f01000 - 0x14e827f03fff
  0x14e827f06000 - 0x14e827f06fff
  0x14e827f07000 - 0x14e827f07fff
  0x14e827f08000 - 0x14e827f08fff
  0x14e827f09000 - 0x14e827f09fff
  0x14e827f0a000 - 0x14e827f0afff
  0x14e827f0b000 - 0x14e827f11fff
  0x14e827f12000 - 0x14e827f14fff
  0x14e827f15000 - 0x14e827f15fff
  0x14e827f16000 - 0x14e827f36fff
  0x14e827f37000 - 0x14e827f3efff
  0x14e827f3f000 - 0x14e827f3ffff
  0x14e827f40000 - 0x14e827f40fff
  0x14e827f41000 - 0x14e827f41fff
  0x55c78e6ed000 - 0x55c78e7ddfff
  0x55c78e7de000 - 0x55c78e8e7fff
  0x55c78e8e8000 - 0x55c78e947fff
  0x55c78e949000 - 0x55c78e977fff
  0x55c78e978000 - 0x55c78e9a8fff
  0x55c78e9a9000 - 0x55c78e9acfff
  0x55c78eb73000 - 0x55c78eb93fff
  0x7fff7cde5000 - 0x7fff7ce05fff
  0x7fff7cf96000 - 0x7fff7cf99fff
  0x7fff7cf9a000 - 0x7fff7cf9bfff