

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


CS 3721: Programming Languages Lab Lab #05: Programming in ML
ML is a statically typed functional programming language. In particular, ML is both compiled and interpreted. Similar to Scheme, it supports functional programming; similar to C/Pascal, it also supports statements and a wide variety of compound data structures including lists, tuples, records(similar to C struct), and user-defined data types.
If you have a ML program, say myprogram.ml, you can compile and run your program by typing
sml < myprogram.ml The redirection ensures that the ML environment reads your program, processes all the statements and expressions, and then exits. NOTE: All ML statements must termi- nate with semicolons (‘;’). ML will not start interpreting your expression unless you place a ‘;’ at the end (which makes it a statement).
Finish the following exercises to get you familiar with ML syntax and concepts. Open a text file with ”.sml” as extension and save all your solutions. In particular, use a comment above each solution to indicate the corresponding exercise number. Each ML comment must be enclosed within a pair of (∗ and ∗).
(* This is a comment. sml will not attempt to execute any part of it. *)
After you are done, submit your sml file
www.cs.utsa.edu/~cs
1::[2,3,4]; (3,4); {f1 = "a", f2="b"}; fn x => x + 5; ref 3;