Public Vars

Back

true? (clj)

(source)

function

(true? x)
Returns true if x is the value true, false otherwise.

Examples

originrose/cortex
(ns cortex.optimise.util-test
  (:refer-clojure :exclude [defonce])
  (:require [cortex.optimise.util :refer :all]
            [clojure.core.matrix :as m]
            [clojure.test :refer :all]))

(deftest seq-like?-test
  (is (false? (seq-like? nil)))
  (is (false? (seq-like? "Hello")))
  (is (false? (seq-like? 5)))
  (is (true? (seq-like? (range 5))))
  (is (true? (seq-like? [:a :b :c])))
  (is (true? (seq-like? {:a 1 :b 2})))
  (is (true? (seq-like? (m/array :vectorz [1 2 3]))))
  (is (true? (seq-like? (m/array :vectorz [[1 2] [3 4]])))))

(deftest approx=-test
  (testing "comparing floats"
    (is (false? (approx= 0.1 10 11)))
    (is (false? (approx= 0.1 10 11.0)))
    (is (true? (approx= 0.1 10.0 11.0)))
    (is (false? (approx= 0.09 10.0 11.0))))
  (testing "comparing more than two floats"
    (is (false? (approx= 0.1 10.0 10.75 11.5)))
    (is (true? (approx= 0.1 10.0 10.5 11.0))))
  (testing "comparing vectors"
    (is (false? (approx= 0.1
                         (m/array :vectorz [10.0 11.0])
                         [11.5 10.0])))
    (is (true? (approx= 0.1
                        (m/array :vectorz [10.0 11.0])
                        [11.0 10.0]))))
  (testing "comparing nested data structures"
    (is (false? (approx= 0.1
                         {:a [10.0 11.0] :b 10.0}
                         {:a [11.0 10.0] :c 10.0})))
    (is (false? (approx= 0.1
                         {:a [10.0 11.0] :b 10.0}
                         {:a [12.0 10.0] :b 10.0})))
    (is (true? (approx= 0.1
                        {:a [10.0 11.0] :b 10.0}
                        {:a [11.0 10.0] :b 10.0}))))
  (testing "lists of different lengths"
    (is (false? (approx= 0.1
                         [1.0 2.0 3.0]
                         [1.0 2.0])))))
hraberg/deuce
(ns deuce.emacs.callproc
  (:use [deuce.emacs-lisp :only (defun defvar) :as el])
  (:require [clojure.core :as c]
            [clojure.string :as s]
            [clojure.java.io :as io]
            [clojure.java.shell :as sh]
            [deuce.emacs.buffer :as buffer]
            [deuce.emacs.data :as data]
            [deuce.emacs.editfns :as editfns])
  (:import [java.io File])
  (:refer-clojure :exclude []))

  If BUFFER is 0, `call-process' returns immediately with value nil.
  Otherwise it waits for PROGRAM to terminate
  and returns a numeric exit status or a signal description string.
  If you quit, the process is killed with SIGINT, or SIGKILL if you quit again."
  (let [opts (if infile [:in (io/file infile)] [])
        no-wait? (= 0 buffer)
        buffer (or no-wait?
                   (and (data/consp buffer) (= :file (data/car buffer)) (data/cdr buffer))
                   (and (true? buffer) (buffer/current-buffer))
                   (el/check-type 'bufferp (or (when (data/consp buffer) (data/car buffer))
                                               buffer (buffer/current-buffer))))
        stderr (when (data/consp buffer) (data/cdr buffer))
        runner (if no-wait? #(do (future-call %) nil) #(%))]
    (runner #(let [{:keys [exit out err]}
                   (apply sh/sh (concat (cons program args) opts))]
               (when (data/bufferp buffer)
                 (binding [buffer/*current-buffer* buffer]
                   (editfns/insert out)
                   (when (true? stderr)
                     (editfns/insert err))))
               (when (string? buffer)
                 (spit (io/file buffer) out))
               (when (string? stderr)
                 (spit (io/file stderr) err))
               exit))))
typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

cc/seq? (t/Pred (t/Seq t/Any))
cc/set? (t/Pred (t/Set t/Any))
cc/vector? (t/Pred (t/Vec t/Any))
cc/nil? (t/Pred nil)
#?@(:cljs [
cc/undefined? (t/Pred t/JSundefined)
])
cc/false? (t/Pred false)
cc/true? (t/Pred true)
cc/symbol? (t/Pred t/Sym)
cc/keyword? (t/Pred t/Keyword)
cc/map? (t/Pred (t/Map t/Any t/Any))
cc/boolean? (t/Pred t/Bool)
cc/any? [t/Any :-> true]
cc/record? (t/Pred #?(:clj clojure.lang.IRecord
                      :cljs cljs.core/IRecord))
liquidz/antq
(ns antq.util.async-test
  (:require
   [antq.util.async :as sut]
   [antq.util.exception :as u.ex]
   [clojure.core.async :as async]
   [clojure.test :as t])
  (:import
   clojure.lang.ExceptionInfo))

  (try
    (test-async-fn ::timeout)
    (t/is false)
    (catch ExceptionInfo ex
      (t/is (true? (u.ex/ex-timeout? ex)))
      (t/is (= "TIMEOUT" (.getMessage ex))))
    (catch Throwable ex
      (t/is false (.getMessage ex))))
fluree/db
(ns json-ld
  (:require [fluree.db.method.ipfs.core :as ipfs]
            [fluree.db.db.json-ld :as jld-db]
            [fluree.db.json-ld.transact :as jld-tx]
            [clojure.core.async :as async]
            [fluree.db.flake :as flake]
            [fluree.db.json-ld.api :as fluree]
            [fluree.db.util.async :refer [<?? go-try channel?]]
            [fluree.db.query.range :as query-range]
            [fluree.db.constants :as const]
            [fluree.db.dbproto :as dbproto]
            [fluree.db.did :as did]
            [fluree.db.conn.proto :as conn-proto]
            [fluree.db.util.json :as json]
            [fluree.json-ld :as json-ld]
            [fluree.db.indexer.default :as indexer]
            [fluree.db.indexer.proto :as idx-proto]
            [fluree.db.util.log :as log]))

  (->> (fluree/db ledger)
       :schema
       :pred
       vals
       set
       (filter #(true? (:ref? %)))
       (map :id)
       sort)