clojure when-let alternative for an empty array? -
I am generating json literally because I can do it in closure. My problem is that some branches of JSS Only if present given parameters are given Here is a sample of such condition
(Name name [uuid & [generated-UUI]] {: message {: id ( Gener-uuid): Details {: name name}}: Metadata {: batch (merge {: id uuid} (when generated-UUD (batches (Map # (Aram-Map: ID%) generated-UUD)] {: GenerateAts batches})))}}})
Unfortunately, when / Part is quite ugly. This can be done only when used as the following, but it does not work because my map returns [] to a zero.
(defn message-for [name uuid & [generated-wou]] {: message {: id (gener-uuid): description {: name name}: metadata {: batch (merge) {: Id uuid} (When-Two [batches (map # (array-map: id%) generated)] {: generates bat batches}}}}})
if Any way I can create any idea - empty list / array / seak is wrong. Can I clean my code a little bit?
No-empty
returns the argument if it is not empty.
- To maintain the archive type
-
expressivenes
(When-Two [batches (Not empty (map ...) ... ...
In your case though I like it:
< Pre> ...: metadata {: batch (cond-> gt: {id: uuid} (seq generated-uuids) (assoc: generated clap (map ...)) ... ... ...
Note that the above Listed three benefits,
Comments
Post a Comment