Main Page | Recent changes | Edit this page | Page history

Printable version | Disclaimers

Not logged in
Log in | Help
 

Topics:LML in other languages:Oz:Chapter 3

From CTMWiki

About LML

The following Oz code is derived from the examples provided in the book:
      "The Little MLer" by Matthias Felleisen and Daniel P. Friedman.
      http://www.ccs.neu.edu/home/matthias/BTML/

Chapter #3 Examples in Oz

%%%%%%%%%%%%%%%%%%% Chapter - 3 %%%%%%%%%%%%%%%%%%%%%%

%% 3.2
{Browse 2#anchovy(onion(anchovy(anchovy(cheese(crust)))))}

%% 3.10
fun {RemoveAnchovy P}
   case P
   of crust      then crust
   [] cheese(X)  then cheese({RemoveAnchovy X})
   [] onion(X)   then onion({RemoveAnchovy X})
   [] anchovy(X) then {RemoveAnchovy X}
   [] sausage(X) then sausage({RemoveAnchovy X})
   end
end

%% 3.4
{Browse 4#{RemoveAnchovy anchovy(onion(anchovy(anchovy(cheese(crust)))))}}

%% 3.5
{Browse 5#{RemoveAnchovy sausage(onion(anchovy(sausage(cheese(crust)))))}}

%% 3.11
{Browse 11#{RemoveAnchovy anchovy(crust)}}

%% 3.13
{Browse 13#{RemoveAnchovy anchovy(anchovy(crust))}}

%% 3.14
{Browse 14#{RemoveAnchovy onion(cheese(anchovy(anchovy(crust))))}}

%% 3.15
local X in
   X = cheese(anchovy(anchovy(crust)))
   {Browse 15#onion({RemoveAnchovy X})}
end

%% 3.16
{Browse 16#{RemoveAnchovy cheese(anchovy(anchovy(crust)))}}

%% 3.17
local X in
   X = anchovy(anchovy(crust))
   {Browse 17#cheese({RemoveAnchovy X})}
end

%% 3.18
{Browse 18#{RemoveAnchovy anchovy(anchovy(crust))}}

%% 3.24
{Browse 24#{RemoveAnchovy cheese(anchovy(cheese(crust)))}}

%% 3.26
{Browse 26#cheese({RemoveAnchovy anchovy(cheese(crust))})}

%% 3.27
{Browse 27#{RemoveAnchovy anchovy(cheese(crust))}}

%%
fun {TopAnchovyWithCheese P}
   case P
   of crust      then crust
   [] cheese(X)  then cheese({TopAnchovyWithCheese X})
   [] onion(X)   then onion({TopAnchovyWithCheese X})
   [] anchovy(X) then cheese(anchovy({TopAnchovyWithCheese X}))
   [] sausage(X) then sausage({TopAnchovyWithCheese X})
   end
end

%% 3.36
{Browse 36#{TopAnchovyWithCheese anchovy(cheese(anchovy(crust)))}}

%% 3.37
{Browse 37#{TopAnchovyWithCheese onion(cheese(sausage(crust)))}}

%% 3.45
{Browse 45#{TopAnchovyWithCheese {RemoveAnchovy onion(anchovy(cheese(anchovy(crust))))}}}

%% 3.46
{Browse 46#{RemoveAnchovy {TopAnchovyWithCheese onion(anchovy(cheese(anchovy(crust))))}}}

%% 3.49
fun {SubstAnchovyByCheese_ P}
   {RemoveAnchovy {TopAnchovyWithCheese P}}
end

%% 3.51
fun {SubsAnchovyByCheese P}
   case P
   of crust      then crust
   [] cheese(X)  then cheese({SubsAnchovyByCheese X})
   [] onion(X)   then onion({SubsAnchovyByCheese X})
   [] anchovy(X) then cheese({SubsAnchovyByCheese X})
   [] sausage(X) then sausage({SubsAnchovyByCheese X})
   end
end

Retrieved from "http://www.codepoetics.com/wiki/index.php?title=Topics:LML_in_other_languages:Oz:Chapter_3"

This page has been accessed 567 times. This page was last modified 04:13, 31 Jul 2008.


[Main Page]
Main Page
Recent changes
Random page
Current events

Edit this page
Discuss this page
Page history
What links here
Related changes

Special pages
Bug reports