From 618304f5ebe041ef8d98cf24c0b03e7a8a2e07d7 Mon Sep 17 00:00:00 2001 From: Felisp Date: Mon, 8 Jan 2024 03:23:03 +0100 Subject: [PATCH] Add [fmap] for mapping over map --- src/rss_thread_watch/utils.clj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/rss_thread_watch/utils.clj b/src/rss_thread_watch/utils.clj index 0de1280..0781220 100644 --- a/src/rss_thread_watch/utils.clj +++ b/src/rss_thread_watch/utils.clj @@ -68,3 +68,11 @@ (map? default-val)) ; If only one is, we don't care cus then it's just assigment {k (map-apply-defaults conf-val default-val)} {k (nil?-else conf-val default-val)}))))) + +(defn fmap [f m] + "Applies function [f] to every key and value in map [m] + Function signature should be (f [key value])." + (into + (empty m) + (for [[key val] m] + [key (f key val)])))