Learning the ML programming language is a lot of fun. This is my first in-depth initiation into the exciting world of functional programming. Here's something to whet your appetite, an elegant function for appending two lists of any type:
fun append e = case e of ([],ys) => ys | (x::xs,ys) => x :: append(xs,ys)
Here we are passing the function append
an expression e
, and if the pattern matches empty string plus string we stop, otherwise we prepend the first element to the tail appended to the list.
I am following the online Coursera training by the University of Washington called Programming Languages given by Dan Grossman.
Great stuff to keep my aging brain cells oiled and running efficiently.