JuliaLang / JuliaDoc

28 stars 26 forks source link

count_heads.jl in parallel-computing section failing #14

Closed rsmaior closed 9 years ago

rsmaior commented 9 years ago

See it here: http://docs.julialang.org/en/latest/manual/parallel-computing/#parallel-map-and-loops

function count_heads(n)
    c::Int = 0
    for i=1:n
        c += rand(Bool)
    end
    c
end

I think rand(Bool) is wrong. So the code above is failing for me. The code below is working:

function count_heads(n)
    c::Int = 0
    for i=1:n
        c += rand(Int64)
    end
    c
end
rsmaior commented 9 years ago

Another code failing for me is

nheads = @parallel (+) for i=1:200000000
  Int(rand(Bool))
end

Obs.: Forgot to say, but the error I get with the two codes is:

exception on 4: ERROR: no random number generator for type Bool; try a more specific type
 in error at error.jl:21
 in anonymous at no file:2
 in anonymous at multi.jl:1279
 in anonymous at multi.jl:848
 in run_work_thunk at multi.jl:621
 in run_work_thunk at multi.jl:630
 in anonymous at task.jl:6
IainNZ commented 9 years ago

This repository is for the code that generates the documentation - if the docs are wrong, then please file an issue on the main Julia repository (https://github.com/JuliaLang/julia/issues).

IainNZ commented 9 years ago

Are you using Julia 0.3? That link is to the docs for (unreleased) Julia 0.4

rsmaior commented 9 years ago

Yes, I'm with julia-0.3.8 (ubuntu linux) Should I open a new issue in https://github.com/JuliaLang/julia/issues or 'move' to the correct place?

rsmaior commented 9 years ago

Using the correct documentation (version 0.3) http://docs.julialang.org/en/release-0.3/manual/parallel-computing/#parallel-map-and-loops I have no issue... So this is not an issue at all.