Memoize |
BasicWerk
EC Support
Technique
Facebook
|
20140908144850_Common_Lisp_split_loop_across |
Common_Lisp_split_loop_across
* (ql:quickload 'cl-ppcre) * (defvar str "ashfkf dssaljdl jd") ;; 1文字の「文字列」のリスト * (split "" str) ("a" "s" "h" "f" "k" "f" " " "d" "s" "s" "a" "l" "j" "d" "l" " " "j" "d") ;; ↑ スペースも載ってくる ;; スペースは除外 * (split "\\s*" str) ("a" "s" "h" "f" "k" "f" "d" "s" "s" "a" "l" "j" "d" "l" "j" "d") ;; スターをプラスにすると単にスペースが入る位置で分割 * (split "\\s+" str) ("ashfkf" "dssaljdl" "jd") ;; Char に分割するには loop ~ across が手っ取り早い * (loop for c across str collect c) (#\a #\s #\h #\f #\k #\f #\ #\d #\s #\s #\a #\l #\j #\d #\l #\ #\j #\d)
http://weitz.de/cl-ppcre/#split
|
© Shin Nakamura/BasicWerk 2014 |