Back
contains? (clj)
(source)function
(contains? coll key)
Returns true if key is present in the given collection, otherwise
returns false. Note that for numerically indexed collections like
vectors and Java arrays, this tests if the numeric key is within the
range of indexes. 'contains?' operates constant or logarithmic time;
it will not perform a linear search for a value. See also 'some'.
Examples
clojure/core.typed
(ns clojure.core.typed.annotator.debug-macros
(:require [clojure.core.typed.annotator.util :refer [*debug*
*debug-depth*
current-time]])
)
(defmacro debug-when [state msg]
`(when (and (set? *debug*)
(contains? *debug* ~state))
(let [msg# ~msg]
(println)
(println (str "SQUASH ITERATION:\n" msg#)))))
PrecursorApp/precursor
(ns pc.http.routes.api
(:require [cemerick.url :as url]
[cheshire.core :as json]
[clojure.core.memoize :as memo]
[clojure.string :as str]
[clojure.tools.reader.edn :as edn]
[crypto.equality :as crypto]
[defpage.core :as defpage :refer (defpage)]
[pc.auth :as auth]
[pc.crm :as crm]
[pc.datomic :as pcd]
[pc.early-access]
[pc.http.doc :as doc-http]
[pc.http.team :as team-http]
[pc.http.handlers.custom-domain :as custom-domain]
[pc.models.chat-bot :as chat-bot-model]
[pc.models.doc :as doc-model]
[pc.models.flag :as flag-model]
[pc.models.team :as team-model]
[pc.profile :as profile]
[ring.middleware.anti-forgery :as csrf]
[slingshot.slingshot :refer (try+ throw+)]))
;; proxy for the dribbble API, to be used by our dribbble cards on the blog
(defpage dribbble-profile "/api/v1/dribbble/users/:username" [req]
(let [username (get-in req [:params :username])]
(if (contains? dribbble-user-whitelist username)
{:body (json/encode (get-dribbble-profile username))
:status 200
:headers {"Content-Type" "application/json; charset=utf-8"}}
(throw+ {:status 400
:public-message "Sorry, this user isn't on the whitelist."}))))
hraberg/deuce
(ns deuce.emacs.eval
(:use [deuce.emacs-lisp :only (defun defvar)])
(:require [clojure.core :as c]
[deuce.emacs.alloc :as alloc]
[deuce.emacs.data :as data]
[deuce.emacs-lisp.cons :as cons]
[deuce.emacs-lisp :as el])
(:import [clojure.lang Var])
(:refer-clojure :exclude [apply eval macroexpand]))
If the optional argument FOR-CALL-INTERACTIVELY is non-nil,
then strings and vectors are not accepted."
(if (or (data/stringp function) (data/vectorp function))
(when-not for-call-interactively true)
(when-let [f (el/fun function)]
(when (contains? (meta f) :interactive)
true))))
unclebob/more-speech
(ns more-speech.nostr.zaps-spec
(:require
[clj-http.client :as client]
[clojure.core.async :as async]
[clojure.data.json :as json]
[clojure.string :as string]
[more-speech.bech32 :as bech32]
[more-speech.config :as config]
[more-speech.db.gateway :as gateway]
[more-speech.mem :refer :all]
[more-speech.nostr.elliptic-signature :as es]
[more-speech.nostr.event-composers :as composers]
[more-speech.nostr.util :as util]
[more-speech.nostr.zaps :as zaps]
[more-speech.relay :as relay]
[more-speech.spec-util :refer :all]
[more-speech.util.fortune-messages :as fortune]
[more-speech.websocket-relay :as ws-relay]
[speclj.core :refer :all])
(:import (ecdhJava SECP256K1)))
(should= 9734 kind)
(should= (:zap-comment @zap-descriptor) content)
(should= my-pubkey (util/unhexify pubkey))
(should= (util/get-now) created_at)
(should (contains? tags ["relays" "relay-r1" "relay-r2"]))
(should (contains? tags ["amount" "1000"]))
(should (contains? tags ["lnurl" b32-lnurl]))
(should (contains? tags ["p" (util/hexify (:pubkey @zap-descriptor))]))
(should (contains? tags ["e" (util/hexify (:id @zap-descriptor))])))))
re-path/studio
(ns renderer.tools.edit
(:require
[clojure.core.matrix :as mat]
[renderer.element.handlers :as element.h]
[renderer.handlers :as handlers]
[renderer.history.handlers :as history]
[renderer.tools.base :as tools]
[renderer.utils.pointer :as pointer]))
(defmethod tools/drag :edit
[{:keys [adjusted-pointer-offset adjusted-pointer-pos clicked-element] :as db} e]
(let [pointer-offset (mat/sub adjusted-pointer-pos adjusted-pointer-offset)
db (history/swap db)
element-key (:element clicked-element)
pointer-offset (if (contains? (:modifiers e) :ctrl)
(pointer/lock-direction pointer-offset)
pointer-offset)]
(if element-key
(assoc-in db
(conj (element.h/path db) element-key)
(tools/edit (element.h/element db element-key)
pointer-offset
(:key clicked-element)))
db)))