Skip to content

Commit 077c276

Browse files
author
Rafa Paradela
committed
Distribution: Distribution: Merge pull request scala-exercises#63 from cjgulledge/patch-1
1 parent 405a7ef commit 077c276

File tree

83 files changed

+4957
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+4957
-0
lines changed

dist/.htaccess

Lines changed: 984 additions & 0 deletions
Large diffs are not rendered by default.

dist/CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
scala-exercises.47deg.com

dist/googlef7ad26181520ab2a.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
google-site-verification: googlef7ad26181520ab2a.html
13 KB
Loading
1.13 KB
Loading

dist/images/2c11a128.favicon.png

698 Bytes
Loading

dist/images/33115d96.step_032x.png

4.55 KB
Loading

dist/images/34ca7b6f.45.GIF

18.3 KB
Loading

dist/images/484944e4.step_03.png

1.63 KB
Loading

dist/images/51ecee2a.icon_blog2x.png

2.71 KB
Loading

dist/images/5218716d.icon_books.png

1.32 KB
Loading

dist/images/6802006a.step_022x.png

3.02 KB
Loading
2.51 KB
Loading

dist/images/838500c1.step_01.png

1.16 KB
Loading

dist/images/9af52ceb.step_04.png

1.36 KB
Loading

dist/images/9b7ab054.step_012x.png

2.17 KB
Loading

dist/images/a029581d.logo_47deg.png

534 Bytes
Loading

dist/images/ac9913c1.icon_blog.png

1.26 KB
Loading

dist/images/b3beabbd.background.jpg

347 KB
Loading

dist/images/c1d0509d.icon_books2x.png

3.01 KB
Loading
6.21 KB
Loading

dist/images/d894ee59.background.png

1.04 MB
Loading

dist/images/df532660.logo_47deg2x.png

877 Bytes
Loading

dist/images/e0d58a65.step_02.png

1.49 KB
Loading

dist/images/f3638223.step_042x.png

2.71 KB
Loading

dist/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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]>
2+
<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>
3+
<![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 solvable 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/fbeab623.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(){
4+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
5+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
6+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
7+
8+
ga('create', 'UA-18433785-8', 'auto');
9+
ga('send', 'pageview');</script> <script src=scripts/a54d9495.main.js></script>

dist/json/asserts.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"title": "Asserts",
3+
"modules": [
4+
{
5+
"preparagraph": "ScalaTest makes three assertions available by default in any style trait. You can use:\n\n- `assert` for general assertions;\n- `assertResult` to differentiate expected from actual values;\n- `intercept` to ensure a bit of code throws an expected exception.\n\nIn any Scala program, you can write assertions by invoking `assert` and passing in a `Boolean` expression:\n\n```\nval left = 2\nval right = 1\nassert(left == right)\n``` \n\nIf the passed expression is `true`, `assert` will return normally. If `false`,\nScala's `assert` will complete abruptly with an `AssertionError`. This behavior is provided by\nthe `assert` method defined in object `Predef`, whose members are implicitly imported into every Scala source file.\n\n\nScalaTest provides a domain specific language (DSL) for expressing assertions in tests\nusing the word `should`. ScalaTest matchers provides five different ways to check equality, each designed to address a different need. They are:\n\n```\nresult should equal (3) // can customize equality\nresult should === (3) // can customize equality and enforce type constraints\nresult should be (3) // cannot customize equality, so fastest to compile\nresult shouldEqual 3 // can customize equality, no parentheses required\nresult shouldBe 3 // cannot customize equality, so fastest to compile, no parentheses required\n```\n\nCome on, your turn: true and false values can be compared with should matchers",
6+
"code": "true should be(__)",
7+
"solutions": [
8+
"true"
9+
],
10+
"postparagraph": ""
11+
},
12+
{
13+
"preparagraph": "Booleans in asserts can test equality.",
14+
"code": "val v1 = 4\nval v2 = 4\nv1 === __",
15+
"solutions": [
16+
"v2"
17+
],
18+
"postparagraph": "`===` is an assert. It is from ScalaTest, not from the Scala language."
19+
},
20+
{
21+
"preparagraph": "Sometimes we expect you to fill in the values",
22+
"code": "assert(__ == 1 + 1)",
23+
"solutions": [
24+
"2"
25+
],
26+
"postparagraph": ""
27+
}
28+
]
29+
}

dist/json/bynameparameter.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"title": "ByName Parameter",
3+
"modules": [
4+
{
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.",
6+
"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 (__)",
7+
"solutions": [
8+
"Right(29)"
9+
],
10+
"postparagraph": ""
11+
},
12+
{
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.",
14+
"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 (__)",
15+
"solutions": [
16+
"Right(69)"
17+
],
18+
"postparagraph": ""
19+
},
20+
{
21+
"preparagraph": "By name parameters can also be used with an *Object* and apply to make interesting block-like calls",
22+
"code": "object PigLatinizer {\n def apply(x: => String) = x.tail + x.head + \"ay\"\n}\n\nval result = PigLatinizer {\n val x = \"pret\"\n val z = \"zel\"\n x ++ z //concatenate the strings\n}\n\nresult should be (__)",
23+
"solutions": [
24+
"\"retzelpay\""
25+
],
26+
"postparagraph": ""
27+
}
28+
]
29+
}

0 commit comments

Comments
 (0)