# [plt-scheme] How to make unit functors?

 From: Robby Findler (robby at cs.uchicago.edu) Date: Wed May 28 12:46:33 EDT 2003 Previous message: [plt-scheme] How to make unit functors? Next message: [plt-scheme] How to make unit functors? Messages sorted by: [date] [thread] [subject] [author]

```I think that the proper interpretation of the prose is:

for any values, v1 and v2,

(eq? v1 v2)
=>
(and (number? (eq-hash-code v1))
(number? (eq-hash-code v2))
(= (eq-hash-code v1) (eq-hash-code v2)))

The reverse implication may or may not be true (it's usually true, tho.
Isn't this the usual story for hashing?)

The text goes on to guarantee that this:

(eq? v1 v2)
=>
(and (number? (eq-hash-code v1))
(number? (eq-hash-code v2))
(eq? (eq-hash-code v1) (eq-hash-code v2)))

which, as the text notes, implies that the numbers are fixnums. Another
way to put it:

(eq? v1 v2)
=>
(and (number? (eq-hash-code v1))
(number? (eq-hash-code v2))
(fixnum? (eq-hash-code v1))
(fixnum? (eq-hash-code v2))
(= (eq-hash-code v1) (eq-hash-code v2)))

where fixnum? can (I think) be defined as:

(define (fixnum? n)
(and (number? n)
(exact? n)
(integer? n)
(eq? (- (+ n 1) 1) n)))

I'm not sure why there isn't a fixnum predicate built in (or maybe I
just missed it?)

Robby

At Wed, 28 May 2003 18:35:05 +0200, =?Windows-1252?Q?Jens_Axel_S=F8gaard?= wrote:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> Matthew Flatt wrote:
>
>
> >> Is the same also true for symbols? That is does it hold for two
> >> symbols s1 and s2 that
> >>
> >>   (= (eq-hash-code s1) (eq-hash-code s2)) =  (symbol=? s1 s2)
> >>
> >> ?
> >
> > Yes. `symbol=?' is `eq?' with its domain restricted to symbols.
>
> Sorry, I intended to ask this question:
>
>   Is the same also true for symbols? That is does it hold for two
>   symbols s1 and s2 that
>
>      (= (eq-hash-code s1) (eq-hash-code s2)) =>  (symbol=? s1 s2)
>   ?
>
> [otherwise the question is a bit silly]
>
> I interpreted the prose describing eq-hash-code as
>
> For all fixnums f1 and f2:
>
>   (= (eq-hash-code f1) (eq-hash-code f2)) =>  (= f1 f2)
>
> and wanted to know if it also holds for symbols.
>
> --
> Jens Axel Søgaard
>
>

```

 Posted on the users mailing list. Previous message: [plt-scheme] How to make unit functors? Next message: [plt-scheme] How to make unit functors? Messages sorted by: [date] [thread] [subject] [author]