Add a function to invert the table in a decoded json.

This commit is contained in:
2023-10-23 15:50:05 +03:00
parent 5a4b88bd08
commit 553f4788e4
2 changed files with 18 additions and 0 deletions
@@ -2,6 +2,7 @@
(:require
[cipher-analytical-machine.ciphers.simple-substitution :as ss]
[cipher-analytical-machine.parsers.parsers :as ps]
[clojure.set :as set]
[cheshire.core :as cc])
(:gen-class))
@@ -42,3 +43,12 @@
(assoc "table" (ss/generate-substitution-table symbols)))
(decode-key-and-substitution-table-from-json key-or-json)))
(defn invert-table-in-map
"Invert the table in a decoded json (key, table)"
[decoded-json]
(->>
(-> decoded-json
(get "table")
(set/map-invert))
(assoc decoded-json "table")))