Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Oz 0.83 KB | None | 0 0
  1. fun {NFullAdder S1 S2}
  2.     local
  3.         fun{Reverse L Acc}
  4.             case L of H|T then
  5.                 if Acc==nil then {Reverse T H|nil}
  6.                 else {Reverse T H|Acc}
  7.                 end
  8.             else Acc
  9.             end
  10.         end
  11.         fun{Listo L1 L2 Prev LSol}
  12.             local
  13.                 X
  14.                 Y
  15.             in
  16.                 case L1#L2 of (I|T)#(J|V) then
  17.                     {FullAdder I J Prev X Y}
  18.                     {Listo T V X Y|LSol}
  19.                 else LSol#Prev
  20.                 end
  21.             end
  22.         end
  23.         fun{NListo L1 L2}
  24.                 case L1#L2 of (H|T)#(I|V) then
  25.                     {Listo {Reverse H nil} {Reverse I nil} 0 nil}|{NListo T V}
  26.                 else nil
  27.                 end
  28.         end
  29.     in
  30.         {NListo S1 S2}
  31.     end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement