commit
fa69d80b8d
@ -151,20 +151,14 @@ case the first false value will be returned. Examples of usage:
|
|||||||
=> (and True [] False True)
|
=> (and True [] False True)
|
||||||
[]
|
[]
|
||||||
|
|
||||||
.. note:: `and` shortcuts and stops evaluating parameters as soon as the first
|
.. note::
|
||||||
false is encountered. However, in the current implementation of Hy
|
|
||||||
statements are executed as soon as they are converted to expressions.
|
`and` shortcuts and stops evaluating parameters as soon as the first
|
||||||
The following two examples demonstrates the difference.
|
false is encountered.
|
||||||
|
|
||||||
.. code-block:: clj
|
.. code-block:: clj
|
||||||
|
|
||||||
=> (and False (print "hello"))
|
=> (and False (print "hello"))
|
||||||
hello
|
|
||||||
False
|
|
||||||
|
|
||||||
=> (defn side-effects [x] (print "I can has" x) x)
|
|
||||||
=> (and (side-effects false) (side-effects 42))
|
|
||||||
I can has False
|
|
||||||
False
|
False
|
||||||
|
|
||||||
|
|
||||||
@ -919,21 +913,13 @@ parameter will be returned.
|
|||||||
1
|
1
|
||||||
|
|
||||||
.. note:: `or` shortcuts and stops evaluating parameters as soon as the first
|
.. note:: `or` shortcuts and stops evaluating parameters as soon as the first
|
||||||
true is encountered. However, in the current implementation of Hy
|
true is encountered.
|
||||||
statements are executed as soon as they are converted to expressions.
|
|
||||||
The following two examples demonstrates the difference.
|
|
||||||
|
|
||||||
.. code-block:: clj
|
.. code-block:: clj
|
||||||
|
|
||||||
=> (or True (print "hello"))
|
=> (or True (print "hello"))
|
||||||
hello
|
|
||||||
True
|
True
|
||||||
|
|
||||||
=> (defn side-effects [x] (print "I can has" x) x)
|
|
||||||
=> (or (side-effects 42) (side-effects False))
|
|
||||||
I can has 42
|
|
||||||
42
|
|
||||||
|
|
||||||
|
|
||||||
print
|
print
|
||||||
-----
|
-----
|
||||||
|
Loading…
x
Reference in New Issue
Block a user