|
1266 | 1266 | (cond
|
1267 | 1267 | (uuid? x) true
|
1268 | 1268 | (string? x) (do (uuid/UUID x) true)
|
1269 |
| - (int? x) (do (apply-kw uuid/UUID {:int x}) true) |
1270 |
| - (byte-string? x) (do (apply-kw uuid/UUID {:bytes x}) true) |
| 1269 | + (int? x) (do (uuid/UUID ** :int x) true) |
| 1270 | + (byte-string? x) (do (uuid/UUID ** :bytes x) true) |
1271 | 1271 | (or (py-tuple? x)
|
1272 |
| - (vector? x)) (do (apply-kw uuid/UUID {:fields x}) true) |
| 1272 | + (vector? x)) (do (uuid/UUID ** :fields x) true) |
1273 | 1273 | :else false)
|
1274 | 1274 | (catch python/AttributeError _ false)
|
1275 | 1275 | (catch python/TypeError _ false)
|
|
2175 | 2175 |
|
2176 | 2176 | (defn partial
|
2177 | 2177 | "Return a function which is the partial application of f with args."
|
2178 |
| - [f & args] |
2179 |
| - (apply basilisp.lang.runtime/partial f args)) |
| 2178 | + ([f] f) |
| 2179 | + ([f & args] |
| 2180 | + (apply basilisp.lang.runtime/partial f args))) |
| 2181 | + |
| 2182 | +(defn partial-kw |
| 2183 | + "Return a function which is the partial application of f with keyword arguments. |
| 2184 | + |
| 2185 | + If a single argument is provided, it will be interpreted as a map of keyword arguments. |
| 2186 | + |
| 2187 | + If multiple arguments are given, they are interpreted as key/value pairs and will |
| 2188 | + be converted into a hash-map before being partially applied to the function. |
| 2189 | + |
| 2190 | + This function applies keyword arguments via `apply-kw`. As a consequence, Lisp keywords |
| 2191 | + will be converted to munged Python strings (via `name`), meaning namespaces will be lost |
| 2192 | + and identifiers which are not valid Python syntax will be converted to safe Python |
| 2193 | + identifiers." |
| 2194 | + ([f] f) |
| 2195 | + ([f m] |
| 2196 | + (apply-kw basilisp.lang.runtime/partial f m)) |
| 2197 | + ([f arg & args] |
| 2198 | + (let [m (apply hash-map (cons arg args))] |
| 2199 | + (partial-kw f m)))) |
2180 | 2200 |
|
2181 | 2201 | (defn every?
|
2182 | 2202 | "Return true if every element in coll satisfies pred."
|
|
0 commit comments