Advertisement
juaniisuar

Untitled

May 10th, 2015
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. Propiedades:
  2. datatype cola= elem of int list;
  3. val emptyQ = elem([]);
  4.  
  5. firstQ (queue emptyQ x) = x
  6. firstQ (queue (queue q y) x) = y
  7. dequeue (queue emptyQ x) = empty
  8. isEmptyQ emptyQ = True
  9. isEmpty (queue (emptyQ x)) = false
  10. dequeue empty y firstQ empty no están definidos
  11.  
  12. Implementación:
  13. fun firstQ (elem([])) = raise excep
  14. | firstQ (elem(a::b)) = a;
  15.  
  16. fun queue (elem([]), y) = elem([y])
  17. | queue (elem([x]), y) = elem([x]@[y])
  18. | queue (elem(x::z), y) = elem(x::Z@[y]);
  19.  
  20. fun dequeue (elem([])) = raise excep
  21. | dequeue (elem([a])) = emptyQ
  22. | dequeue (elem(a::b)) = elem(b);
  23.  
  24. fun isEmpty (elem([])) = true
  25. | isEmpty (elem(a)) = false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement