- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
如何在 Nyquist(与 xlisp 非常相似)中从字符串中删除某个字符并返回结果?
我想计算像“ABBAAAABBBBAABAAAB”这样的字符串中有多少个“A”。 (是的,字符串中只有 'A' 和 'B'。)
因为 Nyquist 中没有(计数)函数,所以我尝试了类似的方法
(length (remove #\B mystring))
或
(length (remove #\B mystring :test equal))
但它不起作用。
暂时忘记了字符数,如何从字符串中删除“B”?
最佳答案
字符串中是否总是只有 A
和 B
?如果没有,您可能想做类似的事情
(remove #\A yourstring :test-not 'char=)
根据XLISP reference for remove
, Nyquist remove
不处理 string
,只处理 list
。您需要将 string
转换为 list
才能以这种方式对其进行操作,但也没有 coerce
。这有点 hacky,但我看到的最简单的解决方法是流式传输 string
和 read-char
。这将生成 char
的 list
,然后您可以使用 remove
对其进行操作。
(defun string->list (a-string)
(let ((collector nil)
(stream (make-string-input-stream a-string)))
(dotimes (c (length a-string) (reverse collector))
(setf collector (cons (read-char stream) collector)))))
现在应该可以
(remove #\A (string->list yourstring) :test-not 'char=)
关于lisp - 从 Nyquist 中的字符串中删除字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9039841/
我正在努力打开一个文件,并读取每一行直到 EOF。我正在使用基于 XLISP 的 nyquist,它缺少 Common Lisp 的 with-open-file。我的代码是: (let ((in_f
如何在 Nyquist(与 xlisp 非常相似)中从字符串中删除某个字符并返回结果? 我想计算像“ABBAAAABBBBAABAAAB”这样的字符串中有多少个“A”。 (是的,字符串中只有 'A'
我的理解是:如果我对(例如)2048 个数据点进行 FFT,我将获得前 1024 个点的数据,代表高达采样频率 1/2 的频率。我已经看到时间抽取 (DIT) 和频率抽取 (DIF) 作为更快计算 F
我希望使用 Audacity 中的 Nyquist Prompt 插件构建长度为 2048 个样本的分段线性波形。例如,我可以通过从 2048 个无声(零)样本开始,选择所有样本,然后调用 Nyqui
这一切都是在 MATLAB 2010 中完成的 我的目标是展示以下结果:欠采样、奈奎斯特率/过采样 首先,我需要对 .wav 文件进行下采样以获得不完整/或公正的数据流,然后我可以重新构建该数据流。
我是一名优秀的程序员,十分优秀!