About TSS The following Oz code is derived from the examples provided in the book:
      "The Seasoned Schemer" by Daniel P. Friedman and Matthias Felleisen.
      http://www.ccs.neu.edu/home/matthias/BTSS/

TSS Chapter #12 Examples in Oz
% Defined in previous chapters
fun {MultiRember L A}
   case L
   of nil then nil
   [] H|T then
      if A == H
         then {MultiRember T A}
         else H|{MultiRember T A}
      end
   end
end
Y = fun {$ Le}
      {fun {$ F} {F F} end
       fun {$ F}
          {Le fun {$ X} {{F F} X} end}
       end}
    end
fun {Add1 N} N + 1 end
fun {IsSet L}
   case L
   of nil then true
   [] H|T then
      if {Member H T}
         then false
         else {IsSet T}
      end
   end
end

%%%%%%%%%%%%%%%%%%% The Little Schemer - Chapter - 12 %%%%%%%%%%%%%%%%%%%%%%

% 12.4
fun {MultiRemberY L A}
   {{Y
       fun {$ Mr}
          fun {$ L}
             case L
             of nil then nil
             [] H|T then
                if A == H
                   then {Mr T}
                   else H|{Mr T}
                end
             end
          end
       end}
    L}
end

% 12.1
local A Lat in
   A = tuna
   Lat = [shrimp salad tuna salad and tuna]
   {Browse 1#{MultiRemberY Lat A}}
end

% 12.5
fun {Length_}
   {fun {$ Le}
      {fun {$ F} {F F} end
       fun {$ F}
          {Le fun {$ X} {{F F} X} end}
       end}
    end
      fun {$ Length}
         fun {$ L}
            case L
            of nil then 0
            [] _|T then {Add1 {Length T}}
            end
         end
      end}
end
fun {LengthY}
   {Y
      fun {$ Length}
         fun {$ L}
            case L
            of nil then 0
            [] _|T then {Add1 {Length T}}
            end
         end
      end}
end
{Browse 5#{{LengthY} [shrimp salad tuna salad]}}

% 12.8
fun {MultiRember_1 L A}
   fun {Mr L}
      case L
      of nil then nil
      [] H|T then
         if H == A
            then {Mr T}
            else H|{Mr T}
         end
      end
   end
in
   {Mr L}
end
{Browse 8#{MultiRember_1 [shrimp salad tuna salad and tuna] tuna}}

% 12.40
fun {RemberF Test}
   fun {$ L A}
      case L
      of nil then nil
      [] H|T then
         if {Test A H}
            then T
            else H|{{RemberF Test} T A}
         end
      end
   end
end

% 12.41
RemberEq = {RemberF fun {$ X Y} X == Y end}

% 12.43
fun {MultiRemberF Test}
   fun {$ L A}
      case L
      of nil then nil
      [] H|T then
         if {Test A H}
            then {{MultiRemberF Test} T A}
            else H|{{MultiRemberF Test} T A}
         end
      end
   end
end

% 12.47
fun {MultiRemberF_1 Test}
   fun {Mf L A}
      case L
      of nil then nil
      [] H|T then
         if {Test A H}
            then {Mf T A}
            else H|{Mf T A}
         end
      end
   end
in
   Mf
end

% 12.49
local Test in
   Test = fun {$ X Y} X == Y end
   {Browse 49#{MultiRemberF_1 Test}}
end

% 12.52
fun {MultiRember_2}
   fun {MultiRember_2 L A}
      case L
      of nil then nil
      [] H|T then
         if A == H
            then {MultiRember_2 T A}
            else H|{MultiRember_2 T A}
         end
      end
   end
in
   MultiRember_2
end
{Browse 52#{{MultiRember_2} [shrimp salad tuna salad and tuna] tuna}}

% 12.54
fun {IsMember A L}
   case L
   of nil then false
   [] H|T then
      if A == H
         then true
         else {IsMember A T}
      end
   end
end

% 12.55
local A Lat in
   A = ice
   Lat = [salad greens with pears brie cheese frozen yogurt]
   {Browse 55#{IsMember A Lat}}
end

% 12.57
fun {IsMember_1 A L}
   fun {IsYes L}
      case L
      of nil then false
      [] H|T then
         if A == H
            then true
            else {IsMember_1 A T}
         end
      end
   end
in
   {IsYes L}
end

% 12.59
{Browse 59#{IsSet [tomatoes and macaroni]}}
{Browse 59#{IsSet [macaroni and cheese]}}

% 12.61
fun {Union Set1 Set2}
   case Set1
   of nil then Set2
   [] H|T then
      if {Member H Set2}
         then {Union T Set2}
         else H|{Union T Set2}
      end
   end
end

% 12.60
local Set1 Set2 in
   Set1 = [tomatoes and macaroni casserole]
   Set2 = [macaroni and cheese]
   {Browse 60#{Union Set1 Set2}}
end

% 12.63
fun {Union_1 Set1 Set2}
   fun {U Set}
      case Set
      of nil then Set2
      [] H|T then
         if {Member H Set2}
            then {U T}
            else H|{U T}
         end
      end
   end
in
   {U Set1}
end

% 12.64
fun {Union_2 Set1 Set2}
   fun {A Set}
      case Set
      of nil then Set2
      [] H|T then
         if {Member H Set2}
            then {A T}
            else H|{A T}
         end
      end
   end
in
   {A Set1}
end

% 12.74
fun {IsMember_2 L A}
   case L
   of nil then false
   [] H|T then
      if A == H
         then true
         else {IsMember_2 T A}
      end
   end
end

% 12.84
fun {Union_3 Set1 Set2}
   fun {U Set}
      case Set
      of nil then Set2
      [] H|T then
         if {IsMember H Set2}
            then {U T}
            else H|{U T}
         end
      end
   end
   fun {IsMember A L}
      case L
      of nil then false
      [] H|T then
         if A == H
            then true
            else {IsMember A T}
         end
      end
   end
in
   {U Set1}
end

% 12.86
fun {Union_4 Set1 Set2}
   fun {U Set}
      case Set
      of nil then Set2
      [] H|T then
         if {M H Set2}
            then {U T}
            else H|{U T}
         end
      end
   end
   fun {M A L}
      case L
      of nil then false
      [] H|T then
         if A == H
            then true
            else {M A T}
         end
      end
   end
in
   {U Set1}
end

% 12.91
fun {Union_5 Set1 Set2}
   fun {U Set}
      case Set
      of nil then Set2
      [] H|T then
         if {M H Set2}
            then {U T}
            else H|{U T}
         end
      end
   end
   fun {M A L}
      fun {N L}
         case L
         of nil then false
         [] H|T then
            if A == H
               then true
               else {N T}
            end
         end
      end
   in
      {N L}
   end
in
   {U Set1}
end

% 12.100
fun {TwoInARow L}
   fun {W L A}
      case L
      of nil then false
      [] H|T then H == A orelse {W T H}
      end
   end
in
   case L
   of nil then false
   [] H|T then {W T H}
   end
end

% 12.104
fun {SumOfPrefixes Tup}
   fun {S Tup Sonssf}
      case Tup
      of nil then nil
      [] H|T then (Sonssf + H) | {S T Sonssf+H}
      end
   end
in
   {S Tup 0}
end

% 12.106
fun {Scramble Tup}
   fun {P Tup Rp}
      case Tup
      of nil then nil
      [] H|T then {Nth H|Rp H} | {P T H|Rp}
      end
   end
in
   {P Tup nil}
end

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