From 5533a3256e77ed83befa898fc186bb21bc22be1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Sun, 9 Apr 2023 19:47:17 +0200 Subject: [PATCH] Update ldict-keys. --- doc/utils.md | 6 ++++++ src/util-dict.scm | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/utils.md b/doc/utils.md index 5ca0c95..de36bc6 100644 --- a/doc/utils.md +++ b/doc/utils.md @@ -90,6 +90,12 @@ the dictionary does not contain the key ```k```, an error is raised. Sets existing key ```k``` to the new value ```v``` or inserts it if it is not already present in the dictionary ```ld```. + (ldict-keys ld) + +* ```ld``` - a ldict instance + +Returns the list of keys stored in given dictionary. + ### IO (import util-io) diff --git a/src/util-dict.scm b/src/util-dict.scm index aa59e2e..e1e58eb 100644 --- a/src/util-dict.scm +++ b/src/util-dict.scm @@ -39,6 +39,7 @@ ldict-remove ldict-set + ldict-keys ldict-map ldict-filter @@ -144,8 +145,8 @@ (cons (car pairs) res))))))) ;; Returns the list of keys stored in given dictionary. - (define (dict-keys d) - (map car d)) + (define (ldict-keys ld) + (map car (ldict-pairs ld))) ;; Maps dictionary values, the procedure gets key-value pairs if it ;; accepts more than one argument. If it accepts a third argument,