Public Vars

Back

zero? (clj)

(source)

function

(zero? num)
Returns true if num is zero, else false

Examples

hraberg/deuce
(ns deuce.emacs.floatfns
  (:use [deuce.emacs-lisp :only (defun defvar)])
  (:require [clojure.core :as c]
            [deuce.emacs.alloc :as alloc])
  (:refer-clojure :exclude [float]))

  The function returns the cons cell (SGNFCAND . EXP).
  If X is zero, both parts (SGNFCAND and EXP) are zero."
  (if (zero? x)
    (alloc/cons 0.0 0)
    (let [exp (inc (Math/getExponent (double x)))]
      (alloc/cons (/ x (Math/pow 2 exp)) exp))))
dco-dev/interval-tree
(ns com.dean.interval-tree.tree.ordered-map
  (:require [clojure.core.reducers       :as r :refer [coll-fold]]
            [com.dean.interval-tree.tree.node     :as node]
            [com.dean.interval-tree.tree.protocol :as proto]
            [com.dean.interval-tree.tree.root]
            [com.dean.interval-tree.tree.tree     :as tree]
            [com.dean.interval-tree.tree.order    :as order])
  (:import  [clojure.lang                RT]
            [com.dean.interval_tree.tree.root     INodeCollection
                                         IBalancedCollection
                                         IOrderedCollection]))

  clojure.lang.IPersistentCollection
  (equiv [this o]
    (with-ordered-map this
      (cond
        (identical? this o) 0
        (.isCompatible this o) (and (= (.count this) (.count o))
                                    (zero? (tree/node-map-compare root (.getRoot o))))
        (map? o) (.equiv (into (empty o) (tree/node-vec root :accessor :kv)) o)
        true     (throw (ex-info "unsupported comparison: " {:this this :o o})))))
datastax/fallout
(ns clojure.core.rrb-vector.transients
  (:require [clojure.core.rrb-vector.nodes :refer [ranges last-range]])
  (:import (clojure.core.rrb_vector.nodes NodeManager)
           (clojure.core ArrayManager)
           (java.util.concurrent.atomic AtomicReference)))

    (ensureEditable [this nm am root-edit current-node shift]
      (if (identical? root-edit (.edit nm current-node))
        current-node
        (if (zero? shift)
          (let [new-arr (.aclone am (.array nm current-node))]
            (.node nm root-edit new-arr))
          (let [new-arr (aclone ^objects (.array nm current-node))]
            (if (== 33 (alength ^objects new-arr))
              (aset new-arr 32 (aclone (ints (aget ^objects new-arr 32)))))
            (.node nm root-edit new-arr)))))

    (popTail [this nm am shift cnt root-edit current-node]
      (let [ret (.ensureEditable this nm am root-edit current-node shift)]
        (if (.regular nm ret)
          (let [subidx (bit-and
                        (bit-shift-right (unchecked-dec-int cnt) shift)
                        0x1f)]
            (cond
              (> shift 5)
              (let [child (.popTail this nm am
                                    (unchecked-subtract-int shift 5)
                                    cnt
                                    root-edit
                                    (aget ^objects (.array nm ret) subidx))]
                (if (and (nil? child) (zero? subidx))
                  nil
                  (let [arr (.array nm ret)]
                    (aset ^objects arr subidx child)
                    ret)))

              (zero? subidx)
              nil

              :else
              (let [arr (.array nm ret)]
                (aset ^objects arr subidx nil)
                ret)))
          (let [rngs   (ranges nm ret)
                subidx (bit-and
                        (bit-shift-right (unchecked-dec-int cnt) shift)
                        0x1f)
                subidx (loop [subidx subidx]
                         (if (or (zero? (aget rngs (unchecked-inc-int subidx)))
                                 (== subidx 31))
                           subidx
                           (recur (unchecked-inc-int subidx))))]
            (cond
              (> shift 5)
              (let [child     (aget ^objects (.array nm ret) subidx)
                    child-cnt (if (zero? subidx)
                                (aget rngs 0)
                                (unchecked-subtract-int
                                 (aget rngs subidx)
                                 (aget rngs (unchecked-dec-int subidx))))
                    new-child (.popTail this nm am
                                        (unchecked-subtract-int subidx 5)
                                        child-cnt
                                        root-edit
                                        child)]
                (cond
                  (and (nil? new-child) (zero? subidx))
                  nil

              (zero? subidx)
              nil

              :else
              (let [arr   (.array nm ret)
                    child (aget ^objects arr subidx)]
                (aset ^objects arr subidx nil)
                (aset rngs subidx 0)
                (aset rngs 32     (unchecked-dec-int (aget rngs 32)))
                ret))))))
    
    (doAssoc [this nm am shift root-edit current-node i val]
      (let [ret (.ensureEditable this nm am root-edit current-node shift)]
        (if (.regular nm ret)
          (loop [shift shift
                 node  ret]
            (if (zero? shift)
              (let [arr (.array nm node)]
                (.aset am arr (bit-and i 0x1f) val))
              (let [arr    (.array nm node)
                    subidx (bit-and (bit-shift-right i shift) 0x1f)
                    child  (.ensureEditable this nm am
                                            root-edit
                                            (aget ^objects arr subidx)
                                            shift)]
                (aset ^objects arr subidx child)
                (recur (unchecked-subtract-int shift 5) child))))
          (let [arr    (.array nm ret)
                rngs   (ranges nm ret)
                subidx (bit-and (bit-shift-right i shift) 0x1f)
                subidx (loop [subidx subidx]
                         (if (< i (aget rngs subidx))
                           subidx
                           (recur (unchecked-inc-int subidx))))
                i      (if (zero? subidx)
                         i
                         (unchecked-subtract-int
                          i (aget rngs (unchecked-dec-int subidx))))]
            (aset ^objects arr subidx
                  (.doAssoc this nm am
                            (unchecked-subtract-int shift 5)
                            root-edit
                            (aget ^objects arr subidx)
                            i
                            val))))
        ret))
aliostad/deep-learning-lang-detection
(ns hugsql-finagle-async.core-test
  (:require [clojure.core.async :as async]
            [clojure.java.io :as io]
            [clojure.test :refer :all]
            [finagle-clojure.mysql.client :as mysql]
            [hugsql-finagle-async.core :refer :all]
            [hugsql.core :as hugsql]))

  (testing "select the weight 0 character with dynamic table-name"
    (is (= (zero? (:weight (async/<!! (select-character-by-weight Client {:weight 0
                                                                          :table-name "characters"})))))))
zalando-incubator/chisel
(ns chisel.trace-test
  (:require [clojure.test :refer :all]
            [chisel.trace :as trace]
            [io.pedestal.log :as plog]
            [clojure.core.async :as a]
            [chisel.async-utils :as async]
            [taoensso.timbre :as timbre]
            [chisel.test-utils :as test-utils]
            [clj-http.client :as http]
            [chisel.correlation-ctx :as ctx]
            [ring.util.response :as r]
            [io.pedestal.interceptor.helpers :as interceptor])
  (:import (io.opentracing Span)))

  (testing "finalises span on normal return"
    (let [capture (atom 0)]
      (with-redefs [plog/finish-span (fn [_]
                                       (swap! capture inc))]
        (trace/with-span "another-span"
                         (is (zero? @capture)))
        (is (= 1 @capture)))))

  (testing "finalises span on normal return"
    (let [capture (atom 0)]
      (with-redefs [plog/finish-span (fn [_]
                                       (swap! capture inc))]
        (a/<!! (trace/go-with-span "another-span"
                                (is (zero? @capture))))
        (is (= 1 @capture)))))