Created
August 26, 2017 16:31
-
-
Save wklm/2602a76c686421146af559a5ad222d91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#use "topfind" | |
#thread | |
#require "core" | |
open Core | |
let rec factorial (number : int) = | |
if number >= 1 then number * factorial (number - 1) | |
else 1 ;; | |
let test (f : int -> int) = | |
f ;; | |
let print_fac (number : int) = sprintf "%i! = %i\n" number (factorial number);; | |
let read_number = int_of_string Sys.argv.(0);; | |
printf "%s" (read_number |> print_fac) | |
(* | |
Exception: Failure "int_of_string". | |
Raised by primitive operation at file "./test.ml", line 19, characters 18-44 | |
Called from file "toplevel/toploop.ml", line 180, characters 17-56 | |
*) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment