我给了:spacegather:字符串列表->字符串
我必须创建一个函数,所以它会调用:
spacegather ["I", "am", "nice"] 到 -> "I am nice"
谢谢
我给了:spacegather:字符串列表->字符串
我必须创建一个函数,所以它会调用:
spacegather ["I", "am", "nice"] 到 -> "I am nice"
谢谢
intercalate xs xss = concat (intersperse xs xss)
找出intercalate的实际意义。这里是穿插的:
(*intersperse x [a,b,c..,z]=>[a,x,b,x,c,x..,x,z]*)
fun intersperse y nil = nil
| intersperse y [x] = [x]
| intersperse y (x::xs)=x::y::(intersperse y xs)
让我看看我是否做对了:
fun spacegather (h::[]) = h
| spacegather (h::tl) = h ^ " " ^ (spacegather tl);
spacegather ["I", "am", "nice!!"];
输出: val it = "我很好!!" : 细绳
这个应该可以吧?
String.concatWith " " ["I", "am", "nice"]