Skip to content

Commit

Permalink
proofreading
Browse files Browse the repository at this point in the history
  • Loading branch information
michalporeba committed Jan 28, 2024
1 parent 4e4cb0e commit 0a63772
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ We could be more verbose in the checks using `and`.
```clojure
(and (zero? (rem num 3)) (zero? (rem num 7)))
```
The return is `"PlingPlong"` only if the number is divisable by 3 and 7 but not by 5.
The return is `"PlingPlong"` only if the number is divisible by 3 and 7 but not by 5.
We don't have to worry about the "not by 5" because of the order of operations.
We can then use the fact that a number is only divisible by 3 and 7 only if it is divisible by 3 * 7.
And so, we can express the above like this:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
:always (or (str number))))
```

Unlike `cond`, the matching condition doesn't stop evaluation of the further conditions.
Instead, every matched condition leads to an operation on a value output of which is passed down to the next matching condition.
Unlike `cond`, the matching condition doesn't stop the evaluation of the further conditions.
Instead, every matched condition leads to an operation on a value with the output passed to the next operation dictated by the next matching condition.
This allows for very concise code that behaves just like the [step by step approach][step-by-step].

[step-by-step]: https://exercism.org/tracks/clojure/exercises/raindrops/approaches/step-by-step
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
(if (empty? sound) (str num) sound)))
```

In the above example the individual sounds of rain are calculated separately and then added to make up the overall sound.
Then we can use the bindings created by `let` to check if the `sound` is empty and return either the sound or the nubmer.
In the above example, the individual sounds of rain are calculated separately and then added to make up the overall sound.
Then we can use the bindings created by `let` to check if the `sound` is empty and return either the sound or the number.

A variant of this approach can use the thread first macro `->` and private functions.

Expand All @@ -28,4 +28,4 @@ A variant of this approach can use the thread first macro `->` and private funct
sound))
```

Using the thread first macro makes the `convert` function simpler if not clearer, but it comes at the cost of extra complexity in the `pling`, `plang`, `plong` and `sound` functions.
Using the thread first macro makes the `convert` function simple, if not clearer, but it comes at the cost of extra complexity in the `pling`, `plang`, `plong` and `sound` functions.

0 comments on commit 0a63772

Please sign in to comment.