Thank you very much, it works!

I'll explain you why I want to use tuples.
I have a range of products 1:N. Every product can be made of several 
mutually exclusive bases. I need to make a lot of loop of this kind

for k in Products, b in Bases
      if accordance[k,b]=true
          ...
end; end



I want to create an array of tulpes, so that I could decrease my loops to

for k in Products, b in Bases[k]

where Bases[1] is the tuple of bases for product[1]

I could use an array, but one product can correspond to different number of 
bases.

That's why I decided to use tuples.

Thanks again!

вторник, 30 августа 2016 г., 10:58:00 UTC+3 пользователь Yichao Yu написал:
>
>
>
> On Tue, Aug 30, 2016 at 3:55 PM, Yichao Yu <[email protected] <javascript:>
> > wrote:
>
>>
>>
>> On Tue, Aug 30, 2016 at 3:39 PM, Kristoffer Carlsson <[email protected] 
>> <javascript:>> 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