clojure-uebungen/Assignment_017/solution
Thomas Smits 04dda27e57 Update of exercises 2024-03-11 10:41:23 +01:00
..
readme.md Update of exercises 2024-03-11 10:41:23 +01:00

readme.md

Lösung: filter

(defn filter-positive
    "Läuft über `data` und gibt die Elemente, deren Wert >= 0 ist zurück."
    [data]
    (filter #(>= % 0) data))

; Testfälle
(assert (= [1 2 3 4 0 5 6] (filter-positive [1 2 3 4 0 5 6])))
(assert (= [2 3]           (filter-positive '(-1 2 3 -4))))
(assert (= [42 0 42]       (filter-positive '(42 -23 0 -23 42))))