Skip to content

Commit

Permalink
cars-assemble: Update introduction.md (#563)
Browse files Browse the repository at this point in the history
* cars-assemble: Update introduction.md

`<>` inequality operator doesn't seem to exist in Clojure, replaced it with `not=`

* Improve wording related to comparison operators

* Add note about equality of numbers
  • Loading branch information
DevPika committed Jul 1, 2023
1 parent f36d859 commit 61bca43
Showing 1 changed file with 12 additions and 1 deletion.
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

0 comments on commit 61bca43

Please sign in to comment.