Back
min (clj)
(source)function
(min x)
(min x y)
(min x y & more)
Returns the least of the nums.
Examples
originrose/cortex
(ns cortex.nn.impl
"Implementation helpers to aid implementing neural network cortex protocols
or specific neural network layers"
(:require [cortex.nn.layers :as layers]
[clojure.core.matrix.macros :refer [c-for]]))
(defmacro convolution-outer-kernel
[conv-desc & body]
`(let [~'conv-desc ~conv-desc
~'output-width (long (:output-width ~'conv-desc))
~'output-height (long (:output-height ~'conv-desc))
~'num-in-channels (long (:input-channels ~'conv-desc))
~'num-out-channels (long (:output-channels ~'conv-desc))
~'input-width (long (:input-width ~'conv-desc))
~'input-height (long (:input-height ~'conv-desc))
~'input-planar-stride (* ~'input-width ~'input-height)
~'output-planar-stride (* ~'output-width ~'output-height)
~'kernel-width (long (:kernel-width ~'conv-desc))
~'kernel-height (long (:kernel-height ~'conv-desc))
~'output-channel-stride (* ~'kernel-width ~'kernel-height)
~'output-column-stride (* ~'output-channel-stride ~'num-in-channels)
~'stride-y (long (:stride-y ~'conv-desc))
~'stride-x (long (:stride-x ~'conv-desc))
~'pad-x (long (:pad-x ~'conv-desc))
~'pad-y (long (:pad-y ~'conv-desc))
~'min-x (- 0 ~'pad-x)
~'min-y (- 0 ~'pad-y)
~'max-x (+ ~'input-width ~'pad-x)
~'max-y (+ ~'input-height ~'pad-y)
~'kernel-num-elems (* ~'kernel-width ~'kernel-height)]
(c-for
[~'chan 0 (< ~'chan ~'num-in-channels) (inc ~'chan)]
(let [~'chan-input-offset (* ~'chan ~'input-planar-stride)
~'chan-output-offset (* ~'chan ~'output-planar-stride)]
(c-for
[~'out-y 0 (< ~'out-y ~'output-height) (inc ~'out-y)]
(let [~'input-rel-y (- (* ~'out-y ~'stride-y) ~'pad-y)]
(c-for
[~'out-x 0 (< ~'out-x ~'output-width) (inc ~'out-x)]
(let [~'input-rel-x (- (* ~'out-x ~'stride-x) ~'pad-x)]
~@body))))))))
(defmacro in-bounds?
"is value within the range of [min-val, max-val)"
[value min-val max-val]
`(and (>= ~value ~min-val)
(< ~value ~max-val)))
(defmacro convolution-roll-unroll-inner-kernel
[& body]
`(let [~'chan-conv-offset (* ~'chan ~'output-channel-stride)
~'output-offset (+ (* ~'out-y ~'output-width)
~'out-x)
;;positive values for how far out we are into the padding
input-over-x# (max 0 (- (+ ~'input-rel-x ~'kernel-width)
~'input-width))
input-over-y# (max 0 (- (+ ~'input-rel-y ~'kernel-height)
~'input-height))
;;Negative values for how far before the 0 idx we are.
input-under-x# (min ~'input-rel-x 0)
input-under-y# (min ~'input-rel-y 0)
;;Width of the kernel excluding padding
~'exc-pad-width (max 0 (+ (- ~'kernel-width input-over-x#)
input-under-x#))
~'exc-pad-height (max 0 (+ (- ~'kernel-height input-over-y#)
input-under-y#))
~'exc-pad-kernel-num-elems (* ~'exc-pad-width ~'exc-pad-height)]
(c-for
[~'k-y 0 (< ~'k-y ~'kernel-height) (inc ~'k-y)]
(c-for
[~'k-x 0 (< ~'k-x ~'kernel-width) (inc ~'k-x)]
(let [~'input-x (+ ~'input-rel-x ~'k-x)
~'input-y (+ ~'input-rel-y ~'k-y)
~'output-conv-addr (+ (* ~'output-offset
~'output-column-stride)
~'chan-conv-offset
(* ~'k-y ~'kernel-width)
~'k-x)
~'input-addr (+ (* ~'input-y ~'input-width)
~'input-x
~'chan-input-offset)
~'input-valid? (and (in-bounds? ~'input-x 0 ~'input-width)
(in-bounds? ~'input-y 0 ~'input-height))
loop-valid?# (and (in-bounds? ~'input-x ~'min-x ~'max-x)
(in-bounds? ~'input-y ~'min-y ~'max-y))]
(when loop-valid?#
~@body))))))
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+)]))
(defpage new [:post "/api/v1/document/new"] [req]
(let [params (some-> req :body slurp edn/read-string)
read-only? (:read-only params)
doc-name (:document/name params)]
(if-not (:subdomain req)
(let [cust-uuid (get-in req [:auth :cust :cust/uuid])
intro-layers? (:intro-layers? params)
doc (doc-model/create-public-doc!
(merge {:document/chat-bot (rand-nth chat-bot-model/chat-bots)}
(when cust-uuid {:document/creator cust-uuid})
(when read-only? {:document/privacy :document.privacy/read-only})
(when doc-name {:document/name doc-name})))]
(when intro-layers?
(doc-http/add-intro-layers doc))
{:status 200 :body (pr-str {:document (doc-model/read-api doc)})})
(if (and (:team req)
(auth/logged-in? req)
(auth/has-team-permission? (pcd/default-db) (:team req) (:auth req) :admin))
(let [doc (doc-model/create-team-doc!
(:team req)
(merge {:document/chat-bot (rand-nth chat-bot-model/chat-bots)}
(when-let [cust-uuid (get-in req [:cust :cust/uuid])]
{:document/creator cust-uuid})
(when read-only?
{:document/privacy :document.privacy/read-only})
(when doc-name
{:document/name doc-name})))]
{:status 200 :body (pr-str {:document (doc-model/read-api doc)})})
{:status 400 :body (pr-str {:error :unauthorized-to-team
:redirect-url (str (url/map->URL {:host (profile/hostname)
:protocol (if (profile/force-ssl?)
"https"
(name (:scheme req)))
:port (if (profile/force-ssl?)
(profile/https-port)
(profile/http-port))
:path "/new"
:query (:query-string req)}))
:msg "You're unauthorized to make documents in this subdomain. Please request access."})}))))
hraberg/deuce
(ns deuce.emacs.indent
(:use [deuce.emacs-lisp :only (defun defvar)])
(:require [clojure.core :as c]
[deuce.emacs.buffer :as buffer]
[deuce.emacs.data :as data]
[deuce.emacs.editfns :as editfns])
(:refer-clojure :exclude []))
(defun current-column ()
"Return the horizontal position of point. Beginning of line is column 0.
This is calculated by adding together the widths of all the displayed
representations of the character between the start of the previous line
and point (eg. control characters will have a width of 2 or 4, tabs
will have a variable width).
Ignores finite width of frame, which means that this function may return
values greater than (frame-width).
Whether the line is visible (if `selective-display' is t) has no effect;
however, ^M is treated as end of line when `selective-display' is t.
Text that has an invisible property is considered as having width 0, unless
`buffer-invisibility-spec' specifies that it is replaced by an ellipsis."
(let [point (editfns/point)
line (.lastIndexOf (str (editfns/buffer-substring (editfns/point-min) point)) "\n")]
(dec (if (= -1 line) point (dec (- point line))))))
(defun compute-motion (from frompos to topos width offsets window)
"Scan through the current buffer, calculating screen position.
Scan the current buffer forward from offset FROM,
assuming it is at position FROMPOS--a cons of the form (HPOS . VPOS)--
to position TO or position TOPOS--another cons of the form (HPOS . VPOS)--
and return the ending buffer position and screen location.
(defun indent-to (column &optional minimum)
"Indent from point with tabs and spaces until COLUMN is reached.
Optional second argument MINIMUM says always do at least MINIMUM spaces
even if that goes past COLUMN; by default, MINIMUM is zero.
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))))
#?(:cljs cc/*clojurescript-version* :default cc/*clojure-version*)
'{:major t/Any :minor t/Any :incremental t/Any :qualifier t/Any}
#?@(:cljs [] :default [
cc/rational? (t/Pred (t/U t/Int clojure.lang.Ratio BigDecimal))
cc/decimal? (t/Pred BigDecimal)
cc/denominator [clojure.lang.Ratio :-> t/Num]
])
cc/max-key (t/All [x] [[x :-> t/Num] (t/+ x) :-> x])
cc/min-key (t/All [x] [[x :-> t/Num] (t/+ x) :-> x])
cc/max (t/IFn #?(:clj [(t/+ Long) :-> Long])
#?(:clj [(t/+ Double) :-> Double])
[(t/+ t/AnyInteger) :-> t/AnyInteger]
[(t/+ t/Num) :-> t/Num])
cc/min (t/IFn #?(:clj [(t/+ Long) :-> Long])
#?(:clj [(t/+ Double) :-> Double])
[(t/+ t/AnyInteger) :-> t/AnyInteger]
[(t/+ t/Num) :-> t/Num])
#?@(:cljs [] :default [
cc/ref (t/All [x] [x & :optional {:validator (t/U nil [x :-> t/Any]) :meta (t/U nil (t/Map t/Any t/Any))
:min-history (t/U nil t/AnyInteger)
:max-history (t/U nil t/AnyInteger)}
:-> (t/Ref x)])
])
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]))
(def ipfs-conn @(fluree/connect-ipfs
{:server nil ;; use default
;; ledger defaults used for newly created ledgers
:defaults {:ipns {:key "self"} ;; publish to ipns by default using the provided key/profile
:indexer {:reindex-min-bytes 100
:reindex-max-bytes 10000000}
:context {:id "@id"
:type "@type"
:schema "http://schema.org/"
:rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
:rdfs "http://www.w3.org/2000/01/rdf-schema#"
:wiki "https://www.wikidata.org/wiki/"
:skos "http://www.w3.org/2008/05/skos#"
:f "https://ns.flur.ee/ledger#"}
:did (did/private->did-map "8ce4eca704d653dec594703c81a84c403c39f262e54ed014ed857438933a2e1c")}}))