diff options
| author | Asko Nomm <asko@Askos-MBP.lan> | 2025-12-07 01:18:18 +0200 |
|---|---|---|
| committer | Asko Nomm <asko@Askos-MBP.lan> | 2025-12-07 01:18:18 +0200 |
| commit | 4a242170a0dbc3df30ba56608a581ab1a9fcf61c (patch) | |
| tree | 6b3a5b79f64ecee3fea4e86a3c8e5a09de14c320 /src | |
| parent | 6619a8da60712c36338cc7e0f1cf8a5b8d9dbed7 (diff) | |
Simplify conditional
Diffstat (limited to 'src')
| -rw-r--r-- | src/dompa/nodes.cljc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/dompa/nodes.cljc b/src/dompa/nodes.cljc index 3e5c72f..d2f8e4b 100644 --- a/src/dompa/nodes.cljc +++ b/src/dompa/nodes.cljc @@ -132,18 +132,26 @@ attrs? (assoc :node/attrs attrs) (seq children) (assoc :node/children (flatten children)))))) +(defn- list-of-one? + [coll] + (and (sequential? coll) + (= (count coll) 1))) + +(defn- list-of-many? + [coll] + (and (sequential? coll) + (> (count coll) 1))) + (defn- nodes-from-opt [opt] (cond (map? opt) opt - (and (sequential? opt) - (> (count opt) 1)) + (list-of-many? opt) {:node/name :<> :node/children opt} - (and (sequential? opt) - (= (count opt) 1)) + (list-of-one? opt) (first opt) :else |
