Skip to content

Commit 5780e32

Browse files
committed
fix: use reduce instead of loop.
1 parent 7349799 commit 5780e32

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/statement.phel

+6-14
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@
44

55
(defn- map-key-to-keyowrd [row]
66
(let [row (php-array-to-map row)]
7-
(loop [ps (keys row)
8-
acc {}]
9-
(if (empty? ps)
10-
acc
11-
(recur
12-
(rest ps)
13-
(put acc (keyword (first ps)) (row (first ps))))))))
7+
(reduce (fn [acc key]
8+
(put acc (keyword key) (row key)))
9+
{} (keys row))))
1410

1511
(defn fetch
1612
"Fetches the next row from a result set"
@@ -36,13 +32,9 @@
3632
(fetchAll (php/:: \PDO FETCH_ASSOC)))))
3733

3834
(defn- map-key-to-string [params]
39-
(loop [ps (keys params)
40-
acc {}]
41-
(if (empty? ps)
42-
(to-php-array acc)
43-
(recur
44-
(rest ps)
45-
(put acc (format "%s" (first ps)) (params (first ps)))))))
35+
(to-php-array (reduce (fn [acc key]
36+
(put acc (format "%s" key) (params key)))
37+
{} (keys params))))
4638

4739
(defn execute
4840
"Executes a prepared statement"

0 commit comments

Comments
 (0)