我想写一个简单的递归函数来帮助我检查数学问题的某些值,但似乎无法添加任何有效的输入。无法输入值到函数中,因为无法推导出类型
这里是有问题的功能
fun 1 = 1
fun n = fun (ceiling n) + 3
这似乎是类型(Integral a1, Num a, RealFrac a1) => a1 -> a
给予fun
任意数量的输入产生以下错误:
Could not deduce (Integral a10) arising from a use of ‘fun’
from the context (Num a)
bound by the inferred type of it :: Num a =>
好吧,函数的定义是它在数学问题中的方式,所以如果它从不碰1,那就是为什么 –