Advertisement
Lucassim

Queue

Jul 16th, 2013
2,457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Oz 0.59 KB | None | 0 0
  1. declare
  2.  
  3. fun {Append L V}
  4.    case L of
  5.       nil then [V]
  6.    [] X|Xr then
  7.       X|{Append Xr V}
  8.    end
  9. end
  10.  
  11.  
  12.  
  13.    
  14. class Cola\4
  15.    attr
  16.       L
  17.    meth inic
  18.       L:=nil
  19.    end
  20.  
  21.    meth push(Val)
  22.       L:={Append @L Val}
  23.    end
  24.  
  25.    meth pop(?Val)
  26.       case @L of
  27.      nil then Val=nil
  28.       [] X|Xr then
  29.      Val=X
  30.      L:=Xr
  31.       end
  32.    end
  33.  
  34.  
  35.    meth browse
  36.       {Browse @L}
  37.    end
  38.    
  39.    
  40. end
  41.  
  42. declare C={New Cola inic}
  43. {C push(1)}
  44. {C push(2)}
  45. {C push(3)}
  46. {C browse}
  47.  
  48. local A B in
  49. {C pop(A)}
  50.    {C browse}
  51.    {C pop(B)}
  52. {C browse}
  53.    {Browse A#B}
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement