On Tue, Aug 30, 2016 at 3:55 PM, Yichao Yu <[email protected]> wrote:

>
>
> On Tue, Aug 30, 2016 at 3:39 PM, Kristoffer Carlsson <
> [email protected]> wrote:
>
>> t = ()
>> condition = true
>> for i = 1:N
>>     if condition==true
>>         t = (t..., i)
>>
>
> Note that you shouldn't do this unless you only have very few elements.
>

And even then, this completely looses the advantage of using tuple
(inferrable size and element types) so you shouldn't do this in general
unless you are going to do a lot of work with the tiny tuple afterwards.


>
>
>>     end
>> end
>>
>>
>> This does not modify the tuple but replaces it with a new longer one.
>>
>> On Tuesday, August 30, 2016 at 7:26:29 AM UTC+2, Alexei Serdiuk wrote:
>>>
>>> Hi,
>>>
>>> I need to choose items from a range (1:N) according to some condition
>>> and to push them into a tuple.
>>>
>>> I understand how to add items into an array:
>>> t=Array()
>>> for i = 1:N
>>>      if condition==true
>>>           push!(t, i)
>>> end; end
>>>
>>> Is there a way to push them into a tuple?
>>>
>>> Thanks.
>>>
>>
>

Reply via email to