Internal utility functions used by other namespaces.

(ns clj-pgp.util)

Returns a collection from the arguments provided. If args is a non-collection value, a single-element collection containing args is returned.

(defn arg-coll
  [args]
  (if (and args (not (coll? args)))
    (list args)
    (seq args)))

Takes a sequence of args and returns a seq. If only one argument is given and it is sequential, it is retured directly. Otherwise the seq of args is returned. Returns nil for empty args.

(defn arg-seq
  [args]
  (if (and (= 1 (count args))
           (sequential? (first args)))
    (seq (first args))
    (seq args)))

Takes a sequence of args and returns a map. If only one argument is given and it is a map, it is retured directly. Otherwise the seq of args is treated as keyword args and returned as a map.

(defn arg-map
  [args]
  (cond
    (nil? args) nil
    (map? args) args
    (= 1 (count args)) (recur (first args))
    :else (apply array-map args)))