Week 5 lunch meeting

169 views
Skip to first unread message

Cody Koeninger

unread,
Oct 23, 2012, 11:44:39 PM10/23/12
to austin-scala...@googlegroups.com
Anyone have strong preferences on location?  Billy's worked well enough for us.

Also, was anyone else annoyed by the "efficient" problems at the end of the Huffman exercises?  Given that I had already written a function from a tree and character to a list of bits, defining convert and mergeCodeTables seemed really redundant.  Maybe I missed the point of that one.

Dan Luu

unread,
Oct 24, 2012, 1:31:25 AM10/24/12
to austin-scala...@googlegroups.com
I doubt I can make it this week, so anywhere's fine with me :-).

I haven't gotten there yet; I guess I'll have plenty of time to be annoyed tomorrow. I haven't watched the week 5 lectures yet, but I assume they cover list/collection methods like length, map, sortBy, etc.? I've been using those all over.

John Cohorn

unread,
Oct 24, 2012, 8:33:47 AM10/24/12
to austin-scala...@googlegroups.com
Can't make it this week, in ATL until Friday. Billy's was good though.

Some of the last exercise steps were definitely confusingly short. mergeCodeTables was not just one line, but one operator...

The week 5 and 6 videos do go over a lot of the higher order list functions so I assume they were fine to use in this one. filter and partition really cleaned up some of my huffman methods and foldLeft has been indispensable.

Brad Peterson

unread,
Oct 24, 2012, 4:16:33 PM10/24/12
to austin-scala...@googlegroups.com
I think they imagined convert would be a recursive tree-traversal with mergeCodeTables somehow building up the list of bits as the smaller tables are combined.  I never figured out how what they were hinting at.  I did originally have convert as a recursive tree-walk, with mergeCodeTables just concatting.  But convert can be done easily and directly, not using mergeCodeTables at all.

Norman Richards

unread,
Oct 24, 2012, 4:32:26 PM10/24/12
to austin-scala...@googlegroups.com
On Wed, Oct 24, 2012 at 3:16 PM, Brad Peterson <des...@gmail.com> wrote:
> I think they imagined convert would be a recursive tree-traversal with
> mergeCodeTables somehow building up the list of bits as the smaller tables
> are combined. I never figured out how what they were hinting at. [...]

The code is a couple weeks old, but this is what I assumed they were
trying for:

def convert(tree: CodeTree): CodeTable =
tree match {
case Leaf(c,_) => List((c,List()))
case Fork(l,r,_,_) => mergeCodeTables(convert(l), convert(r))
}

def mergeCodeTables(a: CodeTable, b: CodeTable): CodeTable = {
def prepend(x:Bit)(pair:(Char, List[Bit])):(Char, List[Bit]) =
(pair._1, x :: pair._2)

a.map(prepend(0)) ++ b.map(prepend(1))
}


That prepend function looks a bit ugly in retrospect....

Dan Luu

unread,
Oct 24, 2012, 5:57:28 PM10/24/12
to austin-scala...@googlegroups.com
There's something I don't understand about the test suite for week 5, or perhaps it's something I don't understand with eclipse.

I stupidly did my encode by pasting my decode function and then editing it, so of course I ended up with a part that wasn't modified correctly. There's no way the function could possibly have terminated (for any input), which I found out after I added my own tests. But, it initially passed their tests, which includes this test: 
   assert(decode(frenchCode, encode(frenchCode)("ab".toList)) === "ab".toList)

And my worksheet hung if I just copied the "encode(frenchCode)("ab".toList)" part of it to the worksheet. How could the test suite have passed?

Also, I keep getting random eclipse errors that don't make sense, e.g., I got an error on this line of my worksheet:
import patmat.Huffman._
which said that Huffman wasn't part of patmat. Cutting the line, saving, then pasting the line back and saving again caused the error to go away.

It seems like, about 2% of the time, when I save, I get a spurious error that goes away if I do some arbitrary manipulation to the text and save again. Is scala for eclipse known to be buggy? I've never used eclipse before, so I'm not sure if this is something I should expect.

Brad Peterson

unread,
Oct 24, 2012, 6:55:12 PM10/24/12
to austin-scala...@googlegroups.com
Did you update the worksheet to the new version that came out this week?  One of the bugs they fixed sounds like what you're describing.

Dan Luu

unread,
Oct 24, 2012, 6:59:30 PM10/24/12
to austin-scala...@googlegroups.com
Thanks for the suggestion! I hadn't updated (I tried for about half an hour to figure out why the update wasn't downloading the last time they said to update, only to find out that they erroneously thought the update had been released, and I haven't looked at the front page since then). 

Norman Richards

unread,
Oct 24, 2012, 10:10:27 PM10/24/12
to austin-scala...@googlegroups.com
On Tue, Oct 23, 2012 at 10:44 PM, Cody Koeninger <co...@koeninger.org> wrote:
> Anyone have strong preferences on location? Billy's worked well enough for
> us.

I have an appointment this friday, so I'm unfortunately out. Billy's
was good. Was at Conan's pizza on anserson recently for lunch - they
have plenty of big open tables that would work well too I think, if
people want a change of pace.

Cody Koeninger

unread,
Oct 25, 2012, 12:49:42 AM10/25/12
to austin-scala...@googlegroups.com
On Wed, Oct 24, 2012 at 9:10 PM, Norman Richards <o...@nostacktrace.com> wrote:
> I have an appointment this friday, so I'm unfortunately out. Billy's
> was good. Was at Conan's pizza on anserson recently for lunch - they
> have plenty of big open tables that would work well too I think, if
> people want a change of pace.


Ok, with 3 people out, I think we'll just default to Austin Java for
this friday. Anderson Conans sounds good to me for the week after,
though.
Reply all
Reply to author
Forward
0 new messages