About AFP The following Oz code is derived from the examples provided in the book:
      "A Little Java, A Few Patterns" by Matthias Felleisen and Daniel P. Friedman.
      http://www.ccs.neu.edu/home/matthias/BALJ/

Chapter #2 Examples in Oz
% Defined in previous chapters
class Integer feat X meth init(Xi) self.X = Xi end end
class NumD end
class Zero from NumD meth init skip end end
class OneMoreThan from NumD
   feat Predecessor
   meth init(P)
      self.Predecessor = P
   end
end


%%%%%%%%%%%%%%%%%%% Chapter - 2 %%%%%%%%%%%%%%%%%%%%%%

% 2.7 | 2.136
class PointD
   meth distanceTo0(?$)
      raise abstract() end
   end
   meth closerTo0(P ?$)
      {self distanceTo0($)} =< {P distanceTo0($)}
   end
end
class CartesianPt from PointD
   feat X Y
   meth init(Xi Yi)
      self.X = Xi
      self.Y = Yi
   end
   meth distanceTo0(?$)
      {FloatToInt {Sqrt {IntToFloat self.X*self.X + self.Y*self.Y}}}
   end
end
class ManhattanPt from PointD
   feat X Y
   meth init(Xi Yi)
      self.X = Xi
      self.Y = Yi
   end
   meth distanceTo0(?$)
      self.X + self.Y
   end
end

% 2.3
{Browse 3#{New ManhattanPt init(3 4)}}

% 2.4
{Browse 4#{New CartesianPt init(3 4)}}

% 2.12
{Browse 12#{{New ManhattanPt init(3 4)} distanceTo0($)}}

% 2.14
{Browse 14#{{New CartesianPt init(3 4)} distanceTo0($)}}

% 2.17 | 2.29 | 2.72 | 2.79
class ShishD
   meth onlyOnions(?$)
      raise abstract() end
   end
   meth isVegetarian(?$)
      raise abstract() end
   end
end
class Skewer from ShishD
   meth init skip end
   meth onlyOnions(?$) true end
   meth isVegetarian(?$) true end
end
class Onion from ShishD
   feat Shish
   meth init(S) self.Shish = S end
   meth onlyOnions(?$) {self.Shish onlyOnions($)} end
   meth isVegetarian(?$) {self.Shish isVegetarian($)} end
end
class Lamb from ShishD
   feat Shish
   meth init(S) self.Shish = S end
   meth onlyOnions(?$) false end
   meth isVegetarian(?$) false end
end
class Tomato from ShishD
   feat Shish
   meth init(S) self.Shish = S end
   meth onlyOnions(?$) false end
   meth isVegetarian(?$) {self.Shish isVegetarian($)} end
end

% 2.19
{Browse 19#{New Skewer init}}

% 2.20
{Browse 20#{New Onion init({New Skewer init})}}

% 2.21
{Browse 43#{New Onion init(
               {New Lamb init(
                  {New Onion init(
                     {New Skewer init})})})}}

% 2.22
{Browse 22#{{New Skewer init} onlyOnions($)}}

% 2.23
{Browse 23#{{New Onion init({New Skewer init})} onlyOnions($)}}

% 2.24
{Browse 24#{{New Lamb init({New Skewer init})} onlyOnions($)}}

% 2.25
{Browse 25#{{New Onion init(
               {New Onion init(
                  {New Onion init(
                     {New Skewer init})})})} onlyOnions($)}}

% 2.26
{Browse 26#{{New Onion init(
               {New Lamb init(
                  {New Onion init(
                     {New Skewer init})})})} onlyOnions($)}}

% 2.36
{Browse 36#{{New Onion init(
               {New Onion init(
                  {New Skewer init})})} onlyOnions($)}}

% 2.55
{Browse 55#{{New Onion init(
               {New Lamb init(
                  {New Skewer init})})} onlyOnions($)}}

% 2.67
{Browse 67#{New Tomato init({New Skewer init})}}

% 2.68
{Browse 68#{New Onion init(
               {New Tomato init(
                  {New Skewer init})})}}

% 2.70
{Browse 70#{{New Tomato init(
               {New Onion init(
                  {New Tomato init(
                     {New Skewer init})})})} isVegetarian($)}}

% 2.71
{Browse 71#{{New Onion init(
               {New Onion init(
                  {New Onion init(
                     {New Skewer init})})})} isVegetarian($)}}

% 2.80 | 2.90 | 2.116
class KebabD
   meth isVeggie(?$)
      raise abstract() end
   end
   meth whatHolder
      raise abtract() end
   end
end
class Holder from KebabD
   feat Obj
   meth init(O) self.Obj = O end
   meth isVeggie(?$) true end
   meth whatHolder(?$) self.Obj end
end
class Shallot from KebabD
   feat Kebab
   meth init(K) self.Kebab = K end
   meth isVeggie(?$) {self.Kebab isVeggie($)} end
   meth whatHolder(?$) {self.Kebab whatHolder($)} end
end
class Shrimp from KebabD
   feat Kebab
   meth init(K) self.Kebab = K end
   meth isVeggie(?$) false end
   meth whatHolder(?$) {self.Kebab whatHolder($)} end
end
class Radish from KebabD
   feat Kebab
   meth init(K) self.Kebab = K end
   meth isVeggie(?$) {self.Kebab isVeggie($)} end
   meth whatHolder(?$) {self.Kebab whatHolder($)} end
end

% 2.82
class RodD end
class Dagger from RodD meth init skip end end
class Sabre from RodD meth init skip end end
class Sword from RodD meth init skip end end

% 2.83
class PlateD end
class Gold from PlateD meth init skip end end
class Silver from PlateD meth init skip end end
class Brass from PlateD meth init skip end end
class Copper from PlateD meth init skip end end
class Wood from PlateD meth init skip end end

% 2.84 | 2.92
{Browse 84#{New Shallot init(
               {New Radish init(
                  {New Holder init(
                     {New Dagger init})})})}}

% 2.85 | 2.91
{Browse 85#{{New Shallot init(
               {New Radish init(
                  {New Holder init(
                     {New Dagger init})})})} isVeggie($)}}

% 2.86 | 2.94
{Browse 86#{New Shallot init(
               {New Radish init(
                  {New Holder init(
                     {New Gold init})})})}}

% 2.87 | 2.93
{Browse 87#{{New Shallot init(
               {New Radish init(
                  {New Holder init(
                     {New Gold init})})})} isVeggie($)}}

% 2.95
{Browse 95#{{New Shallot init(
               {New Radish init(
                  {New Holder init(
                     {New Integer init(52)})})})} isVeggie($)}}

% 2.96
{Browse 96#{{New Shallot init(
               {New Radish init(
                  {New Holder init(
                     {New OneMoreThan init(
                        {New Zero init})})})})} isVeggie($)}}

% 2.97
class Boolean feat X meth init(Xi) self.X = Xi end end
{Browse 97#{{New Shallot init(
               {New Radish init(
                  {New Holder init(
                     {New Boolean init(false)})})})} isVeggie($)}}

% 2.99
{Browse 99#{New Shallot init(
               {New Radish init(
                  {New Holder init(
                     {New Dagger init})})})}}

% 2.100
{Browse 100#{New Shallot init(
               {New Radish init(
                  {New Holder init(
                     {New Gold init})})})}}

% 2.101
{Browse 101#{New Shallot init(
               {New Radish init(
                  {New Holder init(
                     {New Integer init(52)})})})}}

% 2.102
{Browse 102#{{New Shallot init(
               {New Radish init(
                  {New Holder init(
                     {New Dagger init})})})} whatHolder($)}}

% 2.103
{Browse 103#{{New Shallot init(
               {New Radish init(
                  {New Holder init(
                     {New Gold init})})})} whatHolder($)}}

% 2.104
{Browse 104#{{New Shallot init(
               {New Radish init(
                  {New Holder init(
                     {New Integer init(52)})})})} whatHolder($)}}

% 2.108
{Browse 108#{{New Holder init({New Integer init(52)})} whatHolder($)}}

% 2.109
{Browse 109#{{New Holder init({New Sword init})} whatHolder($)}}

% 2.110
{Browse 110#{{New Holder init(b)} whatHolder($)}}

% 2.112
{Browse 112#{{New Radish init(
               {New Shallot init(
                  {New Shrimp init(
                     {New Holder init(
                        {New Integer init(52)})})})})} whatHolder($)}}

% 2.113
{Browse 113#{{New Shallot init(
               {New Shrimp init(
                  {New Holder init(
                     {New Integer init(52)})})})} whatHolder($)}}

% 2.114
{Browse 114#{{New Shrimp init(
               {New Holder init(
                  {New Integer init(52)})})} whatHolder($)}}

% 2.115
{Browse 115#{{New Radish init(
               {New Shallot init(
                  {New Shrimp init(
                     {New Holder init(
                        {New Integer init(52)})})})})} whatHolder($)}}
{Browse 115#{{New Shallot init(
               {New Shrimp init(
                  {New Holder init(
                     {New Integer init(52)})})})} whatHolder($)}}
{Browse 115#{{New Shrimp init(
               {New Holder init(
                  {New Integer init(52)})})} whatHolder($)}}
{Browse 115#{{New Holder init(
               {New Integer init(52)})} whatHolder($)}}

% 2.120
class Pepper from KebabD
   feat Kebab
   meth init(K) self.Kebab = K end
   meth isVeggie(?$) {self.Kebab isVeggie($)} end
   meth whatHolder(?$) {self.Kebab whatHolder($)} end
end
class Zucchini from KebabD
   feat Kebab
   meth init(K) self.Kebab = K end
   meth isVeggie(?$) {self.Kebab isVeggie($)} end
   meth whatHolder(?$) {self.Kebab whatHolder($)} end
end


% 2.123
{Browse 123#{{New ManhattanPt init(3 4)} closerTo0({New ManhattanPt init(1 5)} $)}}

% 2.124
{Browse 124#{{New CartesianPt init(3 4)} closerTo0({New CartesianPt init(12 5)} $)}}

% 2.125
class CartesianPt_1 from PointD
   feat X Y
   meth init(Xi Yi)
      self.X = Xi
      self.Y = Yi
   end
   meth distanceTo0(?$)
      {FloatToInt {Sqrt {IntToFloat self.X*self.X + self.Y*self.Y}}}
   end
   meth closerTo0(P ?$)
      {self distanceTo0($)} =< {P distanceTo0($)}
   end
end
class ManhattanPt_1 from PointD
   feat X Y
   meth init(Xi Yi)
      self.X = Xi
      self.Y = Yi
   end
   meth distanceTo0(?$)
      self.X + self.Y
   end
   meth closerTo0(P ?$)
      {self distanceTo0($)} =< {P distanceTo0($)}
   end
end

% 2.126
{Browse 126#{{New ManhattanPt init(3 4)} closerTo0({New ManhattanPt init(1 5)} $)}}

% 2.127
{Browse 127#{{New ManhattanPt init(1 5)} closerTo0({New ManhattanPt init(3 4)} $)}}

% 2.128
{Browse 128#{{New CartesianPt init(12 5)} closerTo0({New CartesianPt init(3 4)} $)}}

% 2.129
{Browse 129#{{New CartesianPt init(3 4)} closerTo0({New ManhattanPt init(1 5)} $)}}

Chris Rathman / Chris.Rathman@tx.rr.com