Created
June 11, 2018 23:23
-
-
Save kozross/2288462f09b62c58098e21e42f4d6b9e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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