On Mon, Aug 29, 2016 at 3:59 PM, Jared Crean <[email protected]> wrote:

> Here is an oddity:
>
> julia> s
> Set([2,3,1])
>
> julia> in(s, 2)
> false
>
> julia> in(2, s)
> true
>
> I would have though the first use of in would be an error because asking
> if a set is contained in a number is not defined.  Is there some other
> interpretation of the operation?
>

In Julia, every number is a collection that contains just this number. Thus
you are essentially asking whether the set `s` is equal to this number,
which it is not.

-erik

On Monday, August 29, 2016 at 3:27:30 PM UTC-4, Jared Crean wrote:
>>
>> Ah, yes.  That's it.
>>
>>   Thanks,
>>     Jared Crean
>>
>> On Monday, August 29, 2016 at 3:11:02 PM UTC-4, Erik Schnetter wrote:
>>>
>>> Jared
>>>
>>> Are you looking for the function `in`?
>>>
>>> -erik
>>>
>>> On Mon, Aug 29, 2016 at 3:06 PM, Jared Crean <[email protected]> wrote:
>>>
>>>> I'm looking for a data structure that allows O(1) querying if a value
>>>> is contained in the data structure, and reasonably fast construction of the
>>>> data structure given that the initial size is unknown (although this
>>>> criteria is not that strict).  I was looking at the Set in base, but I
>>>> can't find a way to test if a Set contains contains a particular value.  I
>>>> also don't know about the efficiency of appending to a Set.  Any
>>>> suggestions or information about Set would be appreciated.
>>>>
>>>>     Jared Crean
>>>>
>>>
>>>
>>>
>>> --
>>> Erik Schnetter <[email protected]> http://www.perimeterinstitute.
>>> ca/personal/eschnetter/
>>>
>>


-- 
Erik Schnetter <[email protected]>
http://www.perimeterinstitute.ca/personal/eschnetter/

Reply via email to