Browse Groups

• ## probably stupid question of the day

(3)
• NextPrevious
• Why do we have to provide the type + the comparison fonction when we create a set? Isn t the comparison function the only parameter that should be needed to
Message 1 of 3 , Jun 5
View Source
Why do we have to provide the type + the comparison
fonction when we create a set?

Isn't the comparison function the only parameter
that should be needed to "specialize" a set?
• Because, you may have a comparison function that do not use every element of the type actually operate the comparison. For example, a record with an index and
Message 1 of 3 , Jun 9
View Source
Because, you may have a comparison function that do not use every element
of the type actually operate the comparison. For example, a record with an
index and any kind of data where you want data to be ordered by index..

2013/6/5 Francois Berenger <berenger@...>

> **
>
>
> Why do we have to provide the type + the comparison
> fonction when we create a set?
>
> Isn't the comparison function the only parameter
> that should be needed to "specialize" a set?
>
>

[Non-text portions of this message have been removed]
• ... When you apply the functor, you need to specialize the type of elements held in a set. That s because you need to somehow connect the type of the elements
Message 1 of 3 , Jun 9
View Source
On Wed, Jun 5, 2013 at 9:04 AM, Francois Berenger <berenger@...> wrote:

> **
>
>
> Why do we have to provide the type + the comparison
> fonction when we create a set?
>
> Isn't the comparison function the only parameter
> that should be needed to "specialize" a set?
>

When you apply the functor, you need to specialize the type of elements
held in a set. That's because you need to somehow connect the type of the
elements in the set with the type accepted by your comparison function. The
only other option would be that the comparison function is polymorphic with
respect to elements it compares, which would be rather useless.

[Non-text portions of this message have been removed]
Your message has been successfully submitted and would be delivered to recipients shortly.
• Changes have not been saved
Press OK to abandon changes or Cancel to continue editing
• Your browser is not supported
Kindly note that Groups does not support 7.0 or earlier versions of Internet Explorer. We recommend upgrading to the latest Internet Explorer, Google Chrome, or Firefox. If you are using IE 9 or later, make sure you turn off Compatibility View.