Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. declare
  2. fun{Modes L}
  3. local fun{Flatten L}
  4. case L
  5. of nil then nil
  6. [] nil|T then {Flatten T}
  7. [] (H1|T1)|T then {Flatten H1|T1|T}
  8. [] X|T then X | {Flatten T}
  9. [] X then X
  10. end
  11. end
  12. fun{AddPlus L M}
  13. if L.2 == nil then {Flatten M|L.1|nil}
  14. elseif L.1>L.2.1 then {AddMoins L.2 M|L.1}
  15. else {AddPlus L.2 M}
  16. end
  17. end
  18. fun{AddMoins L M}
  19. if L.2==nil then {Flatten M|L.1|nil}
  20. elseif L.1<L.2.1 then {AddPlus L.2 M}
  21. else {AddMoins L.2 M}
  22. end
  23. end
  24. M
  25. Fct
  26. in
  27. fun{Fct L M}
  28. {Flatten {AddPlus L M}}
  29. end
  30. {Fct L nil}
  31. end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement