Guest User

Untitled

a guest
Dec 24th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Oz 1.00 KB | None | 0 0
  1. \insert 'Visualizer.oz'
  2. \insert 'List.oz'
  3. \insert 'ApplyMoves.oz'
  4. \insert 'Find.oz'
  5.  
  6. %FewerFind
  7.  
  8. declare
  9.  
  10. fun {FewerFind Ms Os Ts Ys}
  11.    case Ys
  12.    of nil then nil
  13.    [] Y|Yr then
  14.       if {Member Ms Y} then
  15.      case {SplitTrain Ms Y}
  16.      of Hs#Tr then
  17.         local HsL TrL
  18.         in
  19.            HsL = {Length Hs}
  20.            TrL = {Length Tr}
  21.  
  22.            trackA(TrL+1)|trackB(HsL)|trackA(~1)|{FewerFind nil Hs Tr Yr}
  23.         end
  24.      end
  25.       elseif {Member Os Y} then
  26.      case {SplitTrain Os Y}
  27.      of Hs#Tr then
  28.         local HsL TrL
  29.         in
  30.            HsL = {Length Hs}
  31.            TrL = {Length Tr}
  32.  
  33.            trackB(~HsL)|trackA(HsL)|trackB(~1)|{FewerFind nil Tr {Append Hs Ts} Yr}
  34.         end
  35.      end
  36.       elseif {Member Ts Y} then
  37.      case {SplitTrain Ys Y}
  38.      of Hs#Tr then
  39.         local HsL TrL
  40.         in
  41.            HsL = {Length Hs}
  42.            TrL = {Length Tr}
  43.  
  44.            trackA(~HsL)|trackB(HsL)|trackA(~1)|{FewerFind nil {Append Hs Os} Tr Yr}
  45.         end
  46.      end
  47.       end
  48.    end
  49. end
  50. {Browse {FewerFind [a b] nil nil [b a]}}
Add Comment
Please, Sign In to add comment