【发布时间】:2016-11-30 01:32:02
【问题描述】:
我正在尝试使用带有(string-split "a,b,c" ",") 的映射来拆分列表中的字符串。
(string-split "a,b,c" ",")
'("a" "b" "c")
如果在没有“,”的情况下使用字符串拆分,则以下工作:
(define sl (list "a b c" "d e f" "x y z"))
(map string-split sl)
'(("a" "b" "c") ("d" "e" "f") ("x" "y" "z"))
但以下不会拆分列表中“,”周围的字符串:
(define sl2 (list "a,b,c" "d,e,f" "x,y,z"))
(map (string-split . ",") sl2)
'(("a,b,c") ("d,e,f") ("x,y,z"))
如何将 map 与需要额外参数的函数一起使用?
【问题讨论】:
-
(map (lambda (x) (string-split x ",")) lst) -
最简单!您应该输入它作为答案。
标签: scheme racket map-function partial-application