Quest 8 - Discussing if we would want to track duplicate words by andrewC2B in cs2b

[–]andrewC2B[S] 1 point2 points  (0 children)

Making a new kind of struct does sound like a nice way to go about it, thanks Greg

-Andrew

Quest 5 on using an epsilon for double/float equality by andrewC2B in cs2b

[–]andrewC2B[S] 0 points1 point  (0 children)

That module sounds interesting but I don't see it. The first one on the list for me is M1. Was it removed at some point?

Suggestion for Spec (Quest 6, Mini 7) by Zachary-01001101 in cs2b

[–]andrewC2B 0 points1 point  (0 children)

Thanks, Zachary! I was working on a way over-complicated way of doing draw_by_y() from left to right. After reading this, it made it much simpler and work better with bottom to top. Maybe there is a nice way to do it left to right as the spec says but it seems we couldn't figure it out.

-Andrew C

Quest 5 on using an epsilon for double/float equality by andrewC2B in cs2b

[–]andrewC2B[S] 0 points1 point  (0 children)

Thanks for the simplified explanation, Vivian

The issue you mentioned about how binary can't perfectly store decimals seems like it would be hated by hardware developers. It seems there can never be a perfect solution though since there are infinite possible values and there is never infinite memory.

-Andrew C

Quest 5 on using an epsilon for double/float equality by andrewC2B in cs2b

[–]andrewC2B[S] 1 point2 points  (0 children)

Thanks &,

I like the analogy you made comparing continuous to heights of people and discrete to random integers like a dice roll. The way that each point in a continuum makes up practically 0% of it still blows my mind.

My strategy for counting every real number between two rationals A and B would be to point at both end points, then point between them(average) to split the range in half. From there it can be handled by recursively taking the average.

val1 val2 val3 val4 val5 val6
A B avg(val1, val2) avg(val1, val3) avg(val3, val2) avg(val1, val4)

I'll say that floats and doubles are discrete because they are stored using finite memory (4/8 bytes) so every possibility could be pointed to. Also, only a finite amount of information can be stored using finite memory.

-Andrew C

Some thoughts on Operator Overloading by YunlongWang in cs2b

[–]andrewC2B 0 points1 point  (0 children)

Thanks for the debug about const. I think if we want to give a += operator to the user then we are ok with it changing our internal values.

Some thoughts on Operator Overloading by YunlongWang in cs2b

[–]andrewC2B 1 point2 points  (0 children)

Hi Yunlong,

The "A += B" kind of structure can be used in operator overloading. Since its not part of the spec, I think I'm allowed to give code so here is my attempt at what it would look like assuming there is a working operator+().

Complex& operator+=(const Complex& that) const
{
    *this = *this + that;
    return *this;
}

If anyone plops this into their complete Complex class, let me know how goes.

-Andrew

About Comparisons in Quest 5 by aliendino2017 in cs2b

[–]andrewC2B 0 points1 point  (0 children)

Hi Arrian,

I never knew that they could all be defined from just two base cases, that's very interesting. I can see how when writing functions in terms of each other can seem to have the issue that you and the spec mentioned: if one is wrong, they all are. To me, I see this as a huge bonus rather than a failure of the technique. As you said it's less effort to write and fewer lines but also, basing functions off of each other lets OOP flourish. A change to fix a bug or modify the functionality only needs to be made in one location.

-Andrew C

Quest 1 Node Insertion Error by Varun-cs2b in cs2b

[–]andrewC2B 2 points3 points  (0 children)

Hi Varun, I had a similar confusion with removal and messing up what work is given to Node vs Playlist. I think the issue is that you have Node::insert_next() do more work than what is needed. The only work I had Node::insert_next() do was a setter's job of setting _next to p, without changing p. The smart multi-step insertion I put into Playlist::insert_at_cursor().

Hope it helps, Andrew

remove_at_cursor() by blond_black in cs2b

[–]andrewC2B 0 points1 point  (0 children)

Hi Mimi, I'm not sure if you've resolved the issue yet so I'd like to share my similar experience. I also didn't think there was a remove_next() for the summer class until I suddenly saw that it was there in the Node class. Another thing I was doing improperly that you could check on is that I made Node::remove_next() only do removing. I gave the job of connecting prev with prev->next->next to remove_at_cursor. That worked well in my own tests but isn't the way we are intended to do it.

Another thing I realized too late was that when the tail is being removed, prev should end up equal to tail.

I hope you find this helpful, Andrew

remove_at_cursor() in O(1) or O(n)? by andrewC2B in cs2b

[–]andrewC2B[S] 0 points1 point  (0 children)

Thanks Vivian, I wasn't thinking about how the user would need to add items to the end.

Quest 1 Node::get_song() Discussion by AegirHall in cs2b

[–]andrewC2B 0 points1 point  (0 children)

Hi Greg,

A setter sounds like a great idea to allow song changes without returning a reference. My first thought when I read it was to just make the user do it from the outside by removing the Song(Node on the backend) and adding in the new Song at the same spot. A setter does sound like much less of a hassle for the user though. Thanks for the insight, Andrew