문제

I would like to compile my ML program into a executable binary using mosmlc. However, I could not find much information on how to do it.

The code that I'd like to compile is here http://people.pwf.cam.ac.uk/bt288/tick6s.sml

cx,cy,s,imgLocation are 4 arguments that I'd like to take from command line arguments. For instance, if the program is compiled with name mandelbrot, input bash$mandelbrot -0.5 0.15 0.0099 image.png should execute the main function.

도움이 되었습니까?

해결책

You should be able to put this code into a file foo.sml and run

mosmlc -P full foo.sml

To get the command-line arguments you want function CommandLine.arguments, so, e.g.,

val (cx, cy, s, imgLocation) = 
  case CommandLine.arguments () 
    of [a, b, c, d] -> (a, b, c, d)
     | _ -> (usage(); Process.exit Process.failure)

You'll have to write your own usage function.


P.S. If you have access to mosmlc, you probably also have access to the interactive mosml, which has an incredibly useful help function with type string -> unit.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top