From c0bd4e8dbc7cce39edbfa0c8e40bf30934dae0db Mon Sep 17 00:00:00 2001 From: Ryan Culpepper Date: Tue, 12 Apr 2011 09:30:03 -0600 Subject: [PATCH] removed unused code from unstable/hash --- collects/tests/unstable/hash.rkt | 24 ---------- collects/unstable/hash.rkt | 21 --------- collects/unstable/scribblings/hash.scrbl | 60 ------------------------ 3 files changed, 105 deletions(-) diff --git a/collects/tests/unstable/hash.rkt b/collects/tests/unstable/hash.rkt index 507399d67b..95f2458b69 100644 --- a/collects/tests/unstable/hash.rkt +++ b/collects/tests/unstable/hash.rkt @@ -4,29 +4,6 @@ (run-tests (test-suite "hash.ss" - (test-suite "hash-ref/check" - (test-ok (check-equal? (hash-ref/check #hash([1 . one] [2 . two]) 1) - 'one)) - (test-bad (hash-ref/check #hash([1 . one] [2 . two]) 3))) - (test-suite "hash-ref/identity" - (test-ok (check-equal? (hash-ref/identity #hash([1 . one] [2 . two]) 1) - 'one)) - (test-ok (check-equal? (hash-ref/identity #hash([1 . one] [2 . two]) 3) - 3))) - (test-suite "hash-ref/default" - (test-ok (check-equal? (hash-ref/default #hash([1 . one] [2 . two]) 1 '?) - 'one)) - (test-ok (check-equal? (hash-ref/default #hash([1 . one] [2 . two]) 3 '?) - '?))) - (test-suite "hash-ref/failure" - (test-ok (define x 7) - (define (f) (set! x (+ x 1)) x) - (check-equal? (hash-ref/failure #hash([1 . one] [2 . two]) 1 f) - 'one) - (check-equal? x 7) - (check-equal? (hash-ref/failure #hash([1 . one] [2 . two]) 3 f) - 8) - (check-equal? x 8))) (test-suite "hash-union" (test-ok (hash-union #hash([1 . one] [2 . two]) #hash([3 . three] [4 . four])) @@ -38,4 +15,3 @@ (check-equal? (hash-copy #hash([1 . one] [2 . two] [3 . three] [4 . four])) h))))) - diff --git a/collects/unstable/hash.rkt b/collects/unstable/hash.rkt index 4365ed43cd..a4bfab8469 100644 --- a/collects/unstable/hash.rkt +++ b/collects/unstable/hash.rkt @@ -1,20 +1,6 @@ #lang racket/base (require racket/contract) -;; Eli: See comments for `dict-ref/check' and relatives. - -(define (hash-ref/check table key) - (hash-ref table key)) - -(define (hash-ref/identity table key) - (hash-ref table key (lambda () key))) - -(define (hash-ref/default table key default) - (hash-ref table key (lambda () default))) - -(define (hash-ref/failure table key failure) - (hash-ref table key (lambda () (failure)))) - ;; Eli: See comment for `dict-union' and `dict-union!' -- these two do ;; make sense, but if they're in, then generalizing them to dictionaries ;; seems to make little sense. If they are useful, I'd much rather see @@ -51,13 +37,6 @@ v)))) (provide/contract - [hash-ref/identity (-> hash? any/c any/c)] - [hash-ref/default (-> hash? any/c any/c any/c)] - [hash-ref/failure (-> hash? any/c (-> any/c) any/c)] - [hash-ref/check - (->i ([table hash?] [key any/c]) () - #:pre (table key) (hash-has-key? table key) - [res any/c])] [hash-union (->* [(and/c hash? immutable?)] [#:combine (-> any/c any/c any/c) diff --git a/collects/unstable/scribblings/hash.scrbl b/collects/unstable/scribblings/hash.scrbl index 921fd0ee91..db8b749d19 100644 --- a/collects/unstable/scribblings/hash.scrbl +++ b/collects/unstable/scribblings/hash.scrbl @@ -9,66 +9,6 @@ This module provides tools for manipulating hash tables. -@section{Hash Table Lookup} - -@defproc[(hash-ref/check [h hash?] [k (lambda (k) (hash-has-key? h k))]) - any/c]{ - -Looks up key @scheme[k] in hash table @scheme[h]. Raises a contract error if -@scheme[h] has no entry for @scheme[k]. Equivalent to @scheme[(hash-ref h k)], -except for the specific exception value raised. - -@defexamples[ -#:eval (eval/require 'unstable/hash) -(hash-ref/check (make-immutable-hash '([1 . one] [2 . two] [3 . three])) 2) -] - -} - -@defproc[(hash-ref/identity [h hash?] [k any/c]) any/c]{ - -Looks up key @scheme[k] in hash table @scheme[h]. Returns @scheme[k] if -@scheme[h] has no entry for @scheme[k]. Equivalent to -@scheme[(hash-ref h k (lambda () k))]. - -@defexamples[ -#:eval (eval/require 'unstable/hash) -(hash-ref/identity (make-immutable-hash '([1 . one] [2 . two] [3 . three])) 2) -(hash-ref/identity (make-immutable-hash '([1 . one] [2 . two] [3 . three])) 4) -] - -} - -@defproc[(hash-ref/default [h hash?] [k any/c] [v any/c]) any/c]{ - -Looks up key @scheme[k] in hash table @scheme[h]. Returns @scheme[v] if -@scheme[h] has no entry for @scheme[k]. Equivalent to -@scheme[(hash-ref h k (lambda () v))]. - -@defexamples[ -#:eval (eval/require 'unstable/hash) -(hash-ref/default (make-immutable-hash '([1 . one] [2 . two] [3 . three])) 2 'other) -(hash-ref/default (make-immutable-hash '([1 . one] [2 . two] [3 . three])) 4 'other) -] - -} - -@defproc[(hash-ref/failure [h hash?] [k any/c] [f (-> any/c)]) any/c]{ - -Looks up key @scheme[k] in hash table @scheme[h]. Returns the result of -applying @scheme[f] (in tail position) if @scheme[h] has no entry for -@scheme[k]. Equivalent to @scheme[(hash-ref h k f)]. - -@defexamples[ -#:eval (eval/require 'unstable/hash) -(hash-ref/failure (make-immutable-hash '([1 . one] [2 . two] [3 . three])) 2 gensym) -(hash-ref/failure (make-immutable-hash '([1 . one] [2 . two] [3 . three])) 4 gensym) -] - -} - -@section{Hash Table Combinations} - @defproc[(hash-union [h0 (and/c hash? hash-can-functional-set?)] [h hash?] ... [#:combine combine