Advertisement
Guest User

Untitled

a guest
Apr 8th, 2021
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. fun printToOutStream (outstream, str) = let val os = outstream
  2.  
  3. in
  4. TextIO.output(os,str ^ "\n");
  5. TextIO.closeOut os
  6. end;
  7.  
  8. val os = TextIO.openOut "output.txt";
  9.  
  10. fun ascii (count_end) =
  11. let
  12. val n = ref 0
  13. val str = ref ""
  14. in
  15. while !n < count_end do (
  16.  
  17. str := Int.fmt StringCvt.DEC (!n) ^ " " ^ Int.fmt StringCvt.OCT (!n) ^ " "
  18.  
  19. ^ Int.fmt StringCvt.HEX (!n) ^ " " ^ Int.fmt StringCvt.BIN (!n);
  20.  
  21. printToOutStream(os, !str);
  22. print( Int.fmt StringCvt.DEC (!n) ^ "\t"
  23. ^ Int.fmt StringCvt.BIN (!n) ^ "\t"
  24. ^ Int.fmt StringCvt.OCT (!n) ^ "\t"
  25. ^ Int.fmt StringCvt.HEX (!n) ^ "\n"
  26.  
  27. );
  28. printToOutStream(os, !str);
  29.  
  30. n := !n + 1
  31. )
  32.  
  33.  
  34. end;
  35.  
  36. ascii(16);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement