【问题标题】:Let In Statement ErrorLet In 语句错误
【发布时间】:2015-07-27 12:42:37
【问题描述】:

我对下面的 haskell 语句有疑问:

insertSort3 xs =
    let sort3 [] ys = ys
         sort3 (x:xs) ys = sort3 xs (insert x ys)
    in sort3 xs []

我的编译器说:输入“=”时出现解析错误(错误出现在第三行)。

【问题讨论】:

  • 问题是sort3的第二个定义的缩进

标签: sorting haskell insertion-sort


【解决方案1】:

问题是let第二行的缩进:

insertSort3 xs = 
 let sort3 [] ys = ys
     -- the next line should line up with the previous sort3
     sort3 (x:xs) ys = sort3 xs (insert x ys)
 in sort3 xs []     

【讨论】:

    猜你喜欢
    • 2017-05-29
    • 2017-08-14
    • 2016-11-08
    • 1970-01-01
    • 1970-01-01
    • 2011-09-15
    • 2016-05-18
    • 2011-12-23
    • 1970-01-01
    相关资源
    最近更新 更多