From d51addc4878029126ed6fd3c0a79eb2a4f1b5627 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Tue, 22 Mar 2016 18:11:53 -0700 Subject: [PATCH] Add delete! operation to metadata abstractions. --- src/runtime/global.scm | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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)))))) -- 2.25.1