Messages from list : cormas@cirad.fr

Choose a topic among the following archives :

name variables with printString

New Message Reply Date view Thread view Subject view Author view

Subject: name variables with printString
From: Joelle Noailly (noailly@tinbergen.nl)
Date: Tue Apr 20 2004 - 09:25:54 CEST

Hi everyone,

Thank you Bruno for answering my questions about collections so quickly!
It works fine!

I actually have another question for the Cormas forum. I have a set of
10 variables called var1, ... var10. I want to associate values to these
variables using a loop. I thought of writing something like:
1 to: 10 do: [:i | self ('var', printString i): 100]
but this does not seem to work. Should I use a perform command or
something like that?
Thanks for your help,

cheers,
Joelle Noailly

Bruno Locatelli wrote:

>Hi Joelle,
>
>
>
>>I am trying to create a collection of individual collections. For
>>instance, I have a series of n elements, each one composed of 5 objects
>>as follows: element_1={a, b, c, d, e}, element_2= {b, c, d, e, a}, ...
>>element_n={e, e, d, c, a}.
>>Now, I want to combine all these elements into a big collection of the
>>
>>
>form:
>
>
>>Coll={element_1, element_2, ..., element_n}.
>>
>>
>
>If you write the following code, you will
>create a "myBigCollection" containing collections.
>
>myBigCollection := OrderedCollection new.
>anElement1 := OrderedCollection new.
>anElement1 add: #a.
>anElement1 add: #b.
>anElement1 add: #c.
>anElement1 add: #d.
>anElement1 add: #e.
>myBigCollection add: anElement1.
>etc...
>
>
>
>>The tricky part is that I also would like to ask the program to browse
>>through the big collection. For instance, check if the element
>>corresponding to {b,c,d,e,a} is in the big collection, and if yes,
>>delete it.
>>
>>
>
>You can work with your "big collection", as you do with any collection.
>For instance, to remove an element:
>
>searchedElement := OrderedCollection new.
>searchedElement add: #b.
>searchedElement add: #c.
>searchedElement add: #d.
>searchedElement add: #e.
>searchedElement add: #a.
>myBigCollection remove: searchedElement ifAbsent: [ ]
>
>Another example: if you want to select the elements that contain 'a' as a
>first symbol:
>
>myBigCollection select: [:e | e first = #a]
>
>Suerte!
>Ciao
> bruno
>_____________________________
>
>Bruno Locatelli
>Global Change Group / Grupo Cambio Global
>CIRAD Forêt (www.cirad.fr) - CATIE (www.catie.ac.cr/cambioglobal)
>Apdo 2, Turrialba 7170
>Costa Rica
>
>Tel: 506.558.22.16
>Fax: 506.556.62.55
>Email: bruno@melix.org
>Web perso: http://www.locatelli1.net
>________________________________
>
>

New Message Reply Date view Thread view Subject view Author view
 

Back to home