We will be using a special version of the super nifty ocaml-top IDE to interact with Ocaml.
This version has been instrumented to gather interaction traces to help understand how students learn ocaml, therefore helping future generations of students!
The IDE is slightly tricky to build, and so we have already installed it on the lab machines. Simply type:
$ prep cs130f
.
.
.
$ ocaml-top
at the Unix shell prompt to fire up the IDE.
You can run the IDE at home by logging into ieng
and then using one of
The IDE is pretty intuitive. See the web page for details.
Ctrl-o
(or the relevant toolbar icon)Ctrl-s
(or the relevant toolbar icon)Ctrl-c
, Ctrl-x
and Ctrl-v
do the usual copy,play
to execute till your cursor, and fast-forward
to execute the whole file.If you want to see the value of some expression e
then just write:
let _ = e
into the editor pane, put your cursor after the e
and hit play
.
Also, remember that you can print stuff in Ocaml by:
let name = "Ranjit"
let age = 36
let _ = Format.printf "My name is %s and I am %d years old" name age
Produces the output
val name : string = "Ranjit"
val age : int = 36
My name is Ranjit and I am 36 years old
- : unit = ()