Back

ceil (clj)

(source)

function

(ceil a)
Returns the smallest double greater than or equal to a, and equal to a mathematical integer. If a is ##NaN or ##Inf or ##-Inf or already equal to an integer => a See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#ceil-double-

Examples

clojure
(ns clojure.test-clojure.math
  (:require
    [clojure.test :refer :all]
    [clojure.math :as m]))

(deftest test-ceil
  (is (NaN? (m/ceil ##NaN)))
  (is (= ##Inf (m/ceil ##Inf)))
  (is (= ##-Inf (m/ceil ##-Inf)))
  (is (= 4.0 (m/ceil m/PI))))
dco-dev/interval-tree
(ns com.dean.interval-tree.ordered-set-test
  (:require [clojure.core.reducers        :as r]
            [clojure.math.combinatorics   :as combo]
            [clojure.set                  :as set]
            [clojure.test                 :refer :all]
            [com.dean.interval-tree.core  :refer :all]))

(deftest simple-checks
  (let [x (ordered-set (shuffle (range 8)))
        y (ordered-set (shuffle (range 20)))
        z (ordered-set (shuffle (range 0 20 2)))]
    (is (= #{} (ordered-set)))
    (is (= #{} (disj (ordered-set) 1)))
    (is (= #{} (disj (ordered-set [1]) 1)))
    (is (set? (ordered-set)))
    (is (= #{0 1 2 3 4 5 6 7}     (conj x 5)))
    (is (= #{0 1 2 3 4 5 6 7 9}   (conj x 9)))
    (is (= #{-1 0 1 2 3 4 5 6 7}  (conj x -1)))
    (is (= #{1 2 3 4 5 6 7}       (disj x 0)))
    (is (= [9 0 1 2 3 4 5 6 7]    (cons 9 x)))
    (is (= 0 (first x)))
    (is (= 7 (last x)))
    (doseq [i (range 20)]
      (is (= i (nth y i)))
      (is (= i (y i)))
      (is (= i (get y i)))
      (is (= ::nope (get y (+ 100 i) ::nope)))
      (is (= i (.ceiling y i)))
      (is (= i (.floor y i)))
      (is (= (if (even? i) i (dec i)) (.floor z i)))
      (is (= i (->> y (drop i) first))))
    (is (= #{4 5 6}  (.subSet x 3 7)))))