[chuck-users] How to compare strings?
Manfred Brockhaus
manfred.brockhaus at chello.at
Sun Sep 4 08:34:35 EDT 2005
I figured out that 'associative arrays' can be used for string
comparison, ie. by associating unique numbers with the strings to be
checked. For example
int x[0];
1 => x["abc"];
2 => x["def"];
...
Now a string variable s can be checked for equality by writing
if(x[s]==x["abc"])...
Note that this works without explicit use of the numbers.
-mb
On Sep 3, 2005, at 8:46 PM, Manfred Brockhaus wrote:
> Thanks for the clarification. No big problem actually. I'm quite
> confident that the brilliant team will complete the language as soon
> as possible.
>
> -mb
>
> On Sep 3, 2005, at 7:49 PM, Adam R. Tindale wrote:
>
>> Hi,
>>
>> Right now string operations are quite limited. You can't cast
>> strings, as mentioned in an earlier post, and you can't concatenate
>> strings. Right now strings are stored as object references. You can
>> make this work:
>>
>> if (s==s)<<<"yes">>>;
>>
>> But that isn't very useful.
>>
>> String operations have become a popular item in demand and I think it
>> is on the queue for development.
>>
>> I know this isn't a satisfactory answer but most of the dev team is
>> in Europe for ICMC and I thought I would try to give you an answer in
>> the interim.
>>
>> --art
>>
>>
>> On Sep 3, 2005, at 1:26 AM, Manfred Brockhaus wrote:
>>
>>> I'm trying to check strings for equality but the following doesn't
>>> work
>>>
>>> "abc" => string s;
>>> if(s=="abc"){<<<"yes">>>;}
>>>
>>> -mb
>>>
>>> _______________________________________________
>>> chuck-users mailing list
>>> chuck-users at lists.cs.princeton.edu
>>> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>>>
>>
>>
>> _______________________________________________
>> chuck-users mailing list
>> chuck-users at lists.cs.princeton.edu
>> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>>
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
More information about the chuck-users
mailing list