Advertisement
Guest User

Untitled

a guest
Feb 25th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.25 KB | None | 0 0
  1. let toInt (b : bignum) : int option =
  2.   if less b (fromInt Int.min_value) || greater b (fromInt Int.max_value)
  3.     then None
  4.     else
  5.       let n = List.fold_left ~f:(fun c i -> c * 10 + i) b.coeffs ~init:0
  6.       in Some (if b.neg then (-n) else n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement