>From
>http://docs.julialang.org/en/latest/manual/arrays/#vectorized-operators-and-functions
>
"
Note that comparisons such as == operate on whole arrays, giving a single
boolean answer. Use dot operators for elementwise comparisons."
On Thursday, September 10, 2015 at 11:36:15 AM UTC+10, J Luis wrote:
>
> Thanks. I had tried variations about this theme but expecting that the
> '==' operator would expand for the number of elements.
>
> quinta-feira, 10 de Setembro de 2015 às 02:27:11 UTC+1, Luke Stagner
> escreveu:
>>
>> Firstly, instead of using ```symbol("is_continuous")``` you can use the
>> colon notation ```:is_continuous```. Secondly, you can do element wise
>> comparison by using ```.==``` operator. This will return a BitArray. You
>> can then find where the BitArray is true by using the ```find``` function
>> which returns an array of indices.
>>
>> So for your case all you would need to do is
>> ```
>> index = find(fn .== :is_continuous)
>> ```
>>
>> On Wednesday, September 9, 2015 at 6:01:47 PM UTC-7, J Luis wrote:
>>>
>>> So I need to find position of a certain type member in a type. Easy, I
>>> though
>>>
>>> julia> fn = fieldnames(GMT_PALETTE)
>>> 9-element Array{Symbol,1}:
>>> :n_headers
>>> :n_colors
>>> :alloc_level
>>> :auto_scale
>>> :model
>>> :is_gray
>>> :is_bw
>>> :is_continuous
>>> :z_unit_to_meter
>>>
>>> julia> search(fn,"is_continuous")
>>> ERROR: MethodError: `search` has no method matching
>>> search(::Array{Symbol,1}, ::ASCIIString)
>>> Closest candidates are:
>>> search(::AbstractString, ::AbstractString)
>>> search(::AbstractString, ::AbstractString, ::Integer)
>>>
>>> Went to the docs and found the "symbol" function and though, ok now it
>>> will work
>>>
>>> julia> search(fn,symbol("is_continuous"))
>>> ERROR: MethodError: `search` has no method matching
>>> search(::Array{Symbol,1}, ::Symbol)
>>>
>>> Ok, I can do a loop over the number of elements and ask
>>>
>>> fn[k] == symbol("is_continuous")
>>>
>>> but isn't there a more compact way of do this ?
>>>
>>> (I confess this parts of Julia are annoying)
>>>
>>> Thanks
>>>
>>