JanetDocsSourcePlaygroundI'm feeling luckyCommunityGitHub sign in

comp

core-api


    function
    boot.janet on line 776, column 1

    (comp & functions)

    Takes multiple functions and returns a function that is the 
    composition of those functions.


2 examplesSign in to add an example
Loading...
# Note that the earlier sort func is executed later

(update @{:data @[:cherry :orange]} :data (comp sort |(array/push $ :apple)))
# => @{:data @[:apple :cherry :orange]}
veqqqPlayground
(defn square [x] (* x x))
(defn square-then-dec [x] ((comp dec square) x))
(defn dec-then-square [x] ((comp square dec) x))
(square-then-dec 3)  # => 8
(dec-then-square 3)  # => 4
cellularmitosisPlayground