在我的家庭作业中,我有字母表 a、b 和 c。
我有两个问题我无法弄清楚。
1) 包含奇数个字符的字符串。
2) 字符数为偶数的字符串。
如何跟踪正则表达式中的偶数/奇数字符串?任何帮助表示赞赏。
我想要做的是定义一个列表,例如 (define lst '(1 2 3 4 5 6)) 然后调用 (split lst) 它将返回 '((1 3 5) (2 4 6))。
一些例子:
lst是'(1 2 3 4 5 6),它应该返回'((1 3 5) (2 4 6))lst是'(1 2 3 4 5 6 7),它应该返回'((1 3 5 7) (2 4 6))lst是'("a" "little" "bit" "of" "that" "to" "spice" "things" "up"),它应该返回'(("a" "bit" "that" "spice" "up") ("little" "of" "to" "things"))它应该在构建两个列表时交替。所以第一个索引应该在第一个列表中,第二个索引在第二个列表中,第三个索引在第一个列表中,依此类推。
这是我当前的脚本。
(define (split …Run Code Online (Sandbox Code Playgroud)