Public Vars

Back

not-empty (clj)

(source)

function

(not-empty coll)
If coll is empty, returns nil, else coll

Examples

typedclojure/typedclojure
(ns typed.clojure.jvm
  "JVM-specific annotations and operations.
  See typed.clojure for cross-platform ops."
  (:require clojure.core.typed
            [clojure.core.typed.current-impl :as impl]
            [clojure.core.typed.internal :refer [take-when]]
            [typed.cljc.runtime.env-utils :refer [delay-type]]
            [clojure.core.typed.macros :as macros]))

(defmacro override-classes [& args]
  (assert (even? (count args)))
  `(do ~@(map (fn [[nme [frees & {:as opts}]]]
                `(override-class ~@(some-> (not-empty frees) vector) ~nme ~(or (not-empty opts) {})))
              (partition-all 2 args))))
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))))

;;TODO clojure.core/not-empty
cc/seq (t/All [[x :< t/AnySeqable]]
              [x :-> (t/SeqOn x) :object {:id 0 :path [Seq]}])
#_(t/All [x] (t/IFn [(t/NonEmptyColl x) :-> (t/NonEmptyASeq x)
                          :filters {:then tt
                                    :else ff}]
                         [(t/Option (t/Coll x)) :-> (t/NilableNonEmptyASeq x)
                          :filters {:then (& (is t/NonEmptyCount 0)
                                             (! nil 0))
                                    :else (| (is nil 0)
                                             (is t/EmptyCount 0))}]
                         [(t/Seqable x) :-> (t/NilableNonEmptyASeq x)]))
yetibot/core
(ns yetibot.core.test.handler
  (:require
   [midje.sweet :refer [facts fact => =not=> contains provided]]
   [yetibot.core.handler :as h]
   [clojure.string :as s]
   [yetibot.core.interpreter :as i]
   yetibot.core.test.db
   yetibot.core.commands.echo
   [yetibot.core.chat :refer [chat-data-structure *adapter*]]
   [clojure.core.async :refer [<!!]]))

   (fact
    "it will return a map with the value of the response, related data,
     and settings"
    (h/handle-parsed-expr cs
                          user
                          yb-user
                          (first
                           (:parsed-cmds (h/->parsed-message-info
                                          "!echo hello"))))
    => (contains {:data nil?
                  :settings not-empty
                  :value "hello"}))))
howonlee/mertonon
(ns mertonon.services.grad-service-test
  (:require [clojure.core.matrix :as cm]
            [clojure.core.matrix.operators :as cmo]
            [clojure.data :as cd]
            [clojure.test :refer :all]
            [clojure.test.check :as tc]
            [clojure.test.check.clojure-test :refer :all]
            [clojure.test.check.generators :as gen]
            [clojure.test.check.properties :as prop]
            [mertonon.autodiff.reverse-ops :as ops]
            [mertonon.generators.aug-net :as aug-net-gen]
            [mertonon.generators.grad-net :as grad-net-gen]
            [mertonon.generators.net :as net-gen]
            [mertonon.services.grad-service :as gs]
            [mertonon.services.graph-service :as graphs]
            [mertonon.services.matrix-service :as ms]
            [mertonon.test-utils :as tu]))

(defspec linear-grad-run-test
  tu/many
  (prop/for-all [[matrix-net patterns] (grad-net-gen/matrix-net-and-patterns aug-net-gen/net-and-entries)]
                (let [forward-pass (gs/net-patterns->forward-pass matrix-net patterns)]
                  (not-empty (:grads (gs/forward-pass->grad forward-pass))))))

(defspec dag-grad-run-test
  tu/many
  (prop/for-all [[matrix-net patterns] (grad-net-gen/matrix-net-and-patterns aug-net-gen/dag-net-and-entries)]
                (let [forward-pass (gs/net-patterns->forward-pass matrix-net patterns)]
                  (not-empty (:grads (gs/forward-pass->grad forward-pass))))))