From 53fc18008c9c07c95f602b9a814776f6b4698aaa Mon Sep 17 00:00:00 2001 From: Ryan Culpepper Date: Sat, 17 Dec 2011 21:32:00 -0700 Subject: [PATCH] removed unstable/dict (no uses) --- collects/tests/unstable/dict.rkt | 32 ------- collects/unstable/dict.rkt | 64 -------------- collects/unstable/scribblings/dict.scrbl | 83 ------------------- collects/unstable/scribblings/unstable.scrbl | 1 - .../unstable/tests/test-docs-complete.rkt | 1 - 5 files changed, 181 deletions(-) delete mode 100644 collects/tests/unstable/dict.rkt delete mode 100644 collects/unstable/dict.rkt delete mode 100644 collects/unstable/scribblings/dict.scrbl diff --git a/collects/tests/unstable/dict.rkt b/collects/tests/unstable/dict.rkt deleted file mode 100644 index 8211d0291e..0000000000 --- a/collects/tests/unstable/dict.rkt +++ /dev/null @@ -1,32 +0,0 @@ -#lang racket - -(require rackunit rackunit/text-ui unstable/dict "helpers.rkt") - -(define (dict=? a b) - (and (subdict? a b) - (subdict? b a))) - -(define (subdict? a b) - (for/and ([(k v) (in-dict a)]) - (and (dict-has-key? b k) - (equal? (dict-ref b k) v)))) - -(define (check/dict a b) (check dict=? a b)) - -(run-tests - (test-suite "dict.rkt" - (test-suite "Accessors" - (test-suite "dict-empty?" - (test (check-true (dict-empty? '()))) - (test (check-false (dict-empty? '([1 . a] [2 . b])))))) - (test-suite "Combination" - (test-suite "dict-union" - (test-ok (dict-union '([1 . one] [2 . two]) '([3 . three] [4 . four])) - '([4 . four] [3 . three] [1 . one] [2 . two]))) - (test-suite "dict-union!" - (test-ok (define d (make-hash)) - (dict-union! d '([1 . one] [2 . two])) - (dict-union! d '([3 . three] [4 . four])) - (check-equal? - (hash-copy #hash([1 . one] [2 . two] [3 . three] [4 . four])) - d)))))) diff --git a/collects/unstable/dict.rkt b/collects/unstable/dict.rkt deleted file mode 100644 index 82502d2c4c..0000000000 --- a/collects/unstable/dict.rkt +++ /dev/null @@ -1,64 +0,0 @@ -#lang racket/base -(require racket/dict - racket/contract/base) - -(define (dict-empty? dict) - (not (dict-iterate-first dict))) -;; Eli: This encourages ignoring the actual representation, and the fact -;; that `dict-count' can in some cases be an O(N) operation. (And to -;; make things worse, it's not even mentioned in the docs.) -;; Ryan: Fixed complexity. - -(define ((dict-duplicate-error name) key value1 value2) - (error name "duplicate values for key ~e: ~e and ~e" key value1 value2)) - -;; Eli: If this is useful, then at least make it worth using instead of -;; writing your own code. For example, inspect the arguments and choose -;; an efficient order for the loops, or use a temporary hash table for a -;; union of two alists, etc. Alternatively, just write a function for -;; merging two hash tables (and call it `hash-union', of course). - -;; Ryan: I prefer the names dict-add-all and dict-add-all!---no connotations -;; of symmetry, and it makes it clear that the first argument determines the -;; representation (and key constraints, etc). - -(define (dict-union - #:combine [combine #f] - #:combine/key [combine/key - (if combine - (lambda (k x y) (combine x y)) - (dict-duplicate-error 'dict-union))] - one . rest) - (for*/fold ([one one]) ([two (in-list rest)] [(k v) (in-dict two)]) - (dict-set one k (if (dict-has-key? one k) - (combine/key k (dict-ref one k) v) - v)))) - -(define (dict-union! - #:combine [combine #f] - #:combine/key [combine/key - (if combine - (lambda (k x y) (combine x y)) - (dict-duplicate-error 'dict-union))] - one . rest) - (for* ([two (in-list rest)] [(k v) (in-dict two)]) - (dict-set! one k (if (dict-has-key? one k) - (combine/key k (dict-ref one k) v) - v)))) - -(provide/contract - [dict-empty? (-> dict? boolean?)] - [dict-union (->* [(and/c dict? dict-can-functional-set?)] - [#:combine - (-> any/c any/c any/c) - #:combine/key - (-> any/c any/c any/c any/c)] - #:rest (listof dict?) - (and/c dict? dict-can-functional-set?))] - [dict-union! (->* [(and/c dict? dict-mutable?)] - [#:combine - (-> any/c any/c any/c) - #:combine/key - (-> any/c any/c any/c any/c)] - #:rest (listof dict?) - void?)]) diff --git a/collects/unstable/scribblings/dict.scrbl b/collects/unstable/scribblings/dict.scrbl deleted file mode 100644 index e188372f1d..0000000000 --- a/collects/unstable/scribblings/dict.scrbl +++ /dev/null @@ -1,83 +0,0 @@ -#lang scribble/manual -@(require scribble/eval "utils.rkt" (for-label racket unstable/dict)) - -@(define the-eval (make-base-eval)) -@(the-eval '(require racket/dict unstable/dict)) - -@title{Dictionaries} - -@defmodule[unstable/dict] - -@unstable[@author+email["Carl Eastlund" "cce@racket-lang.org"]] - -This module provides tools for manipulating dictionary values. - -@defproc[(dict-empty? [d dict?]) boolean?]{ - -Reports whether @racket[d] is empty (has no keys). - -@defexamples[ -#:eval the-eval -(dict-empty? '()) -(dict-empty? '([1 . one] [2 . two])) -] - -} - -@defproc[(dict-union [d0 (and/c dict? dict-can-functional-set?)] - [d dict?] ... - [#:combine combine - (-> any/c any/c any/c) - (lambda _ (error 'dict-union ...))] - [#:combine/key combine/key - (-> any/c any/c any/c any/c) - (lambda (k a b) (combine a b))]) - (and/c dict? dict-can-functional-set?)]{ - -Computes the union of @racket[d0] with each dictionary @racket[d] by functional -update, adding each element of each @racket[d] to @racket[d0] in turn. For each -key @racket[k] and value @racket[v], if a mapping from @racket[k] to some value -@racket[v0] already exists, it is replaced with a mapping from @racket[k] to -@racket[(combine/key k v0 v)]. - -@defexamples[ -#:eval the-eval -(dict-union '([1 . one]) '([2 . two]) '([3 . three])) -(dict-union '([1 . (one uno)] [2 . (two dos)]) - '([1 . (ein une)] [2 . (zwei deux)]) - #:combine/key (lambda (k v1 v2) (append v1 v2))) -] - -} - -@defproc[(dict-union! [d0 (and/c dict? dict-mutable?)] - [d dict?] ... - [#:combine combine - (-> any/c any/c any/c) - (lambda _ (error 'dict-union! ...))] - [#:combine/key combine/key - (-> any/c any/c any/c any/c) - (lambda (k a b) (combine a b))]) - void?]{ - -Computes the union of @racket[d0] with each dictionary @racket[d] by mutable -update, adding each element of each @racket[d] to @racket[d0] in turn. For each -key @racket[k] and value @racket[v], if a mapping from @racket[k] to some value -@racket[v0] already exists, it is replaced with a mapping from @racket[k] to -@racket[(combine/key k v0 v)]. - -@defexamples[ -#:eval the-eval -(define d (make-hash)) -d -(dict-union! d '([1 . (one uno)] [2 . (two dos)])) -d -(dict-union! d - '([1 . (ein une)] [2 . (zwei deux)]) - #:combine/key (lambda (k v1 v2) (append v1 v2))) -d -] - -} - -@(close-eval the-eval) diff --git a/collects/unstable/scribblings/unstable.scrbl b/collects/unstable/scribblings/unstable.scrbl index 5050319901..752c3df03f 100644 --- a/collects/unstable/scribblings/unstable.scrbl +++ b/collects/unstable/scribblings/unstable.scrbl @@ -78,7 +78,6 @@ Keep documentation and tests up to date. @include-section["prop-contract.scrbl"] @include-section["debug.scrbl"] @include-section["define.scrbl"] -@include-section["dict.scrbl"] @include-section["exn.scrbl"] @include-section["file.scrbl"] @include-section["find.scrbl"] diff --git a/collects/unstable/tests/test-docs-complete.rkt b/collects/unstable/tests/test-docs-complete.rkt index ef48f4e731..b463336c41 100644 --- a/collects/unstable/tests/test-docs-complete.rkt +++ b/collects/unstable/tests/test-docs-complete.rkt @@ -20,7 +20,6 @@ (check-docs (quote unstable/find)) (check-docs (quote unstable/file)) (check-docs (quote unstable/exn)) -(check-docs (quote unstable/dict)) (check-docs (quote unstable/debug)) (check-docs (quote unstable/contract)) (check-docs (quote unstable/class-iop))