Learning functions in SML