这个问题在这里已经有了答案:
10年前关闭。
Possible Duplicate:
[F#] How to have two methods calling each other?
大家好,
我有一个场景,我有两个函数可以从相互递归中受益,但我不确定如何在 F# 中做到这一点
我的场景不像下面的代码那么简单,但我想得到类似于编译的东西:
let rec f x =
if x>0 then
g (x-1)
else
x
let rec g x =
if x>0 then
f (x-1)
else
x
最佳答案
您也可以使用 let
rec
... and
形式:
let rec f x =
if x>0 then
g (x-1)
else
x
and g x =
if x>0 then
f (x-1)
else
x
关于F#:相互递归函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3621043/