On 11/18/2013 04:37 AM, Waldek Hebisch wrote:
> Clearly the code is messed up. There are already destructive
> versions, namely 'extractTop!' and 'extractBottom!'. And there
> is nondestructive 'top'. So we should remove 'top!' and
> rename 'bottom!' to 'bottom'.
Right.
> Well, actually just remove 'dequeue' from category and argumentless
> 'dequeue' completely.
That's what I meant. But when I wrote my first mail, I had the
impression that you not only wanted to remove bag: List(L) -> %, but
also all the other functions that where called after their domain names
(just with small initial letter).
In your response you clarified that you only intended to and did remove
the 'bag' function.
Your comment above confuses me a bit.
I'm somehow still in favour of removing such functions, because one can
have several implementations of a stack which all fulfill the same
category requirements of StackAggregate. Having constructor names like
stack, arrayStack, etc. derived from the domain name pollutes the
namespace and it makes no sense to put such names into the generic
category. In other words, the generic 'construct' is needed anyway.
Ah, but you left 'dequeue' in the domain.
Dequeue(S : SetCategory) : DequeueAggregate S with
dequeue : List S -> %
++ dequeue([x, y, ..., z]) creates a dequeue with first (top or
front)
++ element x, second element y, ..., and last (bottom or back)
element z.
== Queue S add
...
dequeue d == construct(d)
Looks like you want to remove from the category but not from the domain.
Well, I would be more radical, but I can live with your proposal then.
> Attached is a patch implementing missing functions.
I'm not completely satisfied. The reason lies here:
++ A dequeue is a doubly ended stack, that is, a bag where first items
++ inserted are the first items extracted, at either the front or the
++ back end of the data structure.
DequeueAggregate(S : Type):
Category == Join(StackAggregate S, QueueAggregate S) with
It shouldn't inherit from StackAggregate, because that would violate the
specification. Compare with
++ A stack is a bag where the last item inserted is the first item
++ extracted.
StackAggregate(S : Type) : Category ==
Join(BagAggregate S, finiteAggregate) wit
Stack is LIFO, but Dequeue is FIFO.
I'm not really against that Dequeue inherits from Stack, but (of course)
then there shouldn't be a definition of
Rep := Reference List S
in the 'add' body. Only Rep:=Stack(S).
Ralf
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/groups/opt_out.