1
我对榆树(榆树服务器0.9.2)很新颖,我遇到了一个问题,对我来说已经成为一个障碍。字符模式匹配
这里是我的问题:
根据version-0.9文件,我应该能够编写:
stripCommas str =
case str of
',' :: rest -> stripCommas rest
c :: rest -> c :: stripCommas rest
因此,为了测试这个我基本上做了我自己的函数(非常相似:)):
stripNewLine str =
case str of
'\n' :: rest -> stripNewLine rest
c :: rest -> c :: stripNewLine rest
但他们的展台失败,一些调试后,我发现这个在JavaScript:
var stripNewLine = function(str){
return function(){
switch (str.ctor) {
case '::':
switch (str._0) {
case Chr '\n':
return stripNewLine(str._1);
}
return _L.Cons(str._0,stripNewLine(str._1));
}_E.Case($moduleName,'between lines 22 and 33')}();};
我对JavaScript没有太多了解,但似乎Chr'\ n'应该是Chr('\ n'),强硬我可能是错的......有人能指出我正确的方向吗?我输了...