Skip to content

Commit ca9150b

Browse files
committed
add vary-meta
1 parent 7dd29ae commit ca9150b

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

pixie/stdlib.pxi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2717,3 +2717,9 @@ 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+
[x f & args]
2723+
"Returns x with meta data updated with the application of f and args to it.
2724+
ex: (vary-meta x assoc :foo 42)"
2725+
(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 vary-meta
696+
(t/assert= 42 (-> {} (vary-meta assoc :foo 42) meta :foo)))

0 commit comments

Comments
 (0)