Multidimensional Array Comprehension in Julia

后端 未结 7 1275
既然无缘
既然无缘 2021-01-11 12:50

I\'m mucking about with Julia and can\'t seem to get multidimensional array comprehensions to work. I\'m using a nightly build of 0.20-pre for OSX; this could conceivably be

7条回答
  •  不知归路
    2021-01-11 13:10

    I kind of like the answer @fawr gave for the efficiency of the datatypes while retaining mutability, but this quickly gets you what you asked for (working off of Shawn's answer):

    hcat(1:5,6:10)
    hcat({i for i=1:5},falses(5))
    

    The cell-array comprehension in the second part forces the datatype to be Any instead of IntXX

    This also works:

    hcat(1:5,{i for i in falses(5)})
    

    I haven't found another way to explicitly convert an array to type Any besides the comprehension.

提交回复
热议问题