I have just started to learn SML on my own and get stuck with a question from the tutorial.
Let say I have:
tree data type
datatype node of (tree*int*tree) | null
insert function
fun insert (newItem, null) = node (null, newItem, null)
| insert (newItem, node (left, oldItem, right)) =
if (newItem <= oldItem) then node (insert(newItem,left),oldItem, right)
else
node (left, oldItem, insert(newItem, right)
an integer list
val intList = [19,23,21,100,2];
my question is how can I add write a function to loop through each element in the list and add to a tree?
Your answer is really appreciated.