Skip to content

Commit f653781

Browse files
committed
Merge pull request #409 from mpenet/feature/meta
Add vary-meta
2 parents 7dd29ae + 4994305 commit f653781

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

pixie/stdlib.pxi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2717,3 +2717,11 @@ Calling this function on something that is not ISeqable returns a seq with that
27172717
(if (satisfies? IComparable x)
27182718
(-compare x y)
27192719
(throw [::ComparisonError (str x " does not satisfy IComparable")])))
2720+
2721+
(defn vary-meta
2722+
{:doc "Returns x with meta data updated with the application of f and args to it.
2723+
ex: (vary-meta x assoc :foo 42)"
2724+
:signatures [[x f & args]]
2725+
:added "0.1"}
2726+
[x f & args]
2727+
(with-meta x (apply f (meta x) args)))

tests/pixie/tests/test-stdlib.pxi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,3 +691,6 @@
691691
(t/assert= m (map-entry :a 1))
692692
(t/assert= m [:a 1])
693693
(t/assert= m '(:a 1))))
694+
695+
(t/deftest test-vary-meta
696+
(t/assert= 42 (-> {} (vary-meta assoc :foo 42) meta :foo)))

0 commit comments

Comments
 (0)