Public Vars

Back

some? (clj)

(source)

function

(some? x)
Returns true if x is not nil, false otherwise.

Examples

thheller/shadow-cljs
(ns shadow.remote.runtime.cljs.js-builtins
  (:require
    [goog.object :as gobj]
    [clojure.core.protocols :as p]))

  js/Error
  (datafy [e]
    (let [data (ex-data e)
          file (.-fileName e)
          line (.-lineNumber e)
          column (.-columnNumber e)]
      (-> {:message (.-message e)
           :name (.-name e)
           :stack (.-stack e)}
          (cond->
            (some? data)
            (assoc :data data)
mhuebert/maria
(ns cells.cell
  (:refer-clojure :exclude [bound-fn get])
  (:require [clojure.core :as core]
            [cells.util :as util]
            [applied-science.js-interop :as j]))

(defmacro defcell
  "Defines a named cell."
  [the-name & body]
  (let [[docstring body] (if (string? (first body))
                           [(first body) (rest body)]
                           [nil body])
        [options body] (if (and (map? (first body)) (> (count body) 1))
                         [(first body) (rest body)]
                         [nil body])
        f `(fn [~'self] ~@body)]
    `(do
       ;; support re-evaluation without breaking links
       (declare ~the-name)
       (let [prev-cell# ~the-name]
         (def ~(with-meta the-name options)
           ~@(when docstring (list docstring))
           (if (some? prev-cell#)
             (~'cells.cell/update-cell* prev-cell# ~f)
             (~'cells.cell/cell* ~f)))))))
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))))

; would be nice
; (t/Pred (t/Not nil))
cc/some? [t/Any :-> t/Bool :filters {:then (! nil 0)
                                    :else (is nil 0)}]
nedap/speced.def
(ns nedap.speced.def.impl.def-with-doc
  (:require
   [clojure.core.protocols]
   #?(:cljs [cljs.repl])
   #?(:clj [clojure.spec.alpha :as spec] :cljs [cljs.spec.alpha :as spec])
   [nedap.utils.spec.api :refer [check!]])
  #?(:cljs (:require-macros [nedap.speced.def.impl.def-with-doc]))
  #?(:clj (:import (java.io Writer))))

#?(:clj
   (defmacro def-with-doc
     [spec-name docstring spec doc-registry symbol-doc-registry]
     {:pre [(check! qualified-keyword? spec-name
                    string?            docstring
                    some?              spec)]}
     (when (-> &env :ns nil?)
       (check! (spec/and symbol?
                         resolve) doc-registry
               (spec/and symbol?
                         resolve) symbol-doc-registry))
     (list 'do
           (list `swap! doc-registry `assoc spec-name docstring)
           (list `swap! symbol-doc-registry `assoc (list 'quote (symbol spec-name)) (list `map->Docstring {:docstring docstring}))
           (list (if (-> &env :ns some?)
                   'cljs.spec.alpha/def
                   'clojure.spec.alpha/def)
                 spec-name
                 spec))))
teknql/wing
(ns wing.core.match
  "Extensions to `core.match`"
  #?(:clj (:require [clojure.core.match :as clj]
                    [cljs.core.match :as cljs])
     :cljs (:require [cljs.core.match :as cljs])))

(defmacro match?
  "Returns whether the provided `expr` matches the given `match-pattern`."
  [match-pattern expr]
  (let [cljs? (some? (:js-globals &env))]
    (if-not cljs?
      `(let [val# ~expr]
         (clj/match val#
           ~match-pattern true
           :else false))
      `(let [val# ~expr]
         (cljs/match val#
           ~match-pattern true
           :else false)))))