From 5780e32e4d2db288a256942aa635c2f69e3f2adf Mon Sep 17 00:00:00 2001 From: smeghead Date: Sun, 25 Aug 2024 22:56:32 +0900 Subject: [PATCH] fix: use reduce instead of loop. --- src/statement.phel | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/statement.phel b/src/statement.phel index 1345e95..9dc99e7 100644 --- a/src/statement.phel +++ b/src/statement.phel @@ -4,13 +4,9 @@ (defn- map-key-to-keyowrd [row] (let [row (php-array-to-map row)] - (loop [ps (keys row) - acc {}] - (if (empty? ps) - acc - (recur - (rest ps) - (put acc (keyword (first ps)) (row (first ps)))))))) + (reduce (fn [acc key] + (put acc (keyword key) (row key))) + {} (keys row)))) (defn fetch "Fetches the next row from a result set" @@ -36,13 +32,9 @@ (fetchAll (php/:: \PDO FETCH_ASSOC))))) (defn- map-key-to-string [params] - (loop [ps (keys params) - acc {}] - (if (empty? ps) - (to-php-array acc) - (recur - (rest ps) - (put acc (format "%s" (first ps)) (params (first ps))))))) + (to-php-array (reduce (fn [acc key] + (put acc (format "%s" key) (params key))) + {} (keys params)))) (defn execute "Executes a prepared statement"