Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session 1 and Session 2 updates #3

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ the `png` versions of all modified diagrams).
2. Install the File Watchers plugin
1. Add a File Watcher to watch the `slides` folder and process `puml` files in these folders:<br/>
![File Watcher](slides/images/addingFileWatcherForPlantuml.png)
2. use the arguments `-tsvg -nometadata $FileName$` if you want SVG instead of the default PNG
1. Create a custom `scope` to limit the file watcher:<br/>
![Documentation Scope](slides/images/creatingScope.png)

Automatically generate .png results from changed .puml files:
* install File Watcher plugin in IntelliJ
* See https://www.jetbrains.com/help/idea/using-file-watchers.html#ws_file_watchers_bedore_you_start for background info

## Slide handouts
* open slides with `http://localhost:8000/?print-pdf`
* print selected pages (omitting the exercise solutions)
* Session 1: 1-56,58-98
* Session 2: 100-102,104-125,127-130,132-157
Binary file modified Scala 101 Student guide session 1.pdf
Binary file not shown.
Binary file modified Scala 101 Student guide session 2.pdf
Binary file not shown.
17 changes: 14 additions & 3 deletions exercises/src/main/scala/exercise2/Hamlet.scala
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
package exercise2

// TODO: Uncomment the lines in the app and add the code needed to make it print
// "Hamlet, by William Shakespeare, as published in 1603" to the screen"
// TODO: Follow the instructions in the app and add the code needed to make it print
// "Hamlet, by William Shakespeare, as published in 1603" to the screen

object Hamlet extends App {
trait PrettyPrintable {
def prettyPrint: String
}

def toScreen(p: PrettyPrintable): Unit = ???
def toScreen(p: PrettyPrintable): Unit = {
// ---- Add anything you need below this line
???
// ---- Add anything you need above this line
}

// --- Add case classes below this line ---
// --- Add case classes above this line ---

// --- uncomment the lines below this line ---

//val shakespeare = Author("William", "Shakespeare")
//val hamlet = Book("Hamlet", shakespeare, 1603)

//toScreen(hamlet)

// --- uncomment the lines above this line ---
}
3 changes: 2 additions & 1 deletion slides/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@
// - https://revealjs.com/config/
Reveal.initialize({
hash: true,
center: false,
margin: 0.01,
width: 1920,
height: 1080,
maxScale: 4,
center: false,
pdfSeparateFragments: false,
slideNumber: 'c/t',
// Learn about plugins: https://revealjs.com/plugins/
plugins: [ RevealZoom, RevealMarkdown, RevealHighlight, RevealNotes, RevealMath.KaTeX ]
Expand Down
Binary file removed slides/scala101/images/list1.png
Binary file not shown.
8 changes: 8 additions & 0 deletions slides/scala101/images/list1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed slides/scala101/images/list2.png
Binary file not shown.
12 changes: 12 additions & 0 deletions slides/scala101/images/list2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions slides/scala101/session1/module1.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ notes: Ask audience what differences they spot<br/>
val str = "hello"

str.contains("e") // normal function call
s contains "e" // infix notation of same call
str contains "e" // infix notation of same call

```

Expand Down Expand Up @@ -226,8 +226,8 @@ val todo = ???

## Extra
* Open https://scala-lang.org/api/current
* Find `RichInt.to`
* Find `Int.to`
* What parameters does it accept?
* What does it return?
* What about `RichInt.until`?
* What about `Int.until`?

7 changes: 5 additions & 2 deletions slides/scala101/session1/module2.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,15 @@ class Circle(val r: Double) {
## Methods
```scala
class Circle(val r: Double) {

def draw(c: Canvas): Unit = {
val box = determineBoundingBox // draw using box
val box = determineBoundingBox

// draw on canvas c using box

private def determineBoundingBox = new Rectangle(2 * r, 2 * r)
}
}
```

notes: Unit in Scala is same as void in Java <br/>
Expand Down
4 changes: 2 additions & 2 deletions slides/scala101/session1/module4.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
val xs = List(1, 2, 3)
```

<img src="/scala101/images/list1.png" class="center">
<img src="/scala101/images/list1.svg" class="center">

==
<!-- .slide: class="fragmented-lists" -->
Expand All @@ -25,7 +25,7 @@ val xs = List(1, 2, 3)
val ys = 0 :: xs
```

<img src="/scala101/images/list2.png" class="center">
<img src="/scala101/images/list2.svg" class="center">

* Immutable collections can be implemented efficiently by re-using parts of existing collections
* In a linked list, pre-pending simply re-uses the existing list, and the old pointer remains valid
Expand Down
2 changes: 1 addition & 1 deletion slides/scala101/session2/module5.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ lazy val pi = veryExpensiveComputation
```scala
val discount = if (totalPrice > 100) totalPrice * 0.05 else 0.0

val x: Unit = prinln("Hello world")
val x: Unit = println("Hello world")
println(x)

// Hello world
Expand Down
2 changes: 1 addition & 1 deletion slides/scala101/session2/module7.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ for (i <- 1 to 10) println(i)
(1 to 10) foreach { println(_) }

// is equivalent to
1 to 3 foreach println
1 to 10 foreach println
```

===
Expand Down