-
Notifications
You must be signed in to change notification settings - Fork 53
/
index.html
332 lines (309 loc) · 14.8 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<title> Scala Puzzlers </title>
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/prettify.css" type="text/css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/prettify.js"></script>
</head>
<body data-spy="scroll" data-target=".subnav" data-offset="50">
<!-- Navbar -->
<div class="navbar navbar-fixed-top">
<a target="_blank" href="https://github.com/scalapuzzlers/scalapuzzlers.github.com">
<img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub">
</a>
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="/">Scala ?uzz<img src="img/l.png" alt="l" style="padding-bottom:10px;padding-left:2px;padding-right:2px"/>ers</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li>
<a id="navbar-home" href="index.html">Home</a>
</li>
<li>
<a id="navbar-archive" href="archive.html">Archive</a>
</li>
<li>
<a id="navbar-contribute" href="contribute.html">How to Contribute</a>
</li>
<li>
<a id="navbar-contact" href="contact.html">Contact</a>
</li>
<li>
<a id="navbar-about" href="about.html">About</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<script type="text/javascript">
String.prototype.endsWith = function(suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
var pathToID = {
"/" : '#navbar-home',
"index.html" : '#navbar-home',
"archive.html" : '#navbar-archive',
"contribute.html": '#navbar-contribute',
"contact.html" : '#navbar-contact',
"about.html" : '#navbar-about'
};
$(document).ready(function() {
function mapPathToID(path) {
var key;
var id = null;
for (key in pathToID) {
if (path === key) {
id = pathToID[key];
break;
}
}
return id;
};
var id = mapPathToID(window.location.pathname);
if (id != null) {
$(id).addClass("active");
}
});
/* * * DISQUS CONFIGURATION VARIABLES * * */
var disqus_shortname = 'scalapuzzlers'; // required: replace example with your forum shortname
var disqus_identifier = 'elem.id';
var disqus_url = 'https://scalapuzzlers.com/!#/' + 'elem.id';
var disqus_title = $('#title').find("h1").text();
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<div class="container-fluid">
<div class="row-fluid">
<div class="span3">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Puzzlers</li>
<li><a href="#" id="pzzlr-001">Hi There!</a></li>
<li><a href="#" id="pzzlr-003">UPSTAIRS downstairs</a></li>
<li><a href="#" id="pzzlr-004">Location, Location, Location</a></li>
<li><a href="#" id="pzzlr-005">Now You See Me, Now You Don't</a></li>
<li><a href="#" id="pzzlr-006">The Missing List</a></li>
<li><a href="#" id="pzzlr-007">Arg Arrgh!</a></li>
<li><a href="#" id="pzzlr-008">Captured by Closures</a></li>
<li><a href="#" id="pzzlr-009">Map Comprehension</a></li>
<li><a href="#" id="pzzlr-010">Init You, Init Me</a></li>
<li><a href="#" id="pzzlr-011">A Case of Equality</a></li>
<li><a href="#" id="pzzlr-012">If At First You Don't Succeed...</a></li>
<li><a href="#" id="pzzlr-013">To Map, or Not to Map</a></li>
<li><a href="#" id="pzzlr-015">Private Lives</a></li>
<li><a href="#" id="pzzlr-016">Self: See 'Self'</a></li>
<li><a href="#" id="pzzlr-017">One Egg or Two..?</a></li>
<li><a href="#" id="pzzlr-018">Return to Me!</a></li>
<li><a href="#" id="pzzlr-019">Implicitly Surprising</a></li>
<li><a href="#" id="pzzlr-020">One Bound, Two to Go</a></li>
<li><a href="#" id="pzzlr-021">Views From the Top</a></li>
<li><a href="#" id="pzzlr-022">Count Me Now, Count Me Later</a></li>
<li><a href="#" id="pzzlr-023">Information Overload</a></li>
<li><a href="#" id="pzzlr-024">What's in a Name?</a></li>
<!-- 26 'reserved' for Scalaz - suggestion by A.P. Marki -->
<li><a href="#" id="pzzlr-027">I Can Has Padding?</a></li>
<li><a href="#" id="pzzlr-028">Cast Away</a></li>
<li><a href="#" id="pzzlr-029">Pick an Int, Any Int!</a></li>
<li><a href="#" id="pzzlr-032">Type Extortion</a></li>
<li><a href="#" id="pzzlr-033">Implicit Kryptonite</a></li>
<li><a href="#" id="pzzlr-034">All's Well That Folds Well</a></li>
<li><a href="#" id="pzzlr-035">A Case of Strings</a></li>
<li><a href="#" id="pzzlr-036">Adaptive Reasoning</a></li>
<li><a href="#" id="pzzlr-037">A View to a Shill</a></li>
<li><a href="#" id="pzzlr-039">Accepts Any Args</a></li>
<li><a href="#" id="pzzlr-040">Set the Record Straight</a></li>
<li><a href="#" id="pzzlr-041">Signs of Trouble</a></li>
<li><a href="#" id="pzzlr-042">The Devil Is in the Defaults</a></li>
<li><a href="#" id="pzzlr-043">Market Precedence</a></li>
<li><a href="#" id="pzzlr-044">Float or Sink?</a></li>
<li><a href="#" id="pzzlr-045">Stringy Conversions</a></li>
<li><a href="#" id="pzzlr-046">Size It Up</a></li>
<li><a href="#" id="pzzlr-047">A Listful of Dollars</a></li>
<li><a href="#" id="pzzlr-048">One, Two, Skip a Few</a></li>
<li><a href="#" id="pzzlr-049">Oddly Enough</a></li>
<li><a href="#" id="pzzlr-051">Well, In This Case...</a></li>
<li><a href="#" id="pzzlr-053">Trial and Error</a></li>
<li><a href="#" id="pzzlr-054">Think of 1 Card</a></li>
<li><a href="#" id="pzzlr-055">Splitting Headache</a></li>
<li><a href="#" id="pzzlr-056">An Exceptional Future</a></li>
<li><a href="#" id="pzzlr-057">Applied Values</a></li>
<li><a href="#" id="pzzlr-058">The Branch Not Taken</a></li>
<li><a href="#" id="pzzlr-059">A Result, Finally!</a></li>
<li><a href="#" id="pzzlr-060">Unary Quandary</a></li>
<li><a href="#" id="pzzlr-061">Heads You Win...</a></li>
<li><a href="#" id="pzzlr-063">(Ex)Stream Surprise</a></li>
<li><a href="#" id="pzzlr-065">A Matter of Context</a></li>
<li><a href="#" id="pzzlr-066">Inference Hindrance</a></li>
<li><a href="#" id="pzzlr-067">Inconstant Constants</a></li>
<li><a href="#" id="pzzlr-068">For Each Step...</a></li>
<li><a href="#" id="pzzlr-069">Beep Beep...Reversing</a></li>
<li><a href="#" id="pzzlr-070">Reductio Ad Absurdum</a></li>
<li class="divider"></li>
</ul>
</div><!--/.well -->
</div><!--/span3-->
<script type="text/javascript">
var activeElem = null;
$('a[id|="pzzlr"]').each(function(index, elem) {
$(elem).click(function() {
$('#disqus_thread').hide();
$('#prime-space').html("");
$('#prime-space').load('puzzlers/' + elem.id + '.html', function() {
prettyPrint();
document.location.hash = elem.id;
window.scrollTo(0, 0);
$('#show-and-tell').click(function() {
$('#show-and-tell').addClass("disabled");
$('#correct-answer').addClass("correct-answer");
$('#explanation').show('slow', function () {
DISQUS.reset({
reload: true,
config: function () {
this.page.identifier = elem.id;
this.page.url = 'https://scalapuzzlers.com/#!/' + elem.id;
this.page.title = $('#title').find("h1").text();
}
});
$('#disqus_thread').show();
$('html,body').animate({scrollTop:$('#correct-answer').offset().top - $('.navbar').height() - 2}, 900);
});
});
});
if (activeElem != null) {
$(activeElem).removeClass("active");
}
activeElem = $(elem).parent();
$(activeElem).addClass("active");
});
});
</script>
<div class="span9">
<div id="prime-space">
<div id="welcome-content" style="display:none">
<div class="headline">
<h1>A fun way to learn more about
<img src="img/scala-logo.png" alt="Scala" style="padding-bottom:15px;padding-left:10px"/>
</h1>
<p>
Welcome to Scala Puzzlers, the collection of <i>Traps, Pitfalls
and Corner Cases</i> in the Scala language.</br></br>
</p>
<div class="row-fluid">
<div class="span8 headline-unit yellow-background">
<p>
Prepare to be surprised, entertained and...well, puzzled!<br/>
What is presented here is a selection of seemingly simple examples
which demonstrate that there's plenty of head-scratching left in
Scala.<br/> Let your mind be challenged by unexpected and non-intuitive
behaviour and results and learn something in the process.
</p>
<p>
What is a puzzler? It should be:
<ul>
<li>an intentional language feature (so no bugs)</li>
<li>not just weird because the reader doesn't know Scala</li>
<li>"surprising" or "non-intuitive" to a
reasonably skilled Scala developer</li>
</ul>
</p>
<p>
Choose a puzzler from the left-hand list to get started!
</p>
</div>
<div class="span4 headline-unit book-teaser" style="text-align:center">
<h2><a href="/buy-the-book">Get the book!</a></h2>
<a href="/buy-the-book">
<img class="book-cover" src="img/scala-puzzlers-book.jpg" height="220" width="166" alt="Scala Puzzlers book">
</a>
<p>
In-depth explanations, workarounds and more...
</p>
</div>
</div>
</div><!--/headline-->
<div class="row-fluid">
<div class="span6 headline-unit">
<h2>Your contributions are welcomed</h2>
<p>
Scala Puzzlers is a community effort! Have a puzzler you would like to share with the rest of the Scala community? Please follow <a href="/contribute.html">these instructions</a> to submit your puzzler.
And don't worry, you will be properly credited for your contribution!
</p>
</div>
<div class="span6 headline-unit">
<h2>We would love to hear from you</h2>
<p>
Any kind of feedback is appreciated, about the website but also about the puzzlers themselves. If there is something you would like to let us know, please <a href="/contact.html">contact us</a>.
</p>
</div>
</div><!--/row-fluid-->
<footer class="footer">
Copyright © 2013, Andrew Phillips and Nermin Serifovic
</footer>
</div><!--/welcome-->
</div><!--/prime-space-->
<div id="disqus_thread" class="comments"></div>
</div><!--/span9-->
</div><!--/raw-fluid-->
</div><!--/container-fluid-->
<script type="text/javascript">
$('#disqus_thread').hide();
if (document.location.hash) {
var elem = $(document.location.hash)[0]
$('#prime-space').load('puzzlers/' + elem.id + '.html', function() {
prettyPrint();
window.scrollTo(0, 0);
$('#show-and-tell').click(function() {
$('#show-and-tell').addClass("disabled");
$('#correct-answer').addClass("correct-answer");
$('#explanation').show('slow', function() {
disqus_identifier = elem.id;
disqus_url = 'https://scalapuzzlers.com/#!/' + elem.id;
disqus_title = $('#title').find("h1").text();
DISQUS.reset({
reload: true,
config: function () {
this.page.identifier = elem.id;
this.page.url = 'https://scalapuzzlers.com/#!/' + elem.id;
this.page.title = $('#title').find("h1").text();
}
});
$('#disqus_thread').show();
$('html,body').animate({scrollTop:$('#correct-answer').offset().top - $('.navbar').height() - 2}, 900);
});
});
});
if (activeElem != null) {
$(activeElem).removeClass("active");
}
activeElem = $(elem).parent();
$(activeElem).addClass("active");
} else {
$('#welcome-content').show();
$('#disqus_thread').hide();
}
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-31486114-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>