From: Chris Hanson Date: Wed, 23 Mar 2016 01:11:53 +0000 (-0700) Subject: Add delete! operation to metadata abstractions. X-Git-Tag: mit-scheme-pucked-9.2.12~261^2~70 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=d51addc4878029126ed6fd3c0a79eb2a4f1b5627;p=mit-scheme.git Add delete! operation to metadata abstractions. --- diff --git a/src/runtime/global.scm b/src/runtime/global.scm index 0627959ef..7d84dc016 100644 --- a/src/runtime/global.scm +++ b/src/runtime/global.scm @@ -507,6 +507,13 @@ USA. (set! alist (cons (cons key metadata) alist)) unspecific)))) + (define (delete! key) + (set! alist + (remove! (lambda (p) + (eqv? (car p) key)) + alist)) + unspecific) + (define (get-alist) alist) @@ -520,6 +527,7 @@ USA. ((has?) has?) ((get) get) ((put!) put!) + ((delete!) delete!) ((get-alist) get-alist) ((put-alist!) put-alist!) (else (error "Unknown operator:" operator)))))) @@ -536,6 +544,9 @@ USA. (define (put! key metadata) (hash-table-set! table key metadata)) + (define (delete! key) + (hash-table-delete! table key)) + (define (get-alist) (hash-table->alist table)) @@ -549,6 +560,7 @@ USA. ((has?) has?) ((get) get) ((put!) put!) + ((delete!) delete!) ((get-alist) get-alist) ((put-alist!) put-alist!) (else (error "Unknown operator:" operator))))))