首页 > 解决方案 > 为什么 F# 在我的最后一行“disp”函数中发现错误?

问题描述

let disp xs (d:float) =
    match xs with
    | [] -> ' ' // return the space char
    | (a,b)::ts -> if(a > d)
                    then b // Found
                    else (disp ts d)

标签: f#

解决方案


您需要使用以下命令指示递归函数rec

let rec disp xs (d:float) =
    match xs with
    | [] -> ' ' // return the space char
    | (a,b)::ts -> if(a > d)
                    then b // Found
                    else (disp ts d)

推荐阅读