SML As a Calculator

  1. Set your path in your .cshrc so that you may call the SML interpreter directly using the command sml

    Question: How do you know from the prompt whether you are in SML or not?

  2. You may use SML as a command-line calculator to compute various complex expressions including the following:

    Question: Do you see any difference between these expressions?

    Question: What about the following?

    Question: Do you understand why you get different answers in each case?

  3. Find out all the primitive functions on integers by typing open Int;. Since most of them are self-explanatory you probably understand what they do.

    Question: But can you figure out what the following functions are?

    Question: Can you figure out when the two functions div and quot will give different answers?

    Question: Simlarly what is the difference between rem and mod?

    Question: Try to give one or more identities that connect the functions div, quot, rem and mod?

  4. Now open the structure Real and see what functions you can recognize? Experiment with the functions you don't understand and try to figure out what they do.

    Question: How will you convert between integers and reals when you have to?

  5. There are three more basic data types you need to explore: Open them all and try to figure out what the various functions do.

    Question: What do the following functions do?

    Question: What sort of ordering on strings does < implement?

    Question: Can you figure out why you have the following functions on strings? Does it make any sense at all to have them for strings too?


S. Arun-Kumar
Last modified: Fri Aug 11 09:54:19 2006