Back
floor (clj)
(source)function
(floor a)
Returns the largest double less 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
If a is less than zero but greater than -1.0 => -0.0
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#floor-double-
Examples
clojure
(ns clojure.test-clojure.math
(:require
[clojure.test :refer :all]
[clojure.math :as m]))
(deftest test-floor
(is (NaN? (m/floor ##NaN)))
(is (= ##Inf (m/floor ##Inf)))
(is (= ##-Inf (m/floor ##-Inf)))
(is (= 3.0 (m/floor m/PI))))
(deftest test-floor-div
(is (= Long/MIN_VALUE (m/floor-div Long/MIN_VALUE -1)))
(is (= -1 (m/floor-div -2 5))))
(deftest test-floor-mod
(is (= 3 (m/floor-mod -2 5))))
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)))))
Vaguery/klapaucius
(ns push.type.item.generator
(:require [push.instructions.dsl :as d]
[push.instructions.core :as i]
[push.type.definitions.generator :as g]
[push.util.numerics :as n :refer [infinite?]]
[clojure.math.numeric-tower :as nt :refer [floor]]
[push.type.core :as t]
[push.util.code-wrangling :as u :refer [safe-mod]]
[push.instructions.aspects :as aspects]
[push.util.exotics :as exotics]
))
(d/consume-top-of :generator :as :arg)
(d/consume-top-of :scalar :as :steps)
(d/calculate [:arg :steps]
#(first
(drop
(nt/floor (max 0 (min (u/safe-mod %2 100) 99)))
(iterate
(fn [g] (when-not (nil? g) (g/step-generator g)))
%1))) :as :result)
(d/return-item :result)
))