Looping in SML
Looping in SML
To learn how to install sml and open the SML console visit
In an earlier post, we have learned about the basic concepts of, as there is no predefined syntax for the looping, but we can create it by using the recursive function.
following is the sample code snippet for printing number from 1 to 10.
(*Loop printing program in SML-NJ *)
(* To under stand the looping concept in SML-NJ*)
(* In function loop 2 values are passed
1. Initialization
2. Termination
*)
fun loop (n,max) =
if n > max then
print "\n"
else (
print (Int.toString (n)^"\n");
loop (n + 1,max)
);
loop (1,10);(*loop(initilization , termination)*)
For Table printing in SML visit the link. https://aamir0509.blogspot.com/2019/09/print-table-in-sml-nj.html
Comments
Post a Comment