【发布时间】:2008-10-02 08:29:48
【问题描述】:
鉴于以下情况:
#light
//any function returning bool * 'a
let foo =
let x = ref 10
fun () ->
x := !x - 1
if !x <> 0 then
(true, x)
else
(false, x)
while let (c,x) = foo() in c do print_any x;//can't access x, but would be convinent.
//this is how I want it to work, without all the typing
let rec loop f =
match f() with
| (true, x) ->
print_any x
loop f
| (false, _) -> ()
loop foo
我应该如何解决这个问题? 还是我应该费力地将“foo”转换为序列表达式?
【问题讨论】:
-
你能描述你试图解决的问题,而不是引用一个不起作用的解决方案吗?
标签: f#