I am not sure what you mean - are you expecting a different behavior than
this? Both z and a are containing what they should.
julia> z = [1,2,3,4]
4-element Array{Int64,1}:
1
2
3
4
julia> a = filter(x->x<3, z)
2-element Array{Int64,1}:
1
2
julia> z
4-element Array{Int64,1}:
1
2
3
4
julia> a
2-element Array{Int64,1}:
1
2
Am Mittwoch, 18. März 2015 16:01:11 UTC+1 schrieb [email protected]:
>
> One thing I forgot to ask is .... what if I wan to keep the array as it is
> and then add to it ...if I run a = filter(x->x<3, z) ... it overwrites the
> array.
> Regards
>
> On Wednesday, 18 March 2015 14:04:45 UTC, [email protected] wrote:
>>
>> Thanks everybody - got it!
>> Regards
>>
>> On Wednesday, 18 March 2015 12:04:48 UTC, René Donner wrote:
>>>
>>> or simply
>>>
>>> a = filter(x->x<3, z)
>>>
>>> Am Mittwoch, 18. März 2015 12:46:52 UTC+1 schrieb Konstantin Markov:
>>>>
>>>> julia> a = [i for i=filter(x->x<3,z)]
>>>> 2-element Array{Any,1}:
>>>> 1
>>>> 2
>>>>
>>>>
>>>> On Wednesday, March 18, 2015 at 8:31:57 PM UTC+9, [email protected]
>>>> wrote:
>>>>>
>>>>> Hi
>>>>> I want to fill an array based on a condition - eg
>>>>>
>>>>> a = []
>>>>> z = [1,2,3,4]
>>>>>
>>>>> for i = 1:length(z)
>>>>> if i > 2
>>>>> continue
>>>>> end
>>>>> end
>>>>>
>>>>> so, I would now like to see the values 1 & 2 in my array "a"
>>>>> Regards
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>