小编Bob*_*ers的帖子

如果OCaml中的语句为false,则语句将尽早结束

假设已定义pos_of_xy(x,y)n以返回int,则一旦if语句之一返回false,此代码段将退出,就好像它们是嵌套的一样.无论先前的if语句如何,我都需要它们全部运行.我不确定我忘记了什么.

let final = ref [] in begin
  if x < (size-1) then let pos = pos_of_xy (x+1, y) size in final := pos::!final;
  if y < (size-1) then let pos = pos_of_xy (x, y+1) size in final := pos::!final;
  if y > 0 then let pos = pos_of_xy (x, y-1) size in final := pos::!final;
  if x > 0 then let pos = pos_of_xy (x-1, y) size in final := pos::!final;
end;
Run Code Online (Sandbox Code Playgroud)

ocaml

2
推荐指数
1
解决办法
313
查看次数

标签 统计

ocaml ×1