Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 13th, 2012  |  syntax: OCaml  |  size: 0.36 KB  |  views: 86  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. let log2 x =
  2.         (log x) /. (log 2.0);;
  3.        
  4. let ceil y =
  5.         let rec iceil x y =
  6.                 if y <= 0.0 then
  7.                         x
  8.                 else
  9.                         iceil (x+1) (y -. 1.0) in
  10.                 iceil 0 y;;
  11.                
  12. let pow y =
  13.         let rec ipow x y =
  14.          match y with
  15.                 0 -> x |
  16.                 y -> ipow (x*2) (y-1) in
  17.                         ipow 1 y;;
  18.  
  19. let biject x y =
  20.         let width = ceil (log2 (float_of_int x)) in
  21.         let raised = pow y in
  22.         raised + x;;