--- /srv/rebuilderd/tmp/rebuilderd8cv7Uy/inputs/racket-doc_8.16+dfsg1-3_all.deb
+++ /srv/rebuilderd/tmp/rebuilderd8cv7Uy/out/racket-doc_8.16+dfsg1-3_all.deb
├── file list
│ @@ -1,3 +1,3 @@
│ -rw-r--r-- 0 0 0 4 2025-06-21 19:24:05.000000 debian-binary
│ --rw-r--r-- 0 0 0 83076 2025-06-21 19:24:05.000000 control.tar.xz
│ --rw-r--r-- 0 0 0 35568692 2025-06-21 19:24:05.000000 data.tar.xz
│ +-rw-r--r-- 0 0 0 83072 2025-06-21 19:24:05.000000 control.tar.xz
│ +-rw-r--r-- 0 0 0 35573084 2025-06-21 19:24:05.000000 data.tar.xz
├── control.tar.xz
│ ├── control.tar
│ │ ├── ./control
│ │ │ @@ -1,13 +1,13 @@
│ │ │ Package: racket-doc
│ │ │ Source: racket
│ │ │ Version: 8.16+dfsg1-3
│ │ │ Architecture: all
│ │ │ Maintainer: David Bremner '((1 . 0) (2 . 0) (2 . 1) (3 . 1) (3 . 0) (4 . 1) (3 . 2) (4 . 2) (5 . 2) (4 . 0))(define (swap-components x) (cons (cdr x) (car x))) (define other-ordered-pair/e (map/e swap-components swap-components ordered-pair/e #:contract (cons/c natural? natural?))) > (for/list ([i (in-range 10)]) (from-nat other-ordered-pair/e i))
> (map/e (λ (x) (floor (/ x 100))) (λ (x) (* x 100)) natural/e #:contract natural?) map/e: contract violation;
new enumeration would not be two-way
passing 93 to `from-nat` produces:
93
which, when passed through `in' and `out', produces:
0
which, when passed to `to-nat' produces 0,
but it should have been 93
in: (->i
((in
(e es c)
(cond
((null? es) (-> (enum-contract e) c))
(else
(dynamic->*
#:mandatory-domain-contracts
(map enum-contract ...)
#:range-contracts
(list c)))))
(out
(e es c)
(cond
((null? es) (-> c (enum-contract e)))
(else
(dynamic->*
#:mandatory-domain-contracts
(list c)
#:range-contracts
(map enum-contract ...)))))
(e enum?)
#:contract
(c contract?))
#:rest
(es (listof enum?))
#:pre/desc
(in out e es)
(appears-to-be-a-bijection?
in
out
(cons e es))
(result enum?))
contract from:
<pkgs>/data-enumerate-lib/data/enumerate.rkt
blaming: top-level
(assuming the contract is correct)
at: <pkgs>/data-enumerate-lib/data/enumerate.rkt:45:3
> (map/e (λ (x) (floor (/ x 100))) (λ (x) (* x 100)) natural/e #:contract natural?) map/e: contract violation;
new enumeration would not be two-way
passing 937 to `from-nat` produces:
937
which, when passed through `in' and `out', produces:
900
which, when passed to `to-nat' produces 900,
but it should have been 937
in: (->i
((in
(e es c)
(cond
((null? es) (-> (enum-contract e) c))
(else
(dynamic->*
#:mandatory-domain-contracts
(map enum-contract ...)
#:range-contracts
(list c)))))
(out
(e es c)
(cond
((null? es) (-> c (enum-contract e)))
(else
(dynamic->*
#:mandatory-domain-contracts
(list c)
#:range-contracts
(map enum-contract ...)))))
(e enum?)
#:contract
(c contract?))
#:rest
(es (listof enum?))
#:pre/desc
(in out e es)
(appears-to-be-a-bijection?
in
out
(cons e es))
(result enum?))
contract from:
<pkgs>/data-enumerate-lib/data/enumerate.rkt
blaming: top-level
(assuming the contract is correct)
at: <pkgs>/data-enumerate-lib/data/enumerate.rkt:45:3
Sometimes, there is no easy way to make two functions that form a bijection. In │ │ │ that case you can use pam/e and supply only one function │ │ │ to make a one way enumeration. For example, │ │ │ we can make an enumeration of picts of binary trees like this:
(define pict-bt/e (pam/e (λ (bt) (binary-tidier (let loop ([bt bt]) (cond [(list? bt) (apply tree-layout (map loop bt))] [else #f])))) bt/e #:contract pict?))
> (from-nat pict-bt/e 10)
> (from-nat pict-bt/e 11)
> (from-nat pict-bt/e 12)
Putting all these pieces together, here is a definition of │ │ │ an enumeration of closed expressions of the untyped │ │ │ lambda calculus.
(define/contract (lc-var/e bvs memo) (-> (set/c symbol?) (hash/c (set/c symbol?) enum?) enum?) ; memoization is a significant performance improvement (hash-ref! memo bvs (delay/e (or/e ; the variables currently in scope (apply fin/e (set->list bvs)) ; the λ case; first we build a dependent ; pair of a bound variable and a body expression ; and then use map/e to build the usual syntax (map/e (λ (pr) `(λ (,(car pr)) ,(cdr pr))) (λ (λ-exp) (cons (caadr λ-exp) (caddr λ-exp))) (cons/de [hd symbol/e] [tl (hd) (lc-var/e (set-add bvs hd) memo)]) #:contract (list/c 'λ (list/c symbol?) lc-exp?)) ; application expressions (list/e (lc-var/e bvs memo) (lc-var/e bvs memo)))))) (define (lc-exp? x) (match x [(? symbol?) #t] [`(λ (,x) ,e) (and (symbol? x) (lc-exp? e))] [`(,a ,b) (and (lc-exp? a) (lc-exp? b))])) (define lc/e (lc-var/e (set) (make-hash)))
> (from-nat lc/e 0) '(λ (a) a)
> (from-nat lc/e 1) '((λ (a) a) (λ (a) a))
> (from-nat lc/e 2) '(λ (a) (λ (a) a))
> (to-nat lc/e '(λ (f) ((λ (x) (f (x x))) (λ (x) (f (x x)))))) 120491078480010
(require data/enumerate) | package: data-enumerate-lib |
The data/enumerate library contains the core │ │ │ subset of the enumeration library; its exports are described │ │ │ @@ -212,15 +212,15 @@ │ │ │ finite and infinite enumerations, regardless of the count │ │ │ of the enumeration. For finite enumerations, it picks │ │ │ an index uniformly at random using random-natural │ │ │ and for infinite enumerations it picks a natural number │ │ │ n │ │ │ from the geometric distribution and uses that as an │ │ │ exponent, picking uniformly at random in the interval │ │ │ - between (expt 2 n) and (expt 2 (+ n 1)).
> (random-index natural/e) 1555364196496514356733535419058301946543636307974812981365
> (random-index (below/e 5000000000)) 2921396022
This section describes enumerations of some common Racket │ │ │ + between (expt 2 n) and (expt 2 (+ n 1)).
> (random-index natural/e) 50161898263700830440701841791
> (random-index (below/e 5000000000)) 4544382021
This section describes enumerations of some common Racket │ │ │ datatypes.
value
> (enum->list char/e 5) '(#\a #\b #\c #\d #\e)
> (to-nat char/e #\λ) 955
value
> (enum->list string/e 5) '("a" "b" "c" "d" "e")
> (to-nat string/e "racket") 34015667898221561123161278314514
value
> (enum->list bool/e) '(#t #f)
value
> (enum->list symbol/e 5) '(a b c d e)
> (to-nat symbol/e 'racket/base) 14463363701250876059548377015002918685315716675027977448257554
value
> (enum->list integer/e 10) '(0 1 -1 2 -2 3 -3 4 -4 5)
value
> (enum->list flonum/e 10) '(+inf.0 -inf.0 +nan.0 0.0 5e-324 -5e-324 1e-323 -1e-323 1.5e-323 -1.5e-323)
> (to-nat flonum/e 1.0) 9214364837600034818
> (to-nat flonum/e -1.0) 9214364837600034819
> (enum->list exact-rational/e 13) '(0 1/2 -1/2 1/3 -1/3 1 -1 2/3 -2/3 1/4 -1/4 1/2 -1/2)
> (enum->list two-way-real/e 5) '(0 +inf.0 1 -inf.0 -1)
value
> (enum->list real/e 10) '(+inf.0 0 -inf.0 1/2 +nan.0 -1/2 0.0 1/3 5e-324 -1/3)