Public Vars

Back

loop (clj)

(source)

macro

(loop bindings & body)
Evaluates the exprs in a lexical context in which the symbols in the binding-forms are bound to their respective init-exprs or parts therein. Acts as a recur target.

Examples

clj-kondo/clj-kondo
(ns core-async.alt
  (:require [clojure.core.async :as a]
            [clojure.string :as str]))

(loop []
  (a/alt!!
    (a/timeout 1000)
    ([v _ch]
     (println "got" v)
     (recur)))) ;; no invalid arity for recur
clojure/core.typed
(ns ^:skip-wiki clojure.core.typed.checker.check.recur-utils
  (:require [clojure.core.typed.checker.utils :as u]
            [clojure.core.typed.checker.type-rep :as r]))

(defonce ^:dynamic *loop-bnd-anns* nil)
(set-validator! #'*loop-bnd-anns* #(or (nil? %)
                                       (every? r/Type? %)))
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-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))))))
hraberg/deuce
(ns deuce.emacs.macros
  (:use [deuce.emacs-lisp :only (defun defvar)])
  (:require [clojure.core :as c])
  (:refer-clojure :exclude []))

(defun execute-kbd-macro (macro &optional count loopfunc)
  "Execute MACRO as string of editor command characters.
  If MACRO is a symbol, its function definition is used.
  COUNT is a repeat count, or nil for once, or 0 for infinite loop.

(defun end-kbd-macro (&optional repeat loopfunc)
  "Finish defining a keyboard macro.
  The definition was started by M-x start-kbd-macro.
  The macro is now available for use via M-x call-last-kbd-macro,
  or it can be given a name with M-x name-last-kbd-macro and then invoked
  under that name.

(defun call-last-kbd-macro (&optional prefix loopfunc)
  "Call the last keyboard macro that you defined with M-x start-kbd-macro.
epiccastle/spire
(ns spire.output.events
  (:require [spire.output.core :as output]
            [puget.printer :as puget]
            [clojure.core.async :refer [<!! put! go chan thread]]))

(defmethod output/print-thread :events [_]
  (thread
    (loop []
      (puget/cprint (<!! prn-chan))
      (recur))))