On 25 Sep 2008, at 06:11, Matthew Eastman wrote:
Hey guys,
This is probably more of a question about functional programming
than it is about Haskell, but hopefully you can help me out. I'm new
to thinking about things in a functional way so I'm not sure what
the best way to do some
Matthew Brecknell wrote:
Matthew Eastman said:
i.e. popping Blue in [Red, Red, Blue, Red, Blue] would give [Red,
Red,
Blue]
Hmm, did you mean [Red,Blue] or [Red,Red,Red,Blue]? Judging by your
implementation of remUseless, I'm guessing the latter.
Yes, I meant the latter. Popping Blue in
Thomas Davie wrote:
In this interprettation, here's what I think is an O(1)
implementation:
...
rbPop :: Colour - RBStack a - RBStack a
rbPop c Empty = error Empty Stack, can't pop
rbPop c (More c' v asCs nextNonC)
| c == c' = asCs
| otherwise = rbPop c nextNonC
...
Your pop doesn't
Matthew Eastman said:
i.e. popping Blue in [Red, Red, Blue, Red, Blue] would give [Red, Red,
Blue]
Hmm, did you mean [Red,Blue] or [Red,Red,Red,Blue]? Judging by your
implementation of remUseless, I'm guessing the latter.
Here is a more straightforward approach than apfelmus'. I store
On Thu, 2008-09-25 at 00:11 -0400, Matthew Eastman wrote:
Hey guys,
This is probably more of a question about functional programming than
it is about Haskell, but hopefully you can help me out. I'm new to
thinking about things in a functional way so I'm not sure what the
best way to
Hey guys,
This is probably more of a question about functional programming than
it is about Haskell, but hopefully you can help me out. I'm new to
thinking about things in a functional way so I'm not sure what the
best way to do some things are.
I'm in a data structures course right now,
Try writing
data RBStack = RBS [RBSItem] [RBSItem]
where the first list are all the same colour and the start of the
second list is a different colour. The rest should follow naturally
and you will get amortised O(1) push and pop (you occasionally have to
juggle the lists).
By the way, for this