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
- count_ones(n : int): int =
- if n > 0 then
- (
- if n % 2 = 1
- then count_ones(n / 2) + 1
- else
- count_ones(n / 2)
- )
- else
- 0
- //
- (* ****** ****** *)
- //
- val N = 10
- //
- val () = println! ("count_ones(", N, ") = ", count_ones(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