我正在做一些非常基本的错误,但我不能,因为我的生活,弄清楚它是什么......
let rec testItSeveralTimes (test, times) =
printfn "Iterations to go %O" times
match times with
| 0 -> ()
| _ ->
test
testItSeveralTimes (test, (times - 1))
testItSeveralTimes ((printfn "Running a test"), 2)
Run Code Online (Sandbox Code Playgroud)
我的期望是:
Iterations to go 2
Running a test
Iterations to go 1
Running a test
Iterations to go 0
Running a test
val it : unit = ()
Run Code Online (Sandbox Code Playgroud)
我得到的是:
Running a test
Iterations to go 2
Iterations to go 1
Iterations to go 0
val …Run Code Online (Sandbox Code Playgroud) f# ×1