Clojure-maps-selectkeys
提供:Dev Guides
Clojure-マップの選択キー
キーがキーにあるマップ内のエントリのみを含むマップを返します。
構文
構文は次のとおりです。
(select-keys hmap keys)
パラメータ-「hmap」はハッシュキーと値のマップです。 「キー」は、HashMapから選択する必要があるキーのリストです。
戻り値-キーの選択句に従ってマップからキーを返します。
例
以下は、Clojureの選択キーの例です。
(ns clojure.examples.example
(:gen-class))
(defn example []
(def demokeys (hash-map "z" 1 "b" 2 "a" 3))
(println (select-keys demokeys ["z" "a"])))
(example)
出力
上記のコードは次の出力を生成します。
{z 1, a 3}