Skip to content

Commit fae4d9b

Browse files
author
Rafa Paradela
committed
Distribution: Merge pull request scala-exercises#50 from RomanVlasenko/patch-1
1 parent ee0c06d commit fae4d9b

16 files changed

+69
-46
lines changed

dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html> <html class=no-js lang=en> <head> <meta charset=utf-8> <meta name=viewport content="width=device-width"> <link rel="shortcut icon" href=images/2c11a128.favicon.png> <!-- Update your html tag to include the itemscope and itemtype attributes. --> <html itemscope itemtype=http://schema.org/Article> <!-- Place this data between the <head> tags of your website --> <title>Scala Exercises | The easy way to learn Scala</title> <meta name=description content="Introducing Scala Exercises: Quick lessons that will get you on your way to learning Scala in no time."> <meta name=keywords content="Scala, Koans, Exercises, Scala Koans, Open Source, Lessons"> <meta name=author content="47 Degrees"> <!-- Schema.org markup for Google+ --> <meta itemprop=name content="Scala Exercises"> <meta itemprop=description content="Introducing Scala Exercises: Quick lessons that will get you on your way to learning Scala in no time."> <meta itemprop=image content=http://scala-exercises.47deg.com/static/social_image.jpg> <!-- Twitter Card data --> <meta name=twitter:card content=summary_large_image> <meta name=twitter:site content=@47deg> <meta name=twitter:title content="Scala Exercises"> <meta name=twitter:description content="The easy way to learn Scala."> <meta name=twitter:creator content=@47deg> <!-- Twitter summary card with large image must be at least 280x150px --> <meta name=twitter:image:src content=http://scala-exercises.47deg.com/static/social_image_h.jpg> <!-- Publisher Google Plus --> <meta name=twitter:image:src content=http://scala-exercises.47deg.com/static/social_image_h.jpg> <!-- Open Graph data --> <meta property=og:title content="Scala Exercises"> <meta property=og:type content="article"> <meta property=og:url content="http://scala-exercises.47deg.com/"> <meta property=og:image content="http://scala-exercises.47deg.com/static/social_image.jpg"> <meta property=og:description content="The easy way to learn Scala."> <meta property=og:site_name content="Scala Exercises"> <meta property=article:published_time content="2014-12-04T05:59:00+01:00"> <meta property=article:modified_time content="2014-12-04T05:59:00+01:00"> <meta property=article:section content="Home"> <meta property=article:tag content="Scala"> <!-- Place favicon.ico and apple-touch-icon.png in the root directory --> <link rel=stylesheet href=styles/e9ec9abd.main.css> <script src=scripts/vendor/fbe20327.modernizr.js></script> <link rel=stylesheet href="//cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css"> <body> <!--[if lt IE 10]>
1+
<!DOCTYPE html> <html class=no-js lang=en> <head> <meta charset=utf-8> <meta name=viewport content="width=device-width"> <link rel="shortcut icon" href=images/2c11a128.favicon.png> <!-- Update your html tag to include the itemscope and itemtype attributes. --> <html itemscope itemtype=http://schema.org/Article> <!-- Place this data between the <head> tags of your website --> <title>Scala Exercises | The easy way to learn Scala</title> <meta name=description content="Introducing Scala Exercises: Quick lessons that will get you on your way to learning Scala in no time."> <meta name=keywords content="Scala, Koans, Exercises, Scala Koans, Open Source, Lessons"> <meta name=author content="47 Degrees"> <!-- Schema.org markup for Google+ --> <meta itemprop=name content="Scala Exercises"> <meta itemprop=description content="Introducing Scala Exercises: Quick lessons that will get you on your way to learning Scala in no time."> <meta itemprop=image content=http://scala-exercises.47deg.com/static/social_image.jpg> <!-- Twitter Card data --> <meta name=twitter:card content=summary_large_image> <meta name=twitter:site content=@47deg> <meta name=twitter:title content="Scala Exercises"> <meta name=twitter:description content="The easy way to learn Scala."> <meta name=twitter:creator content=@47deg> <!-- Twitter summary card with large image must be at least 280x150px --> <meta name=twitter:image:src content=http://scala-exercises.47deg.com/static/social_image_h.jpg> <!-- Publisher Google Plus --> <meta name=twitter:image:src content=http://scala-exercises.47deg.com/static/social_image_h.jpg> <!-- Open Graph data --> <meta property=og:title content="Scala Exercises"> <meta property=og:type content="article"> <meta property=og:url content="http://scala-exercises.47deg.com/"> <meta property=og:image content="http://scala-exercises.47deg.com/static/social_image.jpg"> <meta property=og:description content="The easy way to learn Scala."> <meta property=og:site_name content="Scala Exercises"> <meta property=article:published_time content="2014-12-04T05:59:00+01:00"> <meta property=article:modified_time content="2014-12-04T05:59:00+01:00"> <meta property=article:section content="Home"> <meta property=article:tag content="Scala"> <!-- Place favicon.ico and apple-touch-icon.png in the root directory --> <link rel=stylesheet href=styles/e9ec9abd.main.css> <script src=scripts/vendor/3e1dbd5e.modernizr.js></script> <link rel=stylesheet href="//cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css"> <body> <!--[if lt IE 10]>
22
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
33
<![endif]--> <header id=intro> <div class=content-image></div> <div class="presentation animated fadeInDown"> <h1>Scala Exercises</h1> <p class=lead>The easy way to learn Scala.</p> <p class=lead> <button type=button class="btn btn-primary btn-lg" onclick="moveToDiv('content')">GET STARTED</button> </p> <div id=gitHubLayer> <a target=_blank href=https://github.com/47deg/scala-exercises> <i class="fa fa-github fa-main"></i><br>Contribute </a> <div class=row> <div class=col-xs-4> <a class=gitHubWidget target=_blank href=https://github.com/47deg/scala-exercises/watchers> <h2><i class="fa fa-eye"></i> <span id=eyes>00</span></h2> </a> </div> <div class=col-xs-4> <a class=gitHubWidget target=_blank href=https://github.com/47deg/scala-exercises/stargazers> <h2><i class="fa fa-star"></i> <span id=stars>00</span></h2> </a> </div> <div class=col-xs-4> <a class=gitHubWidget target=_blank href=https://github.com/47deg/scala-exercises/fork> <h2><i class="fa fa-code-fork"></i> <span id=forks>00</span></h2> </a> </div> </div> </div> </div> </header> <section id=content> <div class=container> <div class=introduction> <div class=row> <div class="col-md-8 col-md-offset-2"> <h2 class=text-center>How it works?</h2> <p class="function text-center">"Scala Exercises" brings the popular <a href="http://www.scalakoans.org/">Scala Koans</a> to the web. Offering hundreds of solveable exercises organized into 42 categories covering the basics of the Scala language.</p> </div> </div> </div> <hr> <div class=step> <div class=row> <div class="col-md-8 col-md-offset-2 step-content"> <div class=step-icon> <img src=images/9b7ab054.step_012x.png alt="Learn: Each category includes an explanation of the basics. Learn the concepts through simple code samples."> </div> <div class=step-text> <h3>Learn</h3> <p>Each category includes an explanation of the basics. Learn the concepts through simple code samples.</p> </div> </div> </div> <div class=row> <div class="col-md-8 col-md-offset-2 step-content"> <div class=step-icon> <img src=images/6802006a.step_022x.png alt="Solve: Each exercise is a unit test that must pass successfully, complete the exercise by filling in the blanks. Receive instant feedback as your answers are validated in real-time."> </div> <div class=step-text> <h3>Solve</h3> <p>Each exercise is a unit test that must pass successfully, complete the exercise by filling in the blanks. Receive instant feedback as your answers are validated in real-time.</p> </div> </div> </div> <div class=row> <div class="col-md-8 col-md-offset-2 step-content"> <div class=step-icon> <img src=images/33115d96.step_032x.png alt="Share: The system will consider the category complete when all its exercises are successfully done"> </div> <div class=step-text> <h3>Share</h3> <p>The system will consider the category complete when all its exercises are successfully done. Don't forget to share your progress on social networks before moving on to the next category!</p> </div> </div> </div> <div class=row> <div class="col-md-8 col-md-offset-2 step-content"> <div class=step-icon> <img src=images/f3638223.step_042x.png alt="Edit: After completing a category, you'll be able to go back and edit it"> </div> <div class=step-text> <h3>Edit</h3> <p>After completing a category, you'll be able to go back and edit it. Add new exercises or improve existing ones by sending a pull-request.</p> </div> </div> </div> </div> <div class=row> <div class=divider> <div class="col-md-12 text-center"> <hr> <span> <a href=koans><button type=button class="btn btn-primary btn-lg">Let's Begin!</button></a> </span> </div> </div> </div> </div> </section> <footer id=bottom> <div class=link-content> <div class="content-image content-image-footer"></div> <div class=container> <div class=row> <div class="col-md-4 text-center item"> <a href=https://typesafe.com/resources/e-books target=_blank> <div class="icon-general icon-books"></div> <h3>Books</h3> <p>Deepen your knowledge of Scala with this collection of books recommended by Typesafe.</p> </a> </div> <div class="col-md-4 text-center item"> <a href="http://docs.scala-lang.org/" target=_blank> <div class="icon-general icon-official-docs"></div> <h3>Official Docs</h3> <p>Access community-driven documentation for Scala including guides, tutorials and a glossary.</p> </a> </div> <div class="col-md-4 text-center item"> <a href=http://www.47deg.com/blog/tags/scala target=_blank> <div class="icon-general icon-blog"></div> <h3>Blog</h3> <p>At 47 Degrees we occasionally write about Scala on our blog. Take a look!</p> </a> </div> </div> </div> </div> <div class="spread text-center"> <div class=container> <button type=button class="btn btn-primary btn-lg" data-toggle=modal data-target=#spreadModal>Spread the word</button> </div> </div> <div class="about text-center"> <div class=container> <p> <img src=images/df532660.logo_47deg2x.png alt="">Copyright © 2014 - <a href=http://47deg.com>47 Degrees</a> <br> Reactive, scalable software solutions. All rights reserved. <br> Scala Koans Copyright © <a href=http://scalakoans.org>Scala Koans</a> - All Rights Reserved </p> </div> </div> </footer> <!-- modal start --> <div class="modal fade" id=spreadModal tabindex=-1 role=dialog aria-labelledby=spreadModalLabel aria-hidden=true> <div class=modal-dialog> <div class=modal-content> <div class=modal-header> <button type=button class=close data-dismiss=modal><span aria-hidden=true>&times;</span><span class=sr-only>Close</span></button> <h4 class=modal-title id=spreadModalLabel>SPREAD THE WORD</h4> </div> <div class=modal-body> <div class=row> <div class="col-sm-8 col-sm-offset-2">Do you think "Scala Exercises" is useful? Share it with your friends. Who knows, maybe you will inspire some future Scala developers.</div> </div> <div class="row share-step"> <div class="col-sm-2 col-sm-offset-3"> <span class="fa-stack fa-lg" onclick=shareSiteFacebook()> <i class="fa fa-circle fa-stack-2x facebook"></i> <i class="fa fa-facebook fa-fw fa-stack-1x fa-inverse"></i> </span> </div> <div class=col-sm-2> <span class="fa-stack fa-lg" onclick=shareSiteTwitter()> <i class="fa fa-circle fa-stack-2x twitter"></i> <i class="fa fa-twitter fa-fw fa-stack-1x fa-inverse"></i> </span> </div> <div class=col-sm-2> <span class="fa-stack fa-lg" onclick=shareSiteGoogle()> <i class="fa fa-circle fa-stack-2x plus"></i> <i class="fa fa-google-plus fa-fw fa-stack-1x fa-inverse"></i> </span> </div> </div> </div> <div class=modal-footer> </div> </div> </div> </div> <!-- modal end --> <script src=scripts/6d2b5497.vendor.js></script> <!-- Google Analytics: change UA-XXXXX-X to be your site's ID. --> <script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
44
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

dist/json/bynameparameter.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"title": "ByName Parameter",
33
"modules": [
44
{
5-
"preparagraph": "`() => Int` is a Function type that takes a `Unit` type. `Unit` is known as `void` to a Java programmer. The function and returns an `Int`. You can place this as a method parameter so that you can you use it as a block, but still it doesn't look quite right.",
5+
"preparagraph": "`() => Int` is a Function type that takes a `Unit` type. `Unit` is known as `void` to a Java programmer. The function returns an `Int`. You can place this as a method parameter so that you can you use it as a block, but still it doesn't look quite right.",
66
"code": "def calc(x: () => Int): Either[Throwable, Int] = {\n try {\n Right(x()) //An explicit call the the x function\n } catch {\n case b: Throwable => Left(b)\n }\n}\n\nval y = calc {() => //Having explicitly declaring that Unit is a parameter with ()\n 14 + 15\n}\n\ny should be (__)",
77
"solutions": [
88
"Right(29)"
99
],
1010
"postparagraph": ""
1111
},
1212
{
13-
"preparagraph": "A by-name parameter does the same thing as a previous koan but there is no need to explicitly handle `Unit` or `()`. This is used extensively in scala to create blocks.",
13+
"preparagraph": "A by-name parameter does the same thing as the previous koan but there is no need to explicitly handle `Unit` or `()`. This is used extensively in scala to create blocks.",
1414
"code": "def calc(x: => Int): Either[Throwable, Int] = { //x is a call by name parameter\n try {\n Right(x)\n } catch {\n case b: Throwable => Left(b)\n }\n}\n\nval y = calc { //This looks like a natural block\n println(\"Here we go!\") //Some superfluous call\n val z = List(1, 2, 3, 4) //Another superfluous call\n 49 + 20\n}\n\ny should be (__)",
1515
"solutions": [
1616
"Right(69)"
@@ -26,4 +26,4 @@
2626
"postparagraph": ""
2727
}
2828
]
29-
}
29+
}

dist/json/forexpressions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
},
2929
{
3030
"preparagraph": "Using 'for' we can make more readable code",
31-
"code": "val nums = List(List(1), List(2), List(3), List(4), List(5))\n\nval result = for {\n numList <- nums\n num <- numList\n if(num%2 == 0)\n} yield(num)\n\nresult should be (__)\n\n// Which is the same as\n\nnums.flatMap(numList=>numList).filter(_%2==0) should be(result)\n",
31+
"code": "val nums = List(List(1), List(2), List(3), List(4), List(5))\n\nval result = for {\n numList <- nums\n num <- numList\n if(num%2 == 0)\n} yield(num)\n\nresult should be (__)\n\n// Which is the same as\nnums.flatMap(numList=>numList).filter(_%2==0) should be(result)\n\n// or the same as\nnums.flatten.filter(_%2==0) should be(result)\n",
3232
"solutions": [
3333
"List(2, 4)"
3434
],

dist/json/higherorderfunctions.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
},
6363
{
6464
"preparagraph": "`isInstanceOf` is the same as `instanceof` in java, but in this case the parameter types can be *blanked out* using existential types with is a single underline, since parameter type are unknown at runtime.",
65-
"code": "def addWithSyntaxSugar(x: Int) = (y:Int) => x + y\n\naddWithSyntaxSugar(1).isInstanceOf[Function1[Int, Int]] should be(__)",
65+
"code": "def addWithSyntaxSugar(x: Int) = (y:Int) => x + y\n\naddWithSyntaxSugar(1).isInstanceOf[Function1[_, _]] should be(__)",
6666
"solutions": [
6767
"true"
6868
],
@@ -98,4 +98,4 @@
9898
"postparagraph": ""
9999
}
100100
]
101-
}
101+
}

dist/json/iterables.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,19 @@
105105
"postparagraph": ""
106106
},
107107
{
108-
"preparagraph": "If two Iterables aren't the same size, then `zipAll` can provide fillers for what it couldn't find a complement for:\n\nE.g. `Iterable(x1, x2, x3) zipAll (Iterable(y1, y2), x, y)` will return `((x1,y1), (x2, y2, y))`",
109-
"code": "val xs = List(3, 5, 9)\nval ys = List(\"Bob\", \"Ann\")\n(xs zipAll(ys, -1, \"?\")) should be(List((__, __), (__, __), (__, \"?\")))\n\n",
108+
"preparagraph": "If two Iterables aren't the same size, then `zipAll` can provide fillers for what it couldn't find a complement for:\n\nE.g. `Iterable(x1, x2, x3) zipAll (Iterable(y1, y2), x, y)` will return `((x1,y1), (x2, y2), (x3, y)))`",
109+
"code": "val xs = List(3, 5, 9)\nval ys = List(\"Bob\", \"Ann\")\n(xs zipAll(ys, -1, \"?\")) should be(List((__, __), (__, __), (__, \"?\")))\n\nval xs = List(3, 5)\nval ys = List(\"Bob\", \"Ann\", \"Stella\")\n(xs zipAll(ys, -1, \"?\")) should be(List((__, __), (__, __), (-1, __)))\n\n",
110110
"solutions": [
111111
"3",
112112
"\"Bob\"",
113113
"5",
114114
"\"Ann\"",
115-
"9"
115+
"9",
116+
"3",
117+
"\"Bob\"",
118+
"5",
119+
"\"Ann\"",
120+
"\"Stella\""
116121
],
117122
"postparagraph": ""
118123
},

0 commit comments

Comments
 (0)