# Syntax error in parallel computing

**URL:** <https://discourse.julialang.org/t/syntax-error-in-parallel-computing/90378>\
**Category:** Performance\
**Created:** [November 17, 2022, 3:10am UTC](https://discourse.julialang.org/t/syntax-error-in-parallel-computing/90378 "2022-11-17T03:10:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marouane](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marouane/32/16267_2.png) [@marouane](https://discourse.julialang.org/u/marouane)\
**Post date:** [November 17, 2022, 3:10am UTC](https://discourse.julialang.org/t/syntax-error-in-parallel-computing/90378/1 "2022-11-17T03:10:28Z")

</div>

I’m trying to learn parallel computing using `Distributed` and I tried the `Pi` computation as an example:

```julia
using Distributed
addprocs(4)
function points_inside(n)
    n_in= 0
    for i=1:n
        x,y= rand(), rand()
        n_in+= (x*x+ y*y)<= 1
    end
    return n_in
end

```

points\_inside (generic function with 1 method)  
In [8]:

```julia
function pi_p(n)
    p= nworkers()
    n_in= @distributed(+) for i=1:p
        points_inside(n/p)
    end
    return 4*n_in/n
end

```

and I get this syntax error:

```julia
syntax: "function" at In[8]:1 expected "end", got "for"

Stacktrace:
 [1] top-level scope
   @ In[8]:3
 [2] eval
   @ ./boot.jl:373 [inlined]
 [3] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base ./loading.jl:1196

```

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [November 17, 2022, 3:18am UTC](https://discourse.julialang.org/t/syntax-error-in-parallel-computing/90378/2 "2022-11-17T03:18:47Z")

</div>

> [@marouane](#):
>
> `@distributed(+)`

add a space  
`@distributed (+)`

---

<div class="post-metadata">

**Author:** ![marouane](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marouane/32/16267_2.png) [@marouane](https://discourse.julialang.org/u/marouane)\
**Post date:** [November 17, 2022, 3:20am UTC](https://discourse.julialang.org/t/syntax-error-in-parallel-computing/90378/3 "2022-11-17T03:20:59Z")

</div>

oh yeah i didn’t pay attention to that it is working now.
