Chapter #2 Examples in Oz
%%%%%%%%%%%%%%%%%%% Chapter - 2 %%%%%%%%%%%%%%%%%%%%%%
% 2.2
{Browse 2#skewer}
% 2.3
{Browse 3#onion(skewer)}
% 2.4
{Browse 4#onion(lamb(onion(skewer)))}
% 2.15
fun {OnlyOnions S}
case S
of skewer then true
[] onion(X) then {OnlyOnions X}
[] lamb(_) then false
[] tomato(_) then false
end
end
% 2.5
{Browse 5#{OnlyOnions skewer}}
% 2.6
{Browse 6#{OnlyOnions onion(skewer)}}
% 2.7
{Browse 7#{OnlyOnions lamb(skewer)}}
% 2.8
{Browse 8#{OnlyOnions onion(onion(onion(skewer)))}}
% 2.9
{Browse 9#{OnlyOnions onion(lamb(onion(skewer)))}}
% 2.34
{Browse 34#{OnlyOnions onion(onion(skewer))}}
% 2.43
{Browse 43#{OnlyOnions onion(lamb(skewer))}}
% 2.58
{Browse 43#tomato(skewer)}
% 2.59
{Browse 43#onion(tomato(skewer))}
% 2.63
fun {IsVegetarian S}
case S
of skewer then true
[] onion(X) then {IsVegetarian X}
[] lamb(_) then false
[] tomato(X) then {IsVegetarian X}
end
end
% 2.61
{Browse 61#{IsVegetarian tomato(onion(tomato(skewer)))}}
% 2.62
{Browse 62#{IsVegetarian onion(onion(onion(skewer)))}}
% 2.69
{Browse 69#onion(tomato(bottom(dagger)))}
% 2.73
fun {IsVeggie S}
case S
of bottom(_) then true
[] onion(X) then {IsVeggie X}
[] lamb(_) then false
[] tomato(X) then {IsVeggie X}
end
end
% 2.70
{Browse 70#{IsVeggie onion(tomato(bottom(dagger)))}}
% 2.71
{Browse 71#onion(tomato(bottom(gold_plate)))}
% 2.72
{Browse 72#{IsVeggie onion(tomato(bottom(gold_plate)))}}
% 2.85
{Browse 85#{IsVeggie onion(tomato(bottom(52)))}}
% 2.86
{Browse 86#{IsVeggie onion(tomato(bottom(one_more_than(zero))))}}
% 2.87
{Browse 87#{IsVeggie onion(tomato(bottom(false)))}}
% 2.108
fun {WhatBottom S}
case S
of bottom(X) then X
[] onion(X) then {WhatBottom X}
[] lamb(X) then {WhatBottom X}
[] tomato(X) then {WhatBottom X}
end
end
% 2.92
{Browse 92#{WhatBottom onion(tomato(bottom(dagger)))}}
% 2.93
{Browse 93#{WhatBottom onion(tomato(bottom(gold_plate)))}}
% 2.94
{Browse 94#{WhatBottom onion(tomato(bottom(52)))}}
% 2.99
{Browse 99#{WhatBottom bottom(52)}}
% 2.100
{Browse 100#{WhatBottom bottom(sword)}}
% 2.101
{Browse 101#{WhatBottom bottom(x)}}
% 2.103
{Browse 103#{WhatBottom tomato(onion(lamb(bottom(52))))}}
% 2.104
{Browse 104#{WhatBottom onion(lamb(bottom(52)))}}
% 2.105
{Browse 105#{WhatBottom lamb(bottom(52))}}
% 2.106
{Browse 106#{WhatBottom bottom(52)}}
|