Types 与x27之间的OCaml差异;选项列表和';单子
在OCaml顶级中键入此函数时,我得到了以下结果。两次输入似乎都与我相同,只是Types 与x27之间的OCaml差异;选项列表和';单子,types,ocaml,Types,Ocaml,在OCaml顶级中键入此函数时,我得到了以下结果。两次输入似乎都与我相同,只是:运算符周围的空格不同。有人能在这里解释一下'选项列表和'选项之间的区别吗 # let rec at i = function | [] -> None | h::t -> if i = 1 then Some h else at (i-1) t;; val at : int -> 'a option list -> 'a option = <fun> # let r
:
运算符周围的空格不同。有人能在这里解释一下'选项列表
和'选项
之间的区别吗
# let rec at i = function
| [] -> None
| h::t -> if i = 1 then Some h else at (i-1) t;;
val at : int -> 'a option list -> 'a option = <fun>
# let rec at i = function
| [] -> None
| h :: t -> if i = 1 then Some h else at (i-1) t;;
val at : int -> 'a list -> 'a option = <fun>
#让rec在i=函数处
|[]->无
|h::t->如果i=1,那么一些h在(i-1)t;;
val at:int->“a选项列表->”a选项=
#设rec在i=函数处
|[]->无
|h::t->如果i=1,那么一些h在(i-1)t;;
val at:int->“a列表->”a选项=
以下是我看到的:
$ ocaml
OCaml version 4.01.0
# let rec at i = function
| [] -> None
| h::t -> if i = 1 then Some h else at (i-1) t;;
val at : int -> 'a list -> 'a option = <fun>
# let rec at i = function
| [] -> None
| h :: t -> if i = 1 then Some h else at (i-1) t;;
val at : int -> 'a list -> 'a option = <fun>
$ocaml
OCaml版本4.01.0
#设rec在i=函数处
|[]->无
|h::t->如果i=1,那么一些h在(i-1)t;;
val at:int->“a列表->”a选项=
#设rec在i=函数处
|[]->无
|h::t->如果i=1,那么一些h在(i-1)t;;
val at:int->“a列表->”a选项=
在我看来,你的实验在某些方面是有缺陷的。
:
周围的间距不会有任何区别。你一定是对的。我无法重现这个问题,所以它一定与我之前忘记的某个let绑定有关。谢谢