Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Propiedades:
- datatype cola= elem of int list;
- val emptyQ = elem([]);
- firstQ (queue emptyQ x) = x
- firstQ (queue (queue q y) x) = y
- dequeue (queue emptyQ x) = empty
- isEmptyQ emptyQ = True
- isEmpty (queue (emptyQ x)) = false
- dequeue empty y firstQ empty no están definidos
- Implementación:
- fun firstQ (elem([])) = raise excep
- | firstQ (elem(a::b)) = a;
- fun queue (elem([]), y) = elem([y])
- | queue (elem([x]), y) = elem([x]@[y])
- | queue (elem(x::z), y) = elem(x::Z@[y]);
- fun dequeue (elem([])) = raise excep
- | dequeue (elem([a])) = emptyQ
- | dequeue (elem(a::b)) = elem(b);
- fun isEmpty (elem([])) = true
- | isEmpty (elem(a)) = false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement