Public
Authored by Ahmadou Dicko

Count bool R and Julia

Count bool in R and Julia

Edited
fcount.R 257 Bytes
  • The original Julia code

    function fcount(x::Vector{Bool})
        sumx = sum(x)
        Dict{Bool, Int}(true => sumx, false => length(x) - sumx)
    end
    
    srand(2)
    bool = rand(Bool, 1000000000)
    @time fcount(bool)
    # 0.612951 seconds (629 allocations: 36.195 KiB)
    # Dict{Bool,Int64} with 2 entries:
    #   false => 499978312
    #   true  => 500021688
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment