jQuery in Action, 2nd edition*
The moose likes Scala and the fly likes Scala Coursera Week 7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Languages » Scala
Bookmark "Scala Coursera Week 7" Watch "Scala Coursera Week 7" New topic
Author

Scala Coursera Week 7

chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1617
    
  13

Materials not yet online - there's a warning of possible disruption due to the hurricane as the servers are in the USA.


No more Blub for me, thank you, Vicar.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30130
    
150

The lectures are up now.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

There is a case study. Would that be the assignment for this week?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1617
    
  13

Joe Harry wrote:There is a case study. Would that be the assignment for this week?

Not as far as I can tell. The case study is a detailed look at implementing a solution for the so-called "Water pouring problem" using lazy evaluation, Streams etc.

There is a forum for the Week 7 assignment, but no sign of the assignment yet. I'm guessing it's going to be tough, though!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

chris webster wrote:
Joe Harry wrote:There is a case study. Would that be the assignment for this week?

Not as far as I can tell. The case study is a detailed look at implementing a solution for the so-called "Water pouring problem" using lazy evaluation, Streams etc.

There is a forum for the Week 7 assignment, but no sign of the assignment yet. I'm guessing it's going to be tough, though!


Week7 will be about Streams!
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1617
    
  13

Joe Harry wrote:Week7 will be about Streams!

Have you looked at the assignment?
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4343
    
    8

chris webster wrote:Have you looked at the assignment?

Looks fun. Might have to wait till the weekend to have a proper crack at it, though.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

chris webster wrote:
Joe Harry wrote:Week7 will be about Streams!

Have you looked at the assignment?


Tomorrow I've got to get the combinations working correctly and after than I will take a look at Week7. We have time till 15th Nov for Week7 assignments.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Just took a look at the assignments for Week7. I definitely need some more hints. To start with: What is the terrainFunction doing? Could you guys give me additional explanation?
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4343
    
    8

Joe Harry wrote:What is the terrainFunction doing? Could you guys give me additional explanation?


terrain, declared in GameDef, should be a function that returns true if you're within the terrain, and false otherwise.

StringParserTerrain lets you define this terrain by giving a String in a particular form. This is parsed into a Vector of Vectors of Chars, and then terrainFunction takes this and returns a function that can be used for terrain.
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1617
    
  13

So, how's everybody doing with the Week 7 assignment? I'm just starting to look at the "from()" function and right now I can't make head() or tail() of it - I don't really understand what the input data actually represents. I think I need to review the "Water pouring" video to get some ideas.
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4343
    
    8

Finished it a couple of days ago (currently working on my Compilers course assignment).

I found it relatively straightforward until I hit from(). I tried a few approaches there that didn't work (though I suspect that some of them would if I'd got it right). But I tried it before watching the water pouring video. I found that to be a huge help - the from() method in that solution works in a very similar way.
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1617
    
  13

Matthew Brown wrote:Finished it a couple of days ago (currently working on my Compilers course assignment).

I found it relatively straightforward until I hit from(). I tried a few approaches there that didn't work (though I suspect that some of them would if I'd got it right). But I tried it before watching the water pouring video. I found that to be a huge help - the from() method in that solution works in a very similar way.

Excellent advice. I just finished, and the "water pouring" video was definitely the key to getting from() working (first time!).

Good luck with Compilers - I'm having a break from Coursera now to catch up with my OU course and Python. But I'll be back...
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30130
    
150

Got it. I made "from" so much more complicated than it needed to be the first time around! It was an interesting meandering journey though!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

I haven't looked at the assignment fully other that the first part. It was last Friday I had a look at them and only solved the first two tasks. I just gave me some time to relax as the deadline for this assignment is the 15th of this month. I will take a look at them tomorrow. Hope they are not as difficult as it was for Week6.
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1617
    
  13

Joe Harry wrote:I haven't looked at the assignment fully other that the first part. It was last Friday I had a look at them and only solved the first two tasks. I just gave me some time to relax as the deadline for this assignment is the 15th of this month. I will take a look at them tomorrow. Hope they are not as difficult as it was for Week6.

If you pay close attention to the hints in the assignment and source code, then it's not too bad. The "from()" method is a bit more difficult, but the water-pouring example is very helpful there. I found one of the biggest challenges on this assignment was making sense of the data structures we're given, and I definitely wouldn't have come up with this solution (or probably any solution) to the problem on my own. I still have plenty to learn about FP and Scala!
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1617
    
  13

Jeanne Boyarsky wrote:I made "from" so much more complicated than it needed to be the first time around! It was an interesting meandering journey though!

That pretty much sums up my experience of the entire course!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

chris webster wrote:
Joe Harry wrote:I haven't looked at the assignment fully other that the first part. It was last Friday I had a look at them and only solved the first two tasks. I just gave me some time to relax as the deadline for this assignment is the 15th of this month. I will take a look at them tomorrow. Hope they are not as difficult as it was for Week6.

If you pay close attention to the hints in the assignment and source code, then it's not too bad. The "from()" method is a bit more difficult, but the water-pouring example is very helpful there. I found one of the biggest challenges on this assignment was making sense of the data structures we're given, and I definitely wouldn't have come up with this solution (or probably any solution) to the problem on my own. I still have plenty to learn about FP and Scala!


That was something even I was thinking about. How would I have implemented the complete Game as an assignment. I would have done it, but it wouldn't be as concise as it is given out in the course.

Thanks for the hints. I will spend some time tomorrow evening and get this thing done hopefully. But you guys are here in case I need some help!
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30130
    
150

chris webster wrote:and I definitely wouldn't have come up with this solution (or probably any solution) to the problem on my own. I still have plenty to learn about FP and Scala!

Same here. It's like in any language that if someone spells out what to do, it isn't horribly difficult. But coming up with that design and decomposition requires more knowledge/experience.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Matthew Brown wrote:I found it relatively straightforward until I hit from().

Me too. I've been busy with other things so I haven't had the time and concentrate on the from() method yet. I'm going to have a look at it this weekend.
Wen Tong Lin
Greenhorn

Joined: Sep 29, 2012
Posts: 24
hi Guys. I was wondering if you can point me to the right direction with from() method. My solution is doing an infinite loop.

The flow is:
1) if "initial" is empty return Empty stream.
2) do a for comprehension with 2 generators.
a) generate from "initial" assigning it to x.
b) use x._1 and x._2 as parameter of neighborsWithHistory
c) use the value returned by b) as the first parameter of newNeighborsOnly, and second parameter is explored + h._1
d) assign c) to next, and yield it to a val more.
e) then return initial #:: from( more, explored) recursively

Any help will be greatly appreciated.

chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1617
    
  13

Wen Tong Lin wrote:hi Guys. I was wondering if you can point me to the right direction with from() method. My solution is doing an infinite loop.

The flow is:
1) if "initial" is empty return Empty stream.
2) do a for comprehension with 2 generators.
a) generate from "initial" assigning it to x.
b) use x._1 and x._2 as parameter of neighborsWithHistory
c) use the value returned by b) as the first parameter of newNeighborsOnly, and second parameter is explored + h._1
d) assign c) to next, and yield it to a val more.
e) then return initial #:: from( more, explored) recursively

Any help will be greatly appreciated.


I took the from() method in the "water pouring" exercise and used the same approach here. It looks like you're doing something very similar, but you may need to pay attention to exactly when/how you concatenate things onto your "initial" stream or onto the "explored" set.
HTH
Wen Tong Lin
Greenhorn

Joined: Sep 29, 2012
Posts: 24
Thank you Chris. I revised it, and it still does not pass the test case. I think the idea is, you get the initial.head and use newNeighborsOnly() and neighborsWithHistory() with "explored" to generate the possible paths. Then return
h #:: from(initial.tail #::: more, explored + h._1 ) recursively. am I missing something? I can't seem to hit the goal ( Pos(4,7) ). My pathsFromStart does not include the goal. I'll keep pondering. I know im very close to solving this.
Wen Tong Lin
Greenhorn

Joined: Sep 29, 2012
Posts: 24
Hi, guys. in terrainFunction() is 'S' and 'T' considered valid? meaning it should return true?
Wen Tong Lin
Greenhorn

Joined: Sep 29, 2012
Posts: 24
Hi guys. I got it now. My from() was right, after I got the tip from Chris (thank you Chris), and my problem was with terrainFunction() and neighborsWithHistory.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

I managed to complete the assignments. It was not so difficult as it was for Week6. Now the challenge is to keep up the gained knowledge and practice this daily. I do not work on Scala as part of my everyday job. I need to start using it in my private projects during my spare time.

Overall the course was really refreshing and I feel that I had leart Scala the proper way.
Wen Tong Lin
Greenhorn

Joined: Sep 29, 2012
Posts: 24
I didn't finish 2 assignments (Huffman and Anagram), but I learned a lot from this course. I am thinking of studying clojure or haskell though, to fully submerge myself with functional style. My mindset is still imperative. I agree that this course was really refreshing, and takes you out of your comfort zone (imperative OOD)
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

I'm almost there with Bloxorz, but working with these potentially infinitely long streams feels scary sometimes. In my mind I see the block rolling off into infinity...

My solution almost works, but I think I've got something wrong with the order of the elements in the result of from() - it finds a solution, but not the shortest path.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Finally, done!! Scored 10 out of 10.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Scala Coursera Week 7