File: fib.ml

package info (click to toggle)
ocaml-doc 3.09-1
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 10,428 kB
  • ctags: 4,963
  • sloc: ml: 9,244; makefile: 2,413; ansic: 122; sh: 49; asm: 17
file content (10 lines) | stat: -rw-r--r-- 293 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
(* File fib.ml: define some Caml functions. *)

let rec fib n = if n < 2 then 1 else fib (n - 1) + fib (n - 2);;

let format_result n = Printf.sprintf "Result is: %d\n" n;;

(* Export those two functions to C *)

Callback.register "fib" fib;;
Callback.register "format_result" format_result;;