* Re: [Caml-list] Comparison of functional values
@ 2001-03-06 22:17 Arturo Borquez
0 siblings, 0 replies; 5+ messages in thread
From: Arturo Borquez @ 2001-03-06 22:17 UTC (permalink / raw)
To: andrieu; +Cc: caml-list
On Tue, 06 March 2001, Olivier Andrieu wrote:
>
>
> Hello list,
>
> I wanted to build a Set of functional value. But generic equality
> can't be used for functional values (raises an exception ...). It is
> therefore difficult to build a Set of such values because the Set.Make
> functor requires a comparison function and Pervasives.compare relies
> on (=).
>
> Is there a way around this ? I thought I could use physical equality
> (wich is OK wrt functional values) but there's no such thing as
> `physical inequality'.
>
> --
> Olivier Andrieu
> -------------------
> To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
Hi Olivier:
Perhaps this help
let a = fun f x -> x = x;;
let b = fun f x -> x = x;;
(a == b) = true;;
-: bool = false
not (a == b) = true;;
-: bool = true
Regards
Arturo Borquez
Find the best deals on the web at AltaVista Shopping!
http://www.shopping.altavista.com
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Comparison of functional values
2001-03-07 8:49 ` [Caml-list] Comparison of functional values Olivier Andrieu
@ 2001-03-07 8:56 ` Xavier Leroy
0 siblings, 0 replies; 5+ messages in thread
From: Xavier Leroy @ 2001-03-07 8:56 UTC (permalink / raw)
To: Olivier Andrieu; +Cc: Alan Schmitt, caml-list, Juergen Pfitzenmaier
> What I meant actually, was a «physical compare». I found out that
> this (crude) C function works :
>
> value phys_comp(value a, value b)
> {
> if(a<b)
> return Val_int(-1) ;
> else if(a>b)
> return Val_int(+1) ;
> else
> return Val_int(0);
> }
No, it does not: the GC can copy heap blocks and change the relative
ordering of their memory addresses. You really need to pair your
functions with unique identifying integers.
- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Comparison of functional values
2001-03-06 22:08 ` Juergen Pfitzenmaier
@ 2001-03-07 8:49 ` Olivier Andrieu
2001-03-07 8:56 ` Xavier Leroy
0 siblings, 1 reply; 5+ messages in thread
From: Olivier Andrieu @ 2001-03-07 8:49 UTC (permalink / raw)
To: Alan Schmitt; +Cc: caml-list, Juergen Pfitzenmaier
Alan Schmitt [Wednesday 7 March 2001] :
> As stated in http://caml.inria.fr/ocaml/htmlman/manual031.html, != is
> the negation of ==.
Salut Alan !
I known. But to use the Set functor, you need a `compare' function of
type ('a -> 'a -> int) whereas != and == have type ('a -> bool).
So != does not seem very helpful here.
What I meant actually, was a «physical compare». I found out that
this (crude) C function works :
value phys_comp(value a, value b)
{
if(a<b)
return Val_int(-1) ;
else if(a>b)
return Val_int(+1) ;
else
return Val_int(0);
}
Olivier
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Comparison of functional values
2001-03-06 21:51 Olivier Andrieu
@ 2001-03-07 5:20 ` Alan Schmitt
2001-03-06 22:08 ` Juergen Pfitzenmaier
0 siblings, 1 reply; 5+ messages in thread
From: Alan Schmitt @ 2001-03-07 5:20 UTC (permalink / raw)
To: Olivier Andrieu; +Cc: caml-list
>Is there a way around this ? I thought I could use physical equality
>(wich is OK wrt functional values) but there's no such thing as
>`physical inequality'.
>
As stated in http://caml.inria.fr/ocaml/htmlman/manual031.html, != is
the negation of ==.
Alan Schmitt
--
The hacker: someone who figured things out and made something cool happen.
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Caml-list] Comparison of functional values
@ 2001-03-06 21:51 Olivier Andrieu
2001-03-07 5:20 ` Alan Schmitt
0 siblings, 1 reply; 5+ messages in thread
From: Olivier Andrieu @ 2001-03-06 21:51 UTC (permalink / raw)
To: caml-list
Hello list,
I wanted to build a Set of functional value. But generic equality
can't be used for functional values (raises an exception ...). It is
therefore difficult to build a Set of such values because the Set.Make
functor requires a comparison function and Pervasives.compare relies
on (=).
Is there a way around this ? I thought I could use physical equality
(wich is OK wrt functional values) but there's no such thing as
`physical inequality'.
--
Olivier Andrieu
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2001-03-07 8:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-06 22:17 [Caml-list] Comparison of functional values Arturo Borquez
-- strict thread matches above, loose matches on Subject: below --
2001-03-06 21:51 Olivier Andrieu
2001-03-07 5:20 ` Alan Schmitt
2001-03-06 22:08 ` Juergen Pfitzenmaier
2001-03-07 8:49 ` [Caml-list] Comparison of functional values Olivier Andrieu
2001-03-07 8:56 ` Xavier Leroy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox