-
Notifications
You must be signed in to change notification settings - Fork 0
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
Chore - Intro code examples #8
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the improvements @hhandoko. I have a couple of MD syntax related issues and the .gitignore
that I would like to be improved as well.
@@ -1,2 +1,266 @@ | |||
*.class | |||
*.log | |||
# Created by https://www.gitignore.io/api/osx,vim,code,linux,emacs,windows,eclipse,intellij+all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know nobody really looks into .gitignore
but I generally dislike generated bloat like this. As a developer I want to understand what files are being created in the project directory and why. If those are my custom tools, I would ignore them at ~/.gitignore
level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I'll add some comments with a bit of explanation.
My goal here was to ignore all system / OS-specific files (like OSX's .DStore
) and editor / IDE config files which gets generated automatically and often accidentally committed.
I'm covering three main OS (Win, OSX, *nix) and common editors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the .gitignore
starts mentioning files that you didn't even know existed, there is a risk of accidentally not committing a file. And the pursuit of ignoring all system files is pointless because you never know what strange tools and temp files people are going to have. That's why Git has a user-specific ~/.gitignore
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense... I'll revert.
exercises/intro/README.md
Outdated
<center> | ||
<small> | ||
_(source: [Loop1.java](https://github.com/SingaporeScalaProgrammers/scala-workshop/blob/master/references/intro/src/main/java/Loop1.java))_ | ||
</small> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this syntax doing? In the preview https://github.com/SingaporeScalaProgrammers/scala-workshop/blob/a5773757e08d4a1de72ce544d59927766104ca9e/exercises/intro/README.md it's not looking nice. Not sure how is it intended be rendered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Complete fail 😁 I'll figure out alternative format (and keep it readable in raw MD).
exercises/intro/README.md
Outdated
program while learning core FP concepts such as: | ||
|
||
* referential transparency, | ||
* expression-based programming, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Breaking down long sentences in bullet points is good 👍
exercises/intro/README.md
Outdated
variable is inferred from the right-hand side of the assignment, `Int` in | ||
this case; | ||
3. `1 to 10` defines a inclusive `Range` – a sequence that can be enumerated; | ||
4. `for (x <- seq) { ...x... }` enumerates elements of `seq` executing the | ||
1. `1 to 10` defines a inclusive `Range` – a sequence that can be enumerated; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that MD renderer will turn this into a numbered list, but I prefer the text itself to be readable too (that was the selling point of MD, IIRC). A numbered list with ones somewhat defeats that purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, will revert.
intro/src/main/java/Loop1.java
Outdated
@@ -0,0 +1,12 @@ | |||
public class Loop1 { | |||
public static void main(String[] args) { | |||
int sum = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea to put all the steps there. For a small tutorial like this it's good to have all the steps constantly present and it's not too many of them.
@@ -513,7 +513,7 @@ def isEven(x: Int): Boolean = x % 2 == 0 | |||
def square(x: Int): Int = x * x | |||
|
|||
def sumOfEvenSquares(max: Int): Int = { | |||
(1 to 10) | |||
(1 to max) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch 👍
def iterate(max: Int): List[Int] = ??? | ||
def filterEven(xs: List[Int]): List[Int] = ??? | ||
def square(xs: List[Int]): List[Int] = ??? | ||
def sum(xs: List[Int]): Int = ??? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good trick 👍 I didn't think about using ???
to show the intermediary step here.
exercises/intro/README.md
Outdated
|
||
Collection API | ||
-------------- | ||
|
||
By a lucky coincidence Scala standard library collection API already provides | ||
most of the functions that we've just discovered. It would be a shame not to | ||
use them: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This supposed to be a joke 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wooosh 😅 I'll add air quotes, haha.
@shishkin I've made the changes as we discussed. I've also uploaded the diff preview files. Note that the diff links on the MD file points to the master branch (which will 404 until this PR is merged). Have a look here for a preview: https://rawgit.com/SingaporeScalaProgrammers/scala-workshop/chore/intro_code_examples/references/intro/diff/Loop3-Loop4.html |
@@ -0,0 +1,260 @@ | |||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I see what did you mean with the diff.
As mentioned in the group discussion, I've split the exercise code from the example / reference code and updated the
README.md
accordingly.The exercise code now resides under
exercises/
and the example / reference underreferences/
. I've made links to the code snippets to the relevant source files to make it easier to navigate. There are also minor fixes to the example code, where a parameter argument is not being used (but I assume is needed).In regards to
README.md
, mainly: