# \`ParseError\` when reducing for short-circuit evaluation

**URL:** https://discourse.julialang.org/t/parseerror-when-reducing-for-short-circuit-evaluation/116458
**Category:** New to Julia
**Created:** [July 1, 2024, 7:36am UTC](https://discourse.julialang.org/t/parseerror-when-reducing-for-short-circuit-evaluation/116458 "2024-07-01T07:36:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![rmsmsgood](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rmsmsgood/32/20544_2.png) [@rmsmsgood](https://discourse.julialang.org/u/rmsmsgood)
#### Post date: [July 1, 2024, 7:36am UTC](https://discourse.julialang.org/t/parseerror-when-reducing-for-short-circuit-evaluation/116458/1 "2024-07-01T07:36:29Z")

</div>

## Motive

Hi, I have bit tensors to find fixed point of 3-dimensional ODE and I tried drawing nullcline first. Because intersection of nullcline is a candidate of fixed point, I have to evaluate so many times. I want to use short cirquit evaluation `&&` due to performance issue.

## Questions

But I found the operator `&&` couldn’t used in reduce.

1. Is it intentional? Why `&&` only doesn’t work while `&` works?
2. Is there any breakthrough?

```julia-auto
julia> reduce(&, [true, false, true])
false

julia> reduce(&&, [true, false, true])
ERROR: ParseError:
# Error @ c:\Users\rmsms\OneDrive\lab\population_dynamics\src\ddm.jl:89:8

reduce(&&, [true, false, true])
# └┘ ── invalid identifier
Stacktrace:
 [1] top-level scope
   @ c:\Users\rmsms\OneDrive\lab\population_dynamics\src\ddm.jl:89

```

## Enviroment

- julia v1.10.0
- windows 11

---

<div class="post-metadata">

### Author: ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)
#### Post date: [July 1, 2024, 12:25pm UTC](https://discourse.julialang.org/t/parseerror-when-reducing-for-short-circuit-evaluation/116458/2 "2024-07-01T12:25:49Z")

</div>

Not exactly answering your question, but you can use `all` (which is short-circuiting).

Perhaps obvious, but be sure to construct the iterator (the `[true, false, true]` in your MWE) so it does not first construct a Vector of Bool (which would evaluate all terms first).

---

<div class="post-metadata">

### Author: ![\_bernhard](https://avatars.discourse-cdn.com/v4/letter/_/bc79bd/32.png) [@\_bernhard](https://discourse.julialang.org/u/_bernhard)
#### Post date: [July 1, 2024, 12:43pm UTC](https://discourse.julialang.org/t/parseerror-when-reducing-for-short-circuit-evaluation/116458/3 "2024-07-01T12:43:32Z")

</div>

That’s simply because `&` is a function, but `&&` is not.  
Also, this is basically a requirement, because in function calls all arguments are evaluated first.  
However, not evaluating arguments in some situations is exactly the purpose of the short-circuit `&&`.
