Sorry, I made a mistake. The function is actually "Value.hasFeature"
or just "HasFeature".

See here: http://www.mozart-oz.org/documentation/base/record.html

The function also works with dictionaries and chunks (and possibly
other types?).

Wolfgang


On Mon, Oct 4, 2010 at 2:54 AM,  <[email protected]> wrote:
> I was trying to follow along in this email and my version of Mozart/Oz
> doesn't appear to have Record.hasFeature.  I am running the binaries for OS
> X.  Do I need to import anything?  The output isn't complete but here is the
> results of {Show Record} (I can't seem to copy from the tk Browse window) to
> show that my Record modules seem to be valid except for the hasFeature
> function:
>
> record(adjoin:<P/3 Record.adjoin> adjoinAt:<P/4 Record.adjoinAt>
> adjoinList:<P/3 Record.adjoinList> all:<P/3 Record.all> allInd:<P/3
> Record.allInd> arity:<P/2 Record.arity> clone:<P/2 Record.clone>
> dropWhile:<P/3 Record.dropWhile> dropWhileInd:<P/3 Record.dropWhileInd>
> filter:<P/3 Record.filter> ,,,)
>
>
> On Oct 3, 2010, at 9:27 AM, Wolfgang Meyer wrote:
>
>> 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
>> <[email protected]> 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
>>> [email protected]
>>>
>>>
>>> _________________________________________________________________________________
>>> mozart-users mailing list
>>> [email protected]
>>> http://www.mozart-oz.org/mailman/listinfo/mozart-users
>>>
>>
>> _________________________________________________________________________________
>> mozart-users mailing list
>> [email protected]
>> http://www.mozart-oz.org/mailman/listinfo/mozart-users
>
> _________________________________________________________________________________
> mozart-users mailing list
> [email protected]
> http://www.mozart-oz.org/mailman/listinfo/mozart-users
>
_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to