Merge pull request #312 from joehakimrahme/master
Uses square brackets for conds in docs
This commit is contained in:
commit
b56f03ed29
@ -173,8 +173,8 @@ code:
|
|||||||
|
|
||||||
.. code-block:: clj
|
.. code-block:: clj
|
||||||
|
|
||||||
(cond (condition-1 result-1)
|
(cond [condition-1 result-1]
|
||||||
(condition-2 result-2))
|
[condition-2 result-2])
|
||||||
|
|
||||||
(if condition-1 result-1
|
(if condition-1 result-1
|
||||||
(if condition-2 result-2))
|
(if condition-2 result-2))
|
||||||
@ -184,10 +184,10 @@ As shown below only the first matching result block is executed.
|
|||||||
.. code-block:: clj
|
.. code-block:: clj
|
||||||
|
|
||||||
=> (defn check-value [value]
|
=> (defn check-value [value]
|
||||||
... (cond ((< value 5) (print "value is smaller than 5"))
|
... (cond [(< value 5) (print "value is smaller than 5")]
|
||||||
... ((= value 5) (print "value is equal to 5"))
|
... [(= value 5) (print "value is equal to 5")]
|
||||||
... ((> value 5) (print "value is greater than 5"))
|
... [(> value 5) (print "value is greater than 5")]
|
||||||
... (True (print "value is something that it should not be"))))
|
... [True (print "value is something that it should not be")]))
|
||||||
|
|
||||||
=> (check-value 6)
|
=> (check-value 6)
|
||||||
value is greater than 5
|
value is greater than 5
|
||||||
@ -564,8 +564,8 @@ For example:
|
|||||||
.. code-block:: clj
|
.. code-block:: clj
|
||||||
|
|
||||||
=> (defn rent-car [&kwargs kwargs]
|
=> (defn rent-car [&kwargs kwargs]
|
||||||
... (cond ((in :brand kwargs) (print "brand:" (:brand kwargs)))
|
... (cond [(in :brand kwargs) (print "brand:" (:brand kwargs))]
|
||||||
... ((in :model kwargs) (print "model:" (:model kwargs)))))
|
... [(in :model kwargs) (print "model:" (:model kwargs))]))
|
||||||
|
|
||||||
=> (kwapply (rent-car) {:model "T-Model"})
|
=> (kwapply (rent-car) {:model "T-Model"})
|
||||||
model: T-Model
|
model: T-Model
|
||||||
|
@ -254,12 +254,12 @@ In hy, you would do:
|
|||||||
.. code-block:: clj
|
.. code-block:: clj
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
((> somevar 50)
|
[(> somevar 50)
|
||||||
(print "That variable is too big!"))
|
(print "That variable is too big!")]
|
||||||
((< somevar 10)
|
[(< somevar 10)
|
||||||
(print "That variable is too small!"))
|
(print "That variable is too small!")]
|
||||||
(true
|
[true
|
||||||
(print "That variable is jussssst right!")))
|
(print "That variable is jussssst right!")])
|
||||||
|
|
||||||
What you'll notice is that cond switches off between a some statement
|
What you'll notice is that cond switches off between a some statement
|
||||||
that is executed and checked conditionally for true or falseness, and
|
that is executed and checked conditionally for true or falseness, and
|
||||||
|
Loading…
Reference in New Issue
Block a user