JanetDocsPlaygroundI'm feeling luckyGitHub sign in

complement



    function
    boot.janet on line 713, column 1

    (complement f)

    Returns a function that is the complement to the argument.


1 exampleSign in to add an example
Loading...
(filter  even?                     [1 2 3 4 5])  # => @[2 4]
(filter  odd?                      [1 2 3 4 5])  # => @[1 3 5]
(filter  (fn [x] (not (even? x)))  [1 2 3 4 5])  # => @[1 3 5]
(filter  (complement even?)        [1 2 3 4 5])  # => @[1 3 5]

(def fns [even? odd?])
(map  (fn [f] (filter f [-2 -1 0 1 2]))  fns)  # => @[ @[-2 0 2] @[-1 1]   ]
(def fns (map complement fns))
(map  (fn [f] (filter f [-2 -1 0 1 2]))  fns)  # => @[ @[-1 1]   @[-2 0 2] ]
cellularmitosisPlayground