Back

flatten (clj)

(source)

function

(flatten s)

Examples

tick
(ns tick.alpha.interval-test
  (:require
   [clojure.spec.alpha :as s]
   [tick.core :as t]
   [tick.protocols :as p]
   [clojure.test
    :refer [deftest is testing run-tests]
    :refer-macros [deftest is testing run-tests]]
   [tick.alpha.interval :as ti]
   #?@(:cljs [[java.time :refer [Instant LocalDateTime LocalTime]]]))
  #?(:clj
     (:import [java.time LocalDateTime Instant LocalTime])))

(deftest flatten-test
  (let [ivals [(ti/new-interval (t/date "2017-06-15") (t/date "2017-06-25"))
               (ti/new-interval (t/date "2017-06-17") (t/date "2017-06-20"))
               (ti/new-interval (t/date "2017-06-18") (t/date "2017-06-25"))
               (ti/new-interval (t/date "2017-07-18") (t/date "2017-07-25"))
               (ti/new-interval (t/date "2017-08-18") (t/date "2017-08-25"))]]
    (is (= ivals (ti/flatten (ti/unite ivals))))))