Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. (*
  2. ** Welcome to
  3. ** Patsopt-as-a-Service(PATSOPTAAS)
  4. *)
  5. (*
  6. ** Factorial
  7. *)
  8.  
  9. (* ****** ****** *)
  10.  
  11. #define
  12. LIBATSCC2JS_targetloc
  13. "contrib/libatscc2js/ATS2-0.3.2"
  14.  
  15. (* ****** ****** *)
  16.  
  17. #include
  18. "{$LIBATSCC2JS}/staloadall.hats"
  19.  
  20. (* ****** ****** *)
  21.  
  22. staload
  23. "{$LIBATSCC2JS}/SATS/print.sats"
  24.  
  25. (* ****** ****** *)
  26.  
  27. #define ATS_MAINATSFLAG 1
  28. #define ATS_DYNLOADNAME "my_dynload"
  29.  
  30. (* ****** ****** *)
  31. //
  32. fun
  33. binrev(n : int): int =
  34. let
  35. //
  36. fun loop(i : int, res: int): int =
  37. if i > 0 then
  38. if i % 2 = 1 then
  39. loop(i >> 1, (res << 1) + 1)
  40. else
  41. loop(i >> 1, res << 1)
  42. else res
  43. in
  44. loop(n, 0)
  45. end
  46. //
  47. (* ****** ****** *)
  48. //
  49. val N = 10
  50. //
  51. val () = println! ("binrev(", N, ") = ", binrev(N))
  52. //
  53. (* ****** ****** *)
  54.  
  55. %{$
  56. //
  57. ats2jspre_the_print_store_clear();
  58. my_dynload();
  59. alert(ats2jspre_the_print_store_join());
  60. //
  61. %} // end of [%{$]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement