All pastes #384030 Raw Edit

Mine

public text v1 · immutable
·published 2007-03-06 19:52 UTC
rendered paste body
(* Pizza datatype*)
datatype topping = Onion of real | Green_Peppers of real | Mushrooms of real | Goat_Cheese of real | Pepperoni of               real | Eggplant of real;

datatype pizza = single of topping
        | double of topping*topping
        | triple of topping*topping*topping
        | plain of real;
fun getPrice(Onion(x)) = x
        |getPrice(Green_Peppers(x)) = x
        |getPrice(Mushrooms(x)) = x
        |getPrice(Goat_Cheese(x))=x
        |getPrice(Pepperoni(x))=x
        |getPrice(Eggplant(x))=x;
fun pizza_item(single(x))=getPrice(x)
        | pizza_item(double(x,y))=getPrice(x)+getPrice(y)
        | pizza_item(triple(x,y,z))=getPrice(x)+getPrice(y)+getPrice(z)
        | pizza_item(plain(x))=x;

fun pizza_p(x)=getPrice(x);
fun pizza_price (x::xs)=pizza_item(x)+pizza_price(xs);