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

cars-assemble: Update introduction.md #563

Merged
merged 3 commits into from
Jul 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion exercises/concept/cars-assemble/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Numbers in Clojure include:

Two common numeric types are `int` and `float`. An `int` is a 32-bit integer and a `float` is a 64-bit floating-point number.

Arithmetic is done using the standard arithmetic operators. Numbers can be compared using the standard numeric comparison operators and the equality (`=`) and inequality (`<>`) operators.
Arithmetic is done using the standard arithmetic operators. Numbers can be compared using the standard numeric comparison operators (`>`, `<`, `<=`, `>=`), the equality operator (`=`) and the non-equality operator (`not=`).

In this exercise you must conditionally execute logic. A common way to do this in Clojure is by using `cond`:

Expand All @@ -16,3 +16,14 @@ In this exercise you must conditionally execute logic. A common way to do this i
(> x 7) "Expression to evaluate when x is greater than 7"
:else "Expression to evaluate in all other cases")
```

## Note
The `==` operator might be preferable to `=` in some cases where numbers need to be compared irrespective of the exact type. For instance,
```clojure
(== 5.0 5) ;; true as both numbers are equal when type is ignored
(= 5.0 5) ;; false as the types of numbers are also taken into account here i.e. float is different from int
```
The [Clojure guide on Equality][guide-equality], specifically the section on [Numbers][guide-numbers] goes into more details.

[guide-equality]: https://clojure.org/guides/equality
[guide-numbers]: https://clojure.org/guides/equality#numbers