Int List Int: Tutorial1.Sml Page 1
Int List Int: Tutorial1.Sml Page 1
sml Page 1
fun sumList x =
if x = nil then 0
else hd(x) + sumList(tl(x));
sumList [1,2,3,4];
sumList1 [1,2,3,4];
val t = [1, 3, 5, 7, 9] ;
applySomeFunc(square, t) ;
applySomeFunc(square, [1,2,3,4,5]) ;
fun month(n:int):string =
case n of
1 => "January"
| 2 => "February"
| 3 => "March"
| 4 => "April"
| 5 => "May"
| 6 => "June"
| 7 => "July"
| 8 => "August"
| 9 => "September"
| 10 => "October"
| 11 => "November"
| 12 => "December"
| _ => "Bad month"