From 7dfb9602f886dd3b81c913e3ccdb980b68257a94 Mon Sep 17 00:00:00 2001 From: Philip Xu Date: Sun, 25 Dec 2016 17:02:51 -0500 Subject: [PATCH] Add juxt documentation --- docs/language/core.rst | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/language/core.rst b/docs/language/core.rst index 6de4af2..3fc1c8e 100644 --- a/docs/language/core.rst +++ b/docs/language/core.rst @@ -505,6 +505,31 @@ themselves as an iterator when ``(iter x)`` is called. Contrast with => (iterator? (iter {:a 1 :b 2 :c 3})) True + +.. _juxt-fn: + +juxt +---- + +.. versionadded:: 0.12.0 + +Usage: ``(juxt f &rest fs)`` + +Return a function that apply a set of functions to same arguments +and collect the result into a list. + +.. code-block:: hy + + => ((juxt min max sum) (range 1 101)) + [1, 100, 5050] + + => (dict (map (juxt identity ord) "abcdef")) + {'f': 102, 'd': 100, 'b': 98, 'e': 101, 'c': 99, 'a': 97} + + => (setv [total difference product quotient] ((juxt + - * /) 24 3)) + [27, 21, 72, 8.0] + + .. _keyword-fn: keyword