gpt4 book ai didi

arrays - split-sequence- 用双空格分隔序列

转载 作者:太空宇宙 更新时间:2023-11-03 18:52:58 24 4
gpt4 key购买 nike

我知道如何用空格分隔字符串序列:

(defun ff-cols (dir file)
(with-open-file (ff-cols-str pathname :direction :input)
(length (split-sequence #\Space (read-line ff-cols-str nil 'eof)))))

但是如何用双空格分隔序列呢?通常平面文件有由双空格分隔的列。

(split-sequence "  " "1  2  3  4")

返回

("1  2  3  4") ;
10

此外,

(split-sequence #\Space "1  2  3  4")

返回

("1" "" "2" "" "3" "" "4") ;
10

最佳答案

试试这个:

(split-sequence-if (lambda (s) (equal s "  ")) "1  2  3  4")

或者这个:

(split-sequence #\Space "1  2  3  4" :remove-empty-subseqs t)

关于arrays - split-sequence- 用双空格分隔序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13643329/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com