Implement CaseSensitiveQuery #39
1 changed files with 18 additions and 1 deletions
|
@ -47,6 +47,11 @@
|
||||||
~x
|
~x
|
||||||
result#)))
|
result#)))
|
||||||
|
|
||||||
|
(defmacro vectorize
|
||||||
|
"If arg is not a vector, put into vector, otherwise return it"
|
||||||
|
[v]
|
||||||
|
(if (vector? v) v [v]))
|
||||||
|
|
||||||
;; ===== Generic functions ====
|
;; ===== Generic functions ====
|
||||||
|
|
||||||
(defn indices
|
(defn indices
|
||||||
|
@ -71,13 +76,25 @@
|
||||||
|
|
||||||
(defn fmap
|
(defn fmap
|
||||||
"Applies function [f] to every key and value in map [m]
|
"Applies function [f] to every key and value in map [m]
|
||||||
Function signature should be (f [key value])."
|
Function signature should be (f [key value]).
|
||||||
|
Key stays unchanged"
|
||||||
[f m]
|
[f m]
|
||||||
(into
|
(into
|
||||||
(empty m)
|
(empty m)
|
||||||
(for [[key val] m]
|
(for [[key val] m]
|
||||||
[key (f key val)])))
|
[key (f key val)])))
|
||||||
|
|
||||||
|
(defn fkmap
|
||||||
|
;; I am horrible with docstrings, I don't deny that
|
||||||
|
"Applies function [f] to every key and value in map [m]
|
||||||
|
Function signature should be (f [key value]).
|
||||||
|
Unlike fmap, you can change key too, so return both {key value} in map"
|
||||||
|
[f m]
|
||||||
|
(into
|
||||||
|
(empty m)
|
||||||
|
(for [[key val] m]
|
||||||
|
(f key val))))
|
||||||
|
|
||||||
(defn expand-home
|
(defn expand-home
|
||||||
"Expands ~ to home directory"
|
"Expands ~ to home directory"
|
||||||
;;modified from sauce: https://stackoverflow.com/questions/29585928/how-to-substitute-path-to-home-for
|
;;modified from sauce: https://stackoverflow.com/questions/29585928/how-to-substitute-path-to-home-for
|
||||||
|
|
Loading…
Reference in a new issue