Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (*
- ** Welcome to
- ** Patsopt-as-a-Service(PATSOPTAAS)
- *)
- (*
- ** Factorial
- *)
- (* ****** ****** *)
- #define
- LIBATSCC2JS_targetloc
- "contrib/libatscc2js/ATS2-0.3.2"
- (* ****** ****** *)
- #include
- "{$LIBATSCC2JS}/staloadall.hats"
- (* ****** ****** *)
- staload
- "{$LIBATSCC2JS}/SATS/print.sats"
- (* ****** ****** *)
- #define ATS_MAINATSFLAG 1
- #define ATS_DYNLOADNAME "my_dynload"
- (* ****** ****** *)
- //
- fun
- binrev(n : int): int =
- let
- //
- fun loop(i : int, res: int): int =
- if i > 0 then
- if i % 2 = 1 then
- loop(i >> 1, (res << 1) + 1)
- else
- loop(i >> 1, res << 1)
- else res
- in
- loop(n, 0)
- end
- //
- (* ****** ****** *)
- //
- val N = 10
- //
- val () = println! ("binrev(", N, ") = ", binrev(N))
- //
- (* ****** ****** *)
- %{$
- //
- ats2jspre_the_print_store_clear();
- my_dynload();
- alert(ats2jspre_the_print_store_join());
- //
- %} // end of [%{$]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement