Getting Started with SML

Getting Started with SML 


To learn how to install sml and open the SML console visit 

In the previous post, we have learned about how to install and open the SML console. Lets now get started with the first program to print "Hello World".

Open SML console and write

- print("Hello World"); and press Enter.



Comments in SML


Comments in Standard ML begin with (* and end with *)

Variable Declarations in SML

SML will automatically find the variable datatype we did not need to explicitly declare types. 

val a = 10;                    (val a = 5551337 : int)
val a = 5551337;          (val a = 5551337 : int)
val a = 3.14159;           (val a = 3.14159 : real)
val a = ~10;                  (val a = ~10 : int)  ( Unary minus uses the 'tilde' symbol )

we can also explicitly declare the datatype 

val d = 123 : int;          (val d = 123 : int)





We cannot print integer and other data types in print statement other than string.

Need to be converted into a string, to convert an integer into String.

val a = 10;print(Int.toString(a))

For concatenation of two strings ^ is used.

print("Hello "^"World");




For Arithmetic operations in SML visit the link. https://aamir0509.blogspot.com/2019/09/arithmetic-operations-in-smlnj.html

Comments

Popular posts from this blog

Conditional Statement in SML (if else in SML)

Print table in SML-NJ