(* --- In-class example --- *) datatype icecream = VanillaIC | ChocolateIC | StrawberryIC | CookieDoughIC | CricketIC | BananaIC; datatype syrup = ChocolateS | CaramelS | StrawberryS | HotFudge; datatype topping = RainbowSprinkles | ChocolateSprinkles | ChocolateChips | Walnuts | Pecans | Cherry | WhippedCream | GummyBears | Crickets; datatype cone = CakeC | SugarC | WaffleC; datatype donutDough = CakeD | YeastD; datatype donutFlavor = VanillaD | ChocolateD | BlueberryD | PumpkinD | AppleCiderD | RedVelvetD ; datatype frostingFlavor = VanillaF | ChocolateF | MapleF | PeanutButterF; datatype donutEncasement = Plain | Frosting of frostingFlavor | Glaze | Powder; datatype pop = RootBeer | Cola | LemonLime; datatype treat = IcecreamCone of icecream * cone | IcecreamSundae of icecream * syrup * topping | Donut of donutDough * donutFlavor * donutEncasement | Float of pop * icecream; (* --- from the book --- *) datatype number = Int of int | Real of real; (* interpret the first int as numerator and second as denominator *) datatype rational = Fraction of int * int; (* 1.10.1 *) (* A HW problem; this is just to get you started *) datatype book = (* author, title, pages *) Novel of string * string * int (* title, number of vols *) | RefBook of string * int (* author, title, subject, pages *) | NonFiction of string * string * string * int (* author, title, subject, publisher *) | Textbook of string * string * string * string ... datatype libraryItem = Book of book | Recording of recording (* Simple function examples *) fun fahrToCel(t) = (t - 32) * 5 div 9; fun f(x) = 3.0 * x*x - 2.7 * x + 14.4; fun capitalize(s) = str(Char.toUpper(String.sub(s, 0))) ^ String.substring(s, 1, size(s) - 1);