Júlo
My "tuple type" is an actual tuple. While I could create custom comparison
operator for e.g. `Tuple{Int, Int, AbstractString}`, this would be
unorthodox, as this comparison operator would be globally visible. This
could break many things, such as e.g. dictionaries that hold tuples of
arbitrary type.
-erik
On Sun, Nov 29, 2015 at 6:08 PM, Júlio Hoffimann <[email protected]>
wrote:
> Hi Erik,
>
> All you need to do is specialize the < operator for your tuple type.
>
> Please check the definition of findmin by running:
>
> @edit findmin([1,2,3])
>
> You'll see the implementation is quite trivial. Let us know if you weren't
> able to make it work.
>
> Best,
> -Júlio
>
> Em domingo, 29 de novembro de 2015 10:04:49 UTC-8, Erik Schnetter escreveu:
>>
>> Is there a version of `findmin` that allows passing in an arbitrary
>> comparison operator?
>>
>> In throw-away code, I often have an array containing tuples of both the
>> result and some additional operator. I want to find the minimum and its
>> location, but want to ignore the additional information. I would like to
>> use a user-defined comparison operator that looks only at one of the tuple
>> elements, yet `findmin` doesn't seem to offer this.
>>
>> -erik
>>
>> --
>> Erik Schnetter <[email protected]>
>> http://www.perimeterinstitute.ca/personal/eschnetter/
>>
>
--
Erik Schnetter <[email protected]>
http://www.perimeterinstitute.ca/personal/eschnetter/