From ca9150b8e02a849245bdaa8d9ff2f689f9afec2e Mon Sep 17 00:00:00 2001 From: Max Penet Date: Tue, 27 Oct 2015 22:54:57 +0100 Subject: [PATCH 1/3] add vary-meta --- pixie/stdlib.pxi | 6 ++++++ tests/pixie/tests/test-stdlib.pxi | 3 +++ 2 files changed, 9 insertions(+) diff --git a/pixie/stdlib.pxi b/pixie/stdlib.pxi index 7d16a0c6..a9759630 100644 --- a/pixie/stdlib.pxi +++ b/pixie/stdlib.pxi @@ -2717,3 +2717,9 @@ Calling this function on something that is not ISeqable returns a seq with that (if (satisfies? IComparable x) (-compare x y) (throw [::ComparisonError (str x " does not satisfy IComparable")]))) + +(defn vary-meta + [x f & args] + "Returns x with meta data updated with the application of f and args to it. +ex: (vary-meta x assoc :foo 42)" + (with-meta x (apply f (meta x) args))) diff --git a/tests/pixie/tests/test-stdlib.pxi b/tests/pixie/tests/test-stdlib.pxi index 8334d9e0..167177e1 100644 --- a/tests/pixie/tests/test-stdlib.pxi +++ b/tests/pixie/tests/test-stdlib.pxi @@ -691,3 +691,6 @@ (t/assert= m (map-entry :a 1)) (t/assert= m [:a 1]) (t/assert= m '(:a 1)))) + +(t/deftest vary-meta + (t/assert= 42 (-> {} (vary-meta assoc :foo 42) meta :foo))) From 854d838c6b51e4a5ad994ddc871872810a65739e Mon Sep 17 00:00:00 2001 From: Max Penet Date: Wed, 28 Oct 2015 09:14:15 +0100 Subject: [PATCH 2/3] improve metadata --- pixie/stdlib.pxi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pixie/stdlib.pxi b/pixie/stdlib.pxi index a9759630..614befd6 100644 --- a/pixie/stdlib.pxi +++ b/pixie/stdlib.pxi @@ -2719,7 +2719,9 @@ Calling this function on something that is not ISeqable returns a seq with that (throw [::ComparisonError (str x " does not satisfy IComparable")]))) (defn vary-meta - [x f & args] - "Returns x with meta data updated with the application of f and args to it. + {:doc "Returns x with meta data updated with the application of f and args to it. ex: (vary-meta x assoc :foo 42)" + :signatures [[x f & args]] + :added "0.1"} + [x f & args] (with-meta x (apply f (meta x) args))) From 499430529b04f6375d9406dfa3be630cee459eec Mon Sep 17 00:00:00 2001 From: Max Penet Date: Wed, 28 Oct 2015 10:12:34 +0100 Subject: [PATCH 3/3] deftest compile down to a function with the same name, so it clashes with the stdlib var --- tests/pixie/tests/test-stdlib.pxi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pixie/tests/test-stdlib.pxi b/tests/pixie/tests/test-stdlib.pxi index 167177e1..217784d1 100644 --- a/tests/pixie/tests/test-stdlib.pxi +++ b/tests/pixie/tests/test-stdlib.pxi @@ -692,5 +692,5 @@ (t/assert= m [:a 1]) (t/assert= m '(:a 1)))) -(t/deftest vary-meta +(t/deftest test-vary-meta (t/assert= 42 (-> {} (vary-meta assoc :foo 42) meta :foo)))