Ok, I googled Record.hasFeature, and I don't quite understand how it
works?  Can I just give it the value say X1 in my example,
or do I need to give it the key and value.  I'm looking to do it in
the context of a French English Translator.  Where I will check
the french word to see if each word is singular or plural.  I have
both sets of words set up in different lists.  So I would like to
search the record to see if it is in the single list and then if it is
not I know it is plural, and every word that has a plural version must
be
plural for the sentance to be correct.  So I can't pass the key to the
has.Feature function.  Is there another way?


>If you want to check whether a record contains a value as a key, you
>can use "Record.hasFeature":
>
>{Show {Record.hasFeature unit(test:42) test}}
>
>This is an efficient function with constant lookup time.
>
>If you want to know whether one of the fields of a record is equal to
>a value, you can either convert it to a list and use List.member, like
>this:
>
>{Show {List.member 42 {Record.toList unit(test:42)}}}
>
>Or you use the high-order function Record.some like this:
>
>{Show {Record.some unit(test:42) fun {$ V} V==42 end}}
>
>Both of these methods have a O(N) lookup time, i.e. the larger the
>record, the slower the test will be.
>
>Hope this helps,
> Wolfgang
>
>On Sun, Oct 3, 2010 at 2:15 PM, Peter Breitsprecher
><pkbreits at lakeheadu.ca 
><http://lists.gforge.info.ucl.ac.be/mailman/listinfo/mozart-users>> wrote:
>>* I am trying to write a very simple little program that will search a 
>>record*>>* and give me a result of true if the word is in the record, false 
>>if it*>>* isn't.*>>**>>* as an example...*>>**>>* Lex=lex(1:X1 2:X2 3:X3 
>>4:X4)*>>**>>* declare*>>*      fun {IsItThere W}*>>*           if Lex.W \=nil 
>>then true*>>*      else*>>*           false*>>*      end*>>* end*>>**>>* 
>>Firstly it doesn't work right, and I think I have the semantics wrong for*>>* 
>>using a record.  If it were a list i would use the case statement and 
>>pull*>>* the head off compare them, and repeat it until the list was nil.  
>>But for a*>>* record to see if it is in there at all, you just have to 
>>{Browse Lex.W} and*>>* it would come up with the result if it is there or an 
>>error if it isn't.*>>* Can I make this a boolean function easily?*>>**>>* 
>>Kurt*>>* --*>>* Kurt Breitsprecher*>>* (807) 474-9601*>>* pkbreits at 
>>lakeheadu.ca 
>><http://lists.gforge.info.ucl.ac.be/mailman/listinfo/mozart-users>*>>**>>* 
>>_________________________________________________________________________________*>>*
>> mozart-users mailing list*>>* mozart-users at mozart-oz.org 
>><http://lists.gforge.info.ucl.ac.be/mailman/listinfo/mozart-users>*>>* 
>>http://www.mozart-oz.org/mailman/listinfo/mozart-users*>>**



-- 
Kurt Breitsprecher
(807) 474-9601
[email protected]
_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to