Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我从介绍性 ocaml 课程的幻灯片中复制了递归列表匹配函数。
let rec fac n = match n with 0 -> 1 | _ -> n * fac(n-1);; fac 3;;
我得到:“错误:未绑定值 fac”
为什么是这样?
在 emacs 中使用 MX tuareg-eval-buffer 可以:
OCaml version 4.02.3 # let rec fac n = match n with 0 -> 1 | _ -> n * fac(n-1);; fac 3;; val fac : int -> int = <fun> # - : int = 6 #
您可能只使用选定的选项运行 MX tuarge-eval-region,fac 3因此从未定义过该函数。
fac 3