forked from pbassiner/coursera_progfun-004_materials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassignment.html
380 lines (303 loc) · 44 KB
/
assignment.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<!DOCTYPE html>
<html class="supports-svg" xmlns:fb="http://ogp.me/ns/fb#" itemtype="http://schema.org"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=IE7"><meta name="fragment" content="!"><meta name="robots" content="NOODP"><meta charset="utf-8"><meta property="og:title" content="Coursera"><meta property="og:type" content="website"><meta property="og:image" content="http://s3.amazonaws.com/coursera/media/Coursera_Computer_Narrow.png"><meta property="og:url" content="https://www.coursera.org/assignment/view?assignment_id=9"><meta property="og:site_name" content="Coursera"><meta property="og:locale" content="en_US"><meta property="og:description" content="Take free online classes from 80+ top universities and organizations. Coursera is a social entrepreneurship company partnering with Stanford University, Yale University, Princeton University and others around the world to offer courses online for anyone to take, for free. We believe in connecting people to a great education so that anyone around the world can learn without limits."><meta property="fb:admins" content="727836538,4807654"><meta property="fb:app_id" content="274998519252278"><meta name="twitter:site" content="Coursera"><meta name="twitter:app:name:iphone" content="Coursera"><meta name="twitter:app:name:ipad" content="Coursera"><meta name="twitter:app:name:googleplay" content="Coursera"><meta name="twitter:app:id:iphone" content="id736535961"><meta name="twitter:app:id:ipad" content="id736535961"><meta name="twitter:app:id:googleplay" content="org.coursera.android"><meta name="description" content="Take free online classes from 80+ top universities and organizations. Coursera is a social entrepreneurship company partnering with Stanford University, Yale University, Princeton University and others around the world to offer courses online for anyone to take, for free. We believe in connecting people to a great education so that anyone around the world can learn without limits."><meta name="image" content="http://s3.amazonaws.com/coursera/media/Coursera_Computer_Narrow.png"><meta name="apple-itunes-app" content="app-id=736535961"><title>Coursera</title> <link href="assignment_files/spark.css" rel="stylesheet" type="text/css">
<link href="assignment_files/course.asc" rel="stylesheet" type="text/css">
<link href="https://spark-public.s3.amazonaws.com/progfun/static/images/favicon.ico" rel="icon">
<script src="assignment_files/ga.js" async="" type="text/javascript"></script><script src="assignment_files/MathJax.js" type="text/javascript"></script><script src="assignment_files/routes.js" data-requiremodule="pages/spark/routes" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><style type="text/css">.MathJax_Preview {color: #888}
#MathJax_Message {position: fixed; left: 1px; bottom: 2px; background-color: #E6E6E6; border: 1px solid #959595; margin: 0px; padding: 2px 8px; z-index: 102; color: black; font-size: 80%; width: auto; white-space: nowrap}
#MathJax_MSIE_Frame {position: absolute; top: 0; left: 0; width: 0px; z-index: 101; border: 0px; margin: 0px; padding: 0px}
.MathJax_Error {color: #CC0000; font-style: italic}
</style><meta content="summary" name="twitter:card"><meta content="Coursera" name="twitter:title"><meta content="Take free online classes from 80+ top universities and organizations. Coursera is a social entrepreneurship company partnering with Stanford University, Yale University, Princeton University and others around the world to offer courses online for anyone to take, for free. We believe in connecting people to a great education so that anyone around the world can learn without limits." name="twitter:description"><meta content="http://s3.amazonaws.com/coursera/media/Coursera_Computer_Narrow.png" name="twitter:image:src"><script src="assignment_files/204.js" data-requiremodule="js/lib/204" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/400.js" data-requiremodule="js/lib/400" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/student-page_003.js" data-requiremodule="pages/spark/views/template/student-page" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/student-page_002.js" data-requiremodule="pages/spark/views/template/student-page.html" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/sparkSurveyQuestionsSessionModel.js" data-requiremodule="bundles/assess/assessmentTypes/sparkSurveyQuestions/sparkSurveyQuestionsSessionModel" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/sessionModel.js" data-requiremodule="bundles/assess/assessmentTypes/quickQuestions/sessionModel" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/student-page.js" data-requiremodule="pages/spark/views/template/nls/student-page" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/SessionModel.js" data-requiremodule="bundles/assess/assessmentTypes/SessionModel" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/QuestionCollection.js" data-requiremodule="bundles/assess/framework/QuestionCollection" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/QuestionModel.js" data-requiremodule="bundles/assess/framework/QuestionModel" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/backbone.js" data-requiremodule="bundles/assess/lib/backbone.hascollections" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/underscore.js" data-requiremodule="js/lib/underscore.extend" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/header.js" data-requiremodule="pages/spark/views/template/header" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/sidebar_002.js" data-requiremodule="pages/spark/views/template/sidebar" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><style type="text/css">#MathJax_About {position: fixed; left: 50%; width: auto; text-align: center; border: 3px outset; padding: 1em 2em; background-color: #DDDDDD; color: black; cursor: default; font-family: message-box; font-size: 120%; font-style: normal; text-indent: 0; text-transform: none; line-height: normal; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; z-index: 201; border-radius: 15px; -webkit-border-radius: 15px; -moz-border-radius: 15px; -khtml-border-radius: 15px; box-shadow: 0px 10px 20px #808080; -webkit-box-shadow: 0px 10px 20px #808080; -moz-box-shadow: 0px 10px 20px #808080; -khtml-box-shadow: 0px 10px 20px #808080; filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')}
.MathJax_Menu {position: absolute; background-color: white; color: black; width: auto; padding: 5px 0px; border: 1px solid #CCCCCC; margin: 0; cursor: default; font: menu; text-align: left; text-indent: 0; text-transform: none; line-height: normal; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; z-index: 201; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; -khtml-border-radius: 5px; box-shadow: 0px 10px 20px #808080; -webkit-box-shadow: 0px 10px 20px #808080; -moz-box-shadow: 0px 10px 20px #808080; -khtml-box-shadow: 0px 10px 20px #808080; filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')}
.MathJax_MenuItem {padding: 1px 2em; background: transparent}
.MathJax_MenuTitle {background-color: #CCCCCC; margin: -5px 0 0 0; text-align: center; font-style: italic; font-size: 80%; color: #444444; padding: 2px 0; overflow: hidden}
.MathJax_MenuArrow {position: absolute; right: .5em; color: #666666}
.MathJax_MenuActive .MathJax_MenuArrow {color: white}
.MathJax_MenuCheck {position: absolute; left: .7em}
.MathJax_MenuRadioCheck {position: absolute; left: .7em}
.MathJax_MenuLabel {padding: 1px 2em 3px 1.33em; font-style: italic}
.MathJax_MenuRule {border-top: 1px solid #DDDDDD; margin: 4px 3px}
.MathJax_MenuDisabled {color: GrayText}
.MathJax_MenuActive {background-color: #606872; color: white}
.MathJax_Menu_Close {position: absolute; width: 31px; height: 31px; top: -15px; left: -15px}
</style><script src="assignment_files/readme.js" data-requiremodule="js/lib/readme" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/header_002.js" data-requiremodule="pages/spark/views/template/header.html" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/LearnerStoriesCollection.js" data-requiremodule="pages/analytics/models/LearnerStoriesCollection" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/header_003.js" data-requiremodule="pages/spark/views/template/nls/header" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/LearnerStoryModel.js" data-requiremodule="pages/analytics/models/LearnerStoryModel" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/assessApi.js" data-requiremodule="pages/spark-survey/assessApi" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/sidebar.js" data-requiremodule="pages/spark/views/template/sidebar.html" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/signature_track.js" data-requiremodule="spark/app/signature/js/signature_track" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/sidebar_003.js" data-requiremodule="pages/spark/views/template/nls/sidebar" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/signatureTrackLastChanceModal.js" data-requiremodule="spark/app/signature/js/signatureTrackLastChanceModal.html" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/flexjoinLastChanceModal.js" data-requiremodule="spark/app/signature/js/flexjoinLastChanceModal.html" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/util.js" data-requiremodule="js/lib/util" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><script src="assignment_files/path.js" data-requiremodule="js/lib/path" data-requirecontext="_" async="" charset="utf-8" type="text/javascript"></script><style type="text/css">#MathJax_Zoom {position: absolute; background-color: #F0F0F0; overflow: auto; display: block; z-index: 301; padding: .5em; border: 1px solid black; margin: 0; font-weight: normal; font-style: normal; text-align: left; text-indent: 0; text-transform: none; line-height: normal; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; box-shadow: 5px 5px 15px #AAAAAA; -webkit-box-shadow: 5px 5px 15px #AAAAAA; -moz-box-shadow: 5px 5px 15px #AAAAAA; -khtml-box-shadow: 5px 5px 15px #AAAAAA; filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')}
#MathJax_ZoomOverlay {position: absolute; left: 0; top: 0; z-index: 300; display: inline-block; width: 100%; height: 100%; border: 0; padding: 0; margin: 0; background-color: white; opacity: 0; filter: alpha(opacity=0)}
#MathJax_ZoomEventTrap {position: absolute; left: 0; top: 0; z-index: 302; display: inline-block; border: 0; padding: 0; margin: 0; background-color: white; opacity: 0; filter: alpha(opacity=0)}
</style></head><body><div style="display: none;" id="MathJax_Message"></div><div id="fb-root"></div><div id="spark-help" class="hide"></div><a href="https://learner.coursera.help/hc/requests/new" target="_blank"><div style="z-index: 1" data-networkprioritysupportwidget="" role="button" class="helpwidget-tab hide">Premium Support</div></a><!-- - track IE8 and less browser for eventing purposes--><!--[if lte IE 8]><script>window._204 = window._204 || [];
window._gaq = window._gaq || [];
window._gaq.push(
['_setAccount', 'UA-28377374-1'],
['_setDomainName', window.location.hostname],
['_setAllowLinker', true],
['_trackPageview', window.location.pathname]);
window._204.push(
['client', 'home'],
{key:"pageview", value:window.location.pathname});</script><script src="https://dw0ugk4msqulk.cloudfront.net/61a7c1335d196f1295e3341330ed120d255fe89d/js/lib/204.js"></script><script src="https://ssl.google-analytics.com/ga.js"></script><![endif]--><div id="fb-root"></div><div id="origami" data-js="origami"><div><div><div class="coursera-page"><div class="coursera-header" role="menubar"><div class="hidden">This page features MathJax technology to render mathematical formulae.
If you are using a screen reader, please visit <a href="http://www.dessci.com/en/products/mathplayer/">MathPlayer</a> to download the plugin for your browser. Please note that this is an Internet Explorer-only plugin at this time.</div><h1 class="hidden">Functional Programming Principles in Scala</h1><!-- UNTIL dashboard announcement expires 2014-12-01 (then delete this code)--><div role="banner" class="course-topbar container-fluid"><div class="row-fluid"><div class="span3"><a href="https://www.coursera.org/" data-if-linkable="add-referrer" class="course-topbar-logo"></a></div><div style="float:right;" class="course-topbar-nav-container span9"><h2 class="hidden">Top Navigation Bar</h2><ul class="course-topbar-nav-list"><li class="course-topbar-nav-list-item"><a href="https://www.coursera.org/courses" data-if-linkable="add-referrer">Courses</a></li><li tabindex="0" role="button" aria-haspopup="true" aria-expanded="false" aria-owns="course-topbar-my" data-popup="#course-topbar-my" data-popup-bind-open="mouseenter" data-popup-close="data-popup-close" style="cursor:pointer;" data-popup-direction="se" class="course-topbar-nav-list-item"><a data-user-id="4452529">Pol Bassiner<i class="icon-caret-down"></i></a></li></ul></div></div><div id="course-topbar-aboutus" class="course-topbar-sublist"><a href="https://www.coursera.org//about/" target="_new" data-if-linkable="add-referrer" class="internal-about course-topbar-sublist-item">About Us</a><a href="https://www.coursera.org//about/careers" target="_new" data-if-linkable="add-referrer" class="internal-about course-topbar-sublist-item">Careers</a><a href="https://www.coursera.org//about/people" target="_new" data-if-linkable="add-referrer" class="internal-about course-topbar-sublist-item">People</a><a href="https://www.coursera.org//about/contact" target="_new" data-if-linkable="add-referrer" class="internal-about course-topbar-sublist-item">Contact Us</a></div><div id="course-topbar-my" class="course-topbar-sublist"><a data-popup-close="data-popup-close" href="https://www.coursera.org/" target="_new" class="course-topbar-sublist-item">My Courses</a><a data-popup-close="data-popup-close" href="https://www.coursera.org/account/profile" target="_new" class="course-topbar-sublist-item">Profile</a><a data-popup-close="data-popup-close" href="https://www.coursera.org/account/accomplishments" target="_new" class="course-topbar-sublist-item">Course Records</a><a href="https://www.coursera.org/account/settings" target="_new" class="course-topbar-sublist-item">Settings</a><a href="https://class.coursera.org/progfun-004/class/preferences" class="course-topbar-sublist-item">Course Preferences</a><form action="/api/logoutSsr/v1?csrf3-token=1466229970.ZrUTwtrgt5rjI53y" method="post"><button data-popup-close="data-popup-close" type="submit" class="course-topbar-sublist-item">Sign Out</button></form></div></div><div class="course-topbanner-wrapper"><div class="course-topbanner"><div class="course-topbanner-university-logo"><a href="https://www.coursera.org/epfl" target="_blank" data-if-linkable="add-referrer" title="https://www.coursera.org/epfl" class="coursera-university-color"><img src="assignment_files/university_logo.asc" alt="epfl"></a></div><h1 class="course-topbanner-header"><a href="https://class.coursera.org/progfun-004/" data-if-linkable="modal-lock" class="course-topbanner-name coursera-university-color">Functional Programming Principles in Scala</a><br><span style="" class="course-topbanner-instructor">by </span></h1></div></div></div><div style="position:relative;" class="container-fluid"><div class="row-fluid"><div id="course-page-sidebar" role="navigation"><div class="coursera-sidebar" role="menubar"><div id="course-page-sidebar" role="navigation"><div class="course-navbar-container"><a href="https://class.coursera.org/progfun-004" data-ab-user-convert-for="honorcode_to_welcome2" data-ab-user-convert="navclick_index"><img src="assignment_files/logo.asc" style="width: 205px;height: 116px;margin: -15px 0px 8px 1px; box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.05);" alt="Course Home Page"></a><div data-coursera-course-search-nav-widget="data-coursera-course-search-nav-widget" class="input-append course-search-nav-box"><form method="get" action="/progfun-004/class/search" data-js-search-form="data-js-search-form" class="form-inline minimized-search"><label for="course-search-nav-input" class="accessible-text-for-reader">Search this course</label><input id="course-search-nav-input" name="q" data-js-search-input="data-js-search-input" type="text"> <button type="submit" data-ab-user-convert-for="honorcode_to_welcome2" data-ab-user-convert="search" class="btn icon-search"><span class="accessible-text-for-reader">Search</span></button></form></div><h2 class="hidden">Side Navigation Bar</h2><ul class="course-navbar-list"><li class="course-navbar-item"><a href="https://class.coursera.org/progfun-004/class/index" data-if-linkable="modal-lock,gray,lock-icon" data-ab-user-convert-for="honorcode_to_welcome2" data-ab-user-convert="navclick_Home" class="coursera-university-color"><span>Home </span><span></span></a></li><li class="course-navbar-item"></li><li class="course-navbar-item"><a href="https://class.coursera.org/progfun-004/lecture/index" data-if-linkable="modal-lock,gray,lock-icon" data-ab-user-convert-for="honorcode_to_welcome2" data-ab-user-convert="navclick_Video_Lectures" class="coursera-university-color"><span>Video Lectures </span><span></span></a></li><li class="course-navbar-item"><a href="https://class.coursera.org/progfun-004/wiki/LearningResources" data-if-linkable="modal-lock,gray,lock-icon" data-ab-user-convert-for="honorcode_to_welcome2" data-ab-user-convert="navclick_Learning_Resources" class="coursera-university-color"><span>Learning Resources </span><span></span></a></li><li class="course-navbar-item"><a href="https://class.coursera.org/progfun-004/assignment/index" data-if-linkable="modal-lock,gray,lock-icon" data-ab-user-convert-for="honorcode_to_welcome2" data-ab-user-convert="navclick_Assignments" class="coursera-university-color"><span>Assignments </span><span></span></a></li><li class="course-navbar-item"></li><li class="course-navbar-item"><a href="https://class.coursera.org/progfun-004/forum/index" data-if-linkable="modal-lock,gray,lock-icon" data-ab-user-convert-for="honorcode_to_welcome2" data-ab-user-convert="navclick_Discussion_Forums" class="coursera-university-color"><span>Discussion Forums </span><span></span></a></li><li class="course-navbar-item"></li><li class="course-navbar-item"><a href="https://class.coursera.org/progfun-004/wiki/ToolsSetup" data-if-linkable="modal-lock,gray,lock-icon" data-ab-user-convert-for="honorcode_to_welcome2" data-ab-user-convert="navclick_Tools_Setup" class="coursera-university-color"><span>Tools Setup </span><span></span></a></li><li class="course-navbar-item"><a href="https://class.coursera.org/progfun-004/wiki/SbtTutorial" data-if-linkable="modal-lock,gray,lock-icon" data-ab-user-convert-for="honorcode_to_welcome2" data-ab-user-convert="navclick_Sbt_Tutorial" class="coursera-university-color"><span>Sbt Tutorial </span><span></span></a></li><li class="course-navbar-item"><a href="https://share.coursera.org/wiki/index.php/Progfun:sbt" data-if-linkable="modal-lock,gray,lock-icon" data-ab-user-convert-for="honorcode_to_welcome2" data-ab-user-convert="navclick_SBT_FAQ" class="coursera-university-color"><span>SBT FAQ </span><span></span></a></li><li class="course-navbar-item"><a href="https://class.coursera.org/progfun-004/wiki/EclipseTutorial" data-if-linkable="modal-lock,gray,lock-icon" data-ab-user-convert-for="honorcode_to_welcome2" data-ab-user-convert="navclick_Eclipse_Tutorial" class="coursera-university-color"><span>Eclipse Tutorial </span><span></span></a></li><li class="course-navbar-item"><a href="https://class.coursera.org/progfun-004/wiki/IntelliJ_IDEA" data-if-linkable="modal-lock,gray,lock-icon" data-ab-user-convert-for="honorcode_to_welcome2" data-ab-user-convert="navclick_IntelliJ_IDEA_Tutorial_(optional_alternative_IDE)" class="coursera-university-color"><span>IntelliJ IDEA Tutorial (optional alternative IDE) </span><span></span></a></li><li class="course-navbar-item"><a href="https://class.coursera.org/progfun-004/wiki/ScalaTutorial" data-if-linkable="modal-lock,gray,lock-icon" data-ab-user-convert-for="honorcode_to_welcome2" data-ab-user-convert="navclick_Scala_Tutorial" class="coursera-university-color"><span>Scala Tutorial </span><span></span></a></li><li class="course-navbar-item"></li><li class="course-navbar-item"><a href="https://class.coursera.org/progfun-004/wiki/ScalaStyleGuide" data-if-linkable="modal-lock,gray,lock-icon" data-ab-user-convert-for="honorcode_to_welcome2" data-ab-user-convert="navclick_Scala_Style_Guide" class="coursera-university-color"><span>Scala Style Guide </span><span></span></a></li><li class="course-navbar-item"><a href="https://class.coursera.org/progfun-004/wiki/AssignmentFeedback" data-if-linkable="modal-lock,gray,lock-icon" data-ab-user-convert-for="honorcode_to_welcome2" data-ab-user-convert="navclick_Assignment_Feedback" class="coursera-university-color"><span>Assignment Feedback </span><span></span></a></li><li class="course-navbar-item"><a href="https://class.coursera.org/progfun-004/wiki/CheatSheet" data-if-linkable="modal-lock,gray,lock-icon" data-ab-user-convert-for="honorcode_to_welcome2" data-ab-user-convert="navclick_Scala_Cheat_Sheet" class="coursera-university-color"><span>Scala Cheat Sheet </span><span></span></a></li><li class="course-navbar-item"><a href="https://class.coursera.org/progfun-004/wiki/GradingPolicy" data-if-linkable="modal-lock,gray,lock-icon" data-ab-user-convert-for="honorcode_to_welcome2" data-ab-user-convert="navclick_Grading_Policy" class="coursera-university-color"><span>Grading Policy </span><span></span></a></li></ul><ul style="list-style-type:none;margin-left: 10px;"><li><a href="https://learner.coursera.help/" target="_blank" title="Open help articles in new window" class="coursera-university-color"><i class="icon-question-sign"></i>Help Center</a></li></ul><ul style="list-style-type:none;margin-left: 10px;"><li><a href="https://class.coursera.org/progfun-004/forum/list?forum_id=10000&url=https%3A%2F%2Fclass.coursera.org%2Fprogfun-004%2Fassignment%2Fview%3Fassignment_id%3D9" class="coursera-university-color"><i class="icon-comments"></i>Course Materials Errors</a></li><li><a href="https://class.coursera.org/progfun-004/forum/list?forum_id=10001&url=https%3A%2F%2Fclass.coursera.org%2Fprogfun-004%2Fassignment%2Fview%3Fassignment_id%3D9" class="coursera-university-color"><i class="icon-comments"></i>Technical Issues</a></li></ul></div></div></div></div><div id="course-page-content" role="main"><div style="display: block;" id="spark" class="hide"><h2 class="course-page-header">
<span>Object-Oriented Sets: Instructions</span>
<a class="coursera-reporter-link" title="Click here if you're experiencing technical problems or found errors in the course materials." target="_blank" href="https://class.coursera.org/progfun-004/help/programming?url=https%3A%2F%2Fclass.coursera.org%2Fprogfun-004%2Fassignment%2Fview%3Fassignment_id%3D9">
Help Center
</a>
</h2>
<p>
</p><p>Attention: You are allowed to submit <b>a maximum of 5 times</b>!
for grade purposes. Once you have submitted your solution, you should
see your grade and a feedback about your code on the Coursera website
within 10 minutes. If you want to improve your grade, just submit an
improved solution. The best of all your first 5 submissions will count
as the final grade. You can still submit after the 5th time to get
feedbacks on your improved solutions, however, these are for research
purposes only, and will not be counted towards your final grade.</p>
<p><a href="https://spark-public.s3.amazonaws.com/progfun/assignments/objsets.zip">Download the objsets.zip</a> handout archive file.</p>
<p>In this assignment you will work with an object-oriented representations based on binary trees.</p>
<h1 id="objectoriented_sets">Object-Oriented Sets</h1>
<p>For this part, you will earn credit by completing the <code>TweetSet.scala</code> file. This file defines an abstract class <code>TweetSet</code> with two concrete subclasses, <code>Empty</code> which represents an empty set, and <code>NonEmpty(elem: Tweet, left: TweetSet, right: TweetSet)</code>, which represents a non-empty set as a binary tree rooted at <code>elem</code>. The tweets are indexed by their text bodies: the bodies of all tweets on the <code>left</code> are lexicographically smaller than <code>elem</code> and all bodies of elements on the <code>right</code> are lexicographically greater.</p>
<p>Note also that these classes are <em>immutable</em>: the set-theoretic operations do not modify <code>this</code> but should return a new set.</p>
<p>Before tackling this assignment, we suggest you first study the already implemented methods <code>contains</code> and <code>incl</code> for inspiration.</p>
<h2 id="1_filtering">1 Filtering</h2>
<p>Implement filtering on tweet sets. Complete the stubs for the methods <code>filter</code> and <code>filterAcc</code>. <code>filter</code> takes as argument a function, the predicate, which takes a tweet and returns a boolean. <code>filter</code> then returns the subset of all the tweets in the original set for which the predicate is true. For example, the following call:</p>
<pre><code>tweets.filter(tweet => tweet.retweets > 10)</code></pre>
<p>applied to a set <code>tweets</code> of two tweets, say, where the
first tweet was not retweeted and the second tweet was retweeted 20
times should return a set containing only the second tweet.</p>
<p>Hint: start by defining the helper method <code>filterAcc</code> which takes an accumulator set as a second argument. This accumulator contains the ongoing result of the filtering.</p>
<pre><code>/** This method takes a predicate and returns a subset of all the elements
* in the original set for which the predicate is true.
*/
def filter(p: Tweet => Boolean): TweetSet
def filterAcc(p: Tweet => Boolean, acc: TweetSet): TweetSet</code></pre>
<p>The definition of <code>filter</code> in terms of <code>filterAcc</code> should then be straightforward.</p>
<h2 id="2_taking_unions">2 Taking Unions</h2>
<p>Implement union on tweet sets. Complete the stub for the method <code>union</code>. The method <code>union</code> takes another set <code>that</code>, and computes a <em>new</em> set which is the union of <code>this</code> and <code>that</code>, i.e. a set that contains exactly the elements that are <em>either</em> in <code>this</code> <em>or</em> in <code>that</code>, <em>or in both</em>.</p>
<pre><code>def union(that: TweetSet): TweetSet</code></pre>
<p>Note that in this exercise it is your task to find out in which class(es) to define the <code>union</code> method (should it be abstract in class <code>TweetSet</code>?).</p>
<h2 id="3_sorting_tweets_by_their_influence">3 Sorting Tweets by Their Influence</h2>
<p>The more often a tweet is “re-tweeted” (that is, repeated by a
different user with or without additions), the more influential it is.</p>
<p>The goal of this part of the exercise is to add a method <code>descendingByRetweet</code> to <code>TweetSet</code> which should produce a linear sequence of tweets (as an instance of class <code>TweetList</code>), ordered by their number of retweets:</p>
<pre><code>def descendingByRetweet: TweetList</code></pre>
<p>This method reflects a common pattern when transforming data structures. While traversing one data structure (in this case, a <code>TweetSet</code>), we’re building a second data structure (here, an instance of class <code>TweetList</code>). The idea is to start with the empty list <code>Nil</code> (containing no tweets), and to find the tweet with the most retweets in the input <code>TweetSet</code>. This tweet is removed from the <code>TweetSet</code> (that is, we obtain a new <code>TweetSet</code> that has all the tweets of the original set except for the tweet that was “removed”; this <em>immutable</em> set operation, <code>remove</code>, is already implemented for you), and added to the result list by creating a new <code>Cons</code>. After that, the process repeats itself, but now we are searching through a <code>TweetSet</code> with one less tweet.</p>
<p>Hint: start by implementing the method <code>mostRetweeted</code> which returns the most popular tweet of a <code>TweetSet</code>.</p>
<h2 id="4_tying_everything_together">4 Tying everything together</h2>
<p>In the last step of this assignment your task is to detect
influential tweets in a set of recent tweets. We are providing you with a
<code>TweetSet</code> containing several hundred tweets from popular tech news sites in the past few days, located in the <code>TweetReader</code> object (file “TweetReader.scala”). <code>TweetReader.allTweets</code> returns an instance of <code>TweetSet</code> containing a set of all available tweets.</p>
<p>Furthermore, you are given two lists of keywords. The first list
corresponds to keywords associated with Google and Android smartphones,
while the second list corresponds to keywords associated with Apple and
iOS devices. Your objective is to detect which platform has generated
more interest or activity in the past few days.</p>
<p>As a first step, use the functionality you implemented in the first parts of this assignment to create two different <code>TweetSet</code>s, <code>googleTweets</code> and <code>appleTweets</code>. The first <code>TweetSet</code>, <code>googleTweets</code>, should contain all tweets that mention (in their “text”) one of the keywords in the <code>google</code> list. The second <code>TweetSet</code>, <code>appleTweets</code>, should contain all tweets that mention one of the keyword in the <code>apple</code> list. Their signature is as follows:</p>
<pre><code>lazy val googleTweets: TweetSet
lazy val appleTweets: TweetSet</code></pre>
<p>Hint: use the <code>exists</code> method of <code>List</code> and <code>contains</code> method of class <code>java.lang.String</code>.</p>
<p>From the <em>union</em> of those two <code>TweetSet</code>s, produce <code>trending</code>, an instance of class <code>TweetList</code> representing a sequence of tweets ordered by their number of retweets:</p>
<pre><code>lazy val trending: TweetList</code></pre>
<p></p>
<script type="text/x-mathjax-config;executed=true">
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
styleSheets: [],
styles: {},
jax: ["input/TeX"],
extensions: ["tex2jax.js"],
preJax: null,
postJax: null,
preRemoveClass: "MathJax_Preview",
showProcessingMessages: true,
messageStyle: "none",
displayAlign: "center",
displayIndent: "0em",
delayStartupUntil: "none",
skipStartupTypeset: false,
elements: [],
tex2jax: {
inlineMath: [
['$$','$$'], // uncomment this for standard TeX math delimiters
['\\(','\\)']
],
displayMath: [
['\\[','\\]']
],
skipTags: ["script","noscript","style","textarea","pre","code"],
ignoreClass: "tex2jax_ignore",
processClass: "tex2jax_process",
processEscapes: false,
processEnvironments: true,
preview: "TeX"
},
mml2jax: {
preview: "alttext"
},
jsMath2jax: {
preview: "TeX"
},
TeX: {
TagSide: "right",
TagIndent: ".8em",
MultLineWidth: "85%",
Macros: {},
extensions: ["AMSmath.js", "AMSsymbols.js"]
},
//============================================================================
//
// These parameters control the MathML inupt jax.
//
MathML: {
//
// This specifies whether to use TeX spacing or MathML spacing when the
// HTML-CSS output jax is used.
//
useMathMLspacing: false
},
//============================================================================
//
// These parameters control the HTML-CSS output jax.
//
"HTML-CSS": {
scale: 100,
availableFonts: ["STIX","TeX"],
preferredFont: "TeX",
webFont: "TeX",
imageFont: "TeX",
undefinedFamily: "STIXGeneral,'Arial Unicode MS',serif",
showMathMenu: true,
styles: {},
tooltip: {
delayPost: 600, // milliseconds delay before tooltip is posted after mouseover
delayClear: 600, // milliseconds delay before tooltip is cleared after mouseout
offsetX: 10, offsetY: 5 // pixels to offset tooltip from mouse position
}
},
//============================================================================
//
// These parameters control the NativeMML output jax.
//
NativeMML: {
scale: 100,
showMathMenu: true,
showMathMenuMSIE: true,
styles: {}
},
MathMenu: {
delay: 400,
helpURL: "http://www.mathjax.org/help/user/",
showRenderer: true,
showFontMenu: false,
showContext: false,
windowSettings: {
status: "no", toolbar: "no", locationbar: "no", menubar: "no",
directories: "no", personalbar: "no", resizable: "yes", scrollbars: "yes",
width: 100, height: 50
},
styles: {}
},
MMLorHTML: {
prefer: {
MSIE: "MML",
Firefox: "HTML",
Opera: "HTML",
other: "HTML"
}
}
});
</script>
</div></div></div></div></div><div class="coursera-footer"></div></div></div></div><!--[if gte IE 9]><script>document.getElementById("coursera-loading-js").style.display = 'block';</script><![endif]-->
<!--[if lte IE 8]><script>document.getElementById("coursera-loading-nojs").style.display = 'block';</script><![endif]-->
<!--[if !IE]> --><script>document.getElementById("coursera-loading-js").style.display = 'block';</script><!-- <![endif]--><script>if (/zh/i.test(window.localStorage ? localStorage.getItem('locale') : '') || '{{ locale }}') {
document.getElementById('get-browser-zh').style.display = 'block';
}</script><!--[if !IE]> --><script>document.getElementById('coursera-loading-js').style.display = 'block';</script><!-- <![endif]-->
<script src="assignment_files/jquery.js"></script>
<script src="assignment_files/loadOrRefreshMathJax.js"></script>
<script src="assignment_files/require.js"></script><script data-baseurl="https://dw0ugk4msqulk.cloudfront.net/61a7c1335d196f1295e3341330ed120d255fe89d/" data-version="61a7c1335d196f1295e3341330ed120d255fe89d" data-timestamp="1465424411607" data-debug="0" data-locale="en_US" id="_require">if(document.getElementById('coursera-loading-js').style.display == 'block') {
(function(el) {
require.config({
//enforceDefine: true,
waitSeconds: 75,
baseUrl: el.getAttribute('data-baseurl'),
urlArgs: el.getAttribute('data-debug') == '1' ? 'v=' + el.getAttribute('data-timestamp') : '',
shim: {
'underscore': {
exports: '_'
},
'backbone': {
deps: ['underscore', 'jquery'],
exports: 'Backbone',
init: function(_, $) {
Backbone.$ = $;
return Backbone;
}
},
'pages/hg/thirdparty/js/backbone.marionette': {
deps: ['backbone']
},
'pages/hg/thirdparty/js/webshims/polyfiller': {
deps: ['jquery']
},
'pages/hg/thirdparty/js/webshims/extras/mousepress': {
deps: ['jquery', 'pages/hg/thirdparty/js/webshims/polyfiller']
},
'pages/hg/thirdparty/js/jquery.throttle': {
deps: ['jquery']
},
'js/lib/jquery.linkify': {
deps: ['jquery']
},
'pages/hg/thirdparty/js/js/bootstrap/alert': {
deps: ['jquery', 'pages/hg/thirdparty/js/bootstrap/transition']
},
'spark/core/js/jquery_ui': {
deps: ['jquery']
},
'spark/core/js/jquery.history': {
deps: ['jquery']
},
'js/lib/bootstrap.tooltip': {
deps: ['jquery']
},
'pages/hg/thirdparty/js/bootstrap/transition': {
deps: ['jquery']
},
'pages/hg/thirdparty/js/bootstrap/tab': {
deps: ['jquery']
},
'bundles/videojs/lib/video.4.3.0': {
exports: 'vjs'
}
},
paths: {
'q': 'js/vendor/q.v1-0-1',
'react-with-addons': 'js/vendor/react-with-addons.v0-12',
'jquery': 'pages/spark/jquery',
'underscore': 'js/vendor/underscore.v1-5-2',
'backbone': 'js/vendor/backbone.v1-1-0',
'backbone.relational': 'js/lib/backbone.relational.0.8.6',
'i18n': 'js/lib/i18n._t',
'css': 'js/vendor/require.css.v0-1-2',
'memoize': 'js/lib/require.memoize.v0-0-1',
'pages/spark/models/user.json': 'empty:',
'pages/spark/models/course.json': 'empty:',
'pages/spark/models/navbar.json': 'empty:'
},
callback: function() {
require(['pages/spark/routes']);
},
config: {
i18n: {
locale: (window.localStorage ? localStorage.getItem('locale') : '') || el.getAttribute('data-locale')
}
}
});
})(document.getElementById('_require'));
}
</script><script>define('pages/spark/models/user.json', [], function(){
return JSON.parse("{\"id\":4452529,\"email_address\":\"[email protected]\",\"full_name\":\"Pol Bassiner\",\"locale\":\"en_US\",\"timezone\":\"Europe\\\/Madrid\",\"access_group_id\":\"4\",\"registration_time\":\"1394212065\",\"last_access_time\":\"1465970693\",\"last_access_ip\":\"213.229.148.26\",\"signature_track_register_time\":\"0\",\"email_announcement\":\"1\",\"email_forum\":\"1\",\"in_signature_track\":\"0\",\"wishes_proctored_exam\":null,\"first_name\":\"Pol\",\"permissions\":[\"default\",\"allow_site_access\"],\"group\":\"Student\",\"anonymous\":false,\"forum_title\":\"Student\",\"signature_track_state\":1,\"verified_quizzes\":[],\"submitted_quizzes\":[\"60\",\"78\",\"88\",\"90\",\"92\",\"100\",\"104\",\"128\",\"130\",\"132\"],\"scheduled_proctored_exam\":null,\"last_chance_modal\":1,\"flexjoin_last_chance_modal\":null}");
});
define('pages/spark/models/course.json', [], function(){
return JSON.parse("{\"id\":972351,\"isPrivate\":false,\"type\":\"public\",\"name\":\"Functional Programming Principles in Scala\",\"instructor\":\"\",\"sessionName\":\"progfun-004\",\"externalBaseURL\":\"https:\\\/\\\/www.coursera.org\\\/\",\"shortname\":\"progfun\",\"host\":\"https:\\\/\\\/www.coursera.org\\\/\",\"assetUnversionedLink\":\"https:\\\/\\\/dw0ugk4msqulk.cloudfront.net\\\/\",\"cheggID\":\"\",\"hasLTI\":true,\"badgevilleDomain\":\"\",\"linkable\":false,\"universityShortname\":\"epfl\",\"signatureTrackStatus\":{\"signature_track_enabled\":1},\"courseURLs\":{\"log_in_link\":\"https:\\\/\\\/www.coursera.org\\\/login?post_redirect=https%3A%2F%2Fwww.coursera.org%2Flogin%3Fuser_action%3Dclass%26course_id%3D972351%26post_redirect%3Dhttps%253A%252F%252Fclass.coursera.org%252Fprogfun-004%252Fauth%252Fauth_redirector%253Ftype%253Dlogin%2526subtype%253Dnormal%2526visiting%253D\",\"sign_up_link\":\"https:\\\/\\\/www.coursera.org\\\/signup?enroll_cid=972351&enroll_sn=progfun&enroll_n=Functional Programming Principles in Scala\",\"view_course_info_link\":\"https:\\\/\\\/www.coursera.org\\\/course\\\/progfun\",\"sign_up_link_cant_enroll\":\"https:\\\/\\\/www.coursera.org\\\/signup?post_redirect=https%3A%2F%2Fwww.coursera.org%2Fcourse%2Fprogfun\"},\"courseBase\":\"https:\\\/\\\/class.coursera.org\\\/progfun-004\\\/\",\"search\":true,\"hideWiki\":true,\"aceStartRegistrationDate\":\"Thu 1 Jan 1970 1:00 AM CET\",\"aceEndRegistrationDate\":\"Thu 1 Jan 1970 1:00 AM CET\",\"aceExamStartDate\":\"Thu 1 Jan 1970 1:00 AM CET\",\"aceExamEndDate\":\"Thu 1 Jan 1970 1:00 AM CET\",\"aceExamRules\":\"\",\"aceExamDuration\":\"\",\"aceBeforeExam\":false,\"aceAfterExam\":true,\"aceHours\":null,\"aceCreditType\":\"\",\"acePrice\":null,\"aceExamID\":null,\"aceEligible\":false,\"canRegisterForACE\":false,\"specialization\":null,\"supportForums\":true,\"textbooks\":\"\",\"inVideoQuizV2\":false,\"in_flexjoin\":0,\"honorCodeExtraText\":\"\",\"honorCodeCustomTitle\":\"\",\"honorCodeCustomButton\":\"\",\"studentAccessDisabled\":0,\"disableQQs\":true}");
});
define('pages/spark/models/navbar.json', [], function(){
return JSON.parse("{\"items\":[{\"name\":\"Home\",\"icon\":\"home\",\"link_type\":\"circuit\",\"link_data\":\"class:index\"},{\"name\":\"\",\"icon\":\"\",\"link_type\":\"circuit\",\"link_data\":\"\"},{\"name\":\"Video Lectures\",\"icon\":\"lecture\",\"link_type\":\"circuit\",\"link_data\":\"lecture:index\"},{\"name\":\"Learning Resources\",\"icon\":\"wiki\",\"link_type\":\"wiki\",\"link_data\":\"LearningResources\"},{\"name\":\"Assignments\",\"icon\":\"assignment\",\"link_type\":\"circuit\",\"link_data\":\"assignment:index\"},{\"name\":\"\",\"icon\":\"\",\"link_type\":\"circuit\",\"link_data\":\"\"},{\"name\":\"Discussion Forums\",\"icon\":\"forum\",\"link_type\":\"circuit\",\"link_data\":\"forum:index\"},{\"name\":\"\",\"icon\":\"\",\"link_type\":\"circuit\",\"link_data\":\"\"},{\"name\":\"Tools Setup\",\"icon\":\"wiki\",\"link_type\":\"wiki\",\"link_data\":\"ToolsSetup\"},{\"name\":\"Sbt Tutorial\",\"icon\":\"wiki\",\"link_type\":\"wiki\",\"link_data\":\"SbtTutorial\"},{\"name\":\"SBT FAQ\",\"icon\":\"\",\"link_type\":\"link\",\"link_data\":\"https:\\\/\\\/share.coursera.org\\\/wiki\\\/index.php\\\/Progfun:sbt\"},{\"name\":\"Eclipse Tutorial\",\"icon\":\"wiki\",\"link_type\":\"wiki\",\"link_data\":\"EclipseTutorial\"},{\"name\":\"IntelliJ IDEA Tutorial (optional alternative IDE)\",\"icon\":\"\",\"link_type\":\"wiki\",\"link_data\":\"IntelliJ_IDEA\"},{\"name\":\"Scala Tutorial\",\"icon\":\"wiki\",\"link_type\":\"wiki\",\"link_data\":\"ScalaTutorial\"},{\"name\":\"\",\"icon\":\"\",\"link_type\":\"circuit\",\"link_data\":\"\"},{\"name\":\"Scala Style Guide\",\"icon\":\"wiki\",\"link_type\":\"wiki\",\"link_data\":\"ScalaStyleGuide\"},{\"name\":\"Assignment Feedback\",\"icon\":\"wiki\",\"link_type\":\"wiki\",\"link_data\":\"AssignmentFeedback\"},{\"name\":\"Scala Cheat Sheet\",\"icon\":\"wiki\",\"link_type\":\"wiki\",\"link_data\":\"CheatSheet\"},{\"name\":\"Grading Policy\",\"icon\":\"wiki\",\"link_type\":\"wiki\",\"link_data\":\"GradingPolicy\"}]}");
});
</script><script>var coursera_enable_new_help_center = false;
</script><div class="hide confirm-navigation modal"><div class="modal-header"><h3>Confirm Navigation</h3></div><div class="modal-body"><div class="confirm-navigation-message"></div><div>Are you sure you want to leave this page?</div></div><div class="modal-footer"><button data-modal-close="data-modal-close" class="btn confirm-navigation-stay">Stay on this Page</button><button data-modal-close="data-modal-close" class="btn btn-danger confirm-navigation-leave">Leave this Page</button></div></div><div style="display: none;" class="coursera-async-message"></div></body></html>