Skip to content

Instantly share code, notes, and snippets.

@kozross
Created June 11, 2018 23:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kozross/2288462f09b62c58098e21e42f4d6b9e to your computer and use it in GitHub Desktop.
Save kozross/2288462f09b62c58098e21e42f4d6b9e to your computer and use it in GitHub Desktop.
arr = [5, 8, 11, 0]
function bitat(x,i)
x & (1 << (i - 1)) != 0
end
y = BitMatrix(bitat(arr[i], j) for i in 1:4, j in 1:4)
#=
This fails, claiming:
MethodError: Cannot `convert` an object of type Base.Generator{Base.Iterators.Prod2{UnitRange{Int64},UnitRange{Int64}},##9#10} to an object of type BitArray{2}
This may have arisen from a call to the constructor BitArray{2}(...),
since type constructors fall back to convert methods.
How do I spell this request properly, so that my result is a BitMatrix?
=#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment