Back
seque (clj)
(source)function
(seque s)
(seque n-or-q s)
Creates a queued seq on another (presumably lazy) seq s. The queued
seq will produce a concrete seq in the background, and can get up to
n items ahead of the consumer. n-or-q can be an integer n buffer
size, or an instance of java.util.concurrent BlockingQueue. Note
that reading from a seque can block if the reader gets ahead of the
producer.
Examples
penpot/penpot
#_:clj-kondo/ignore
(ns app.common.data.macros
"Data retrieval & manipulation specific macros."
(:refer-clojure :exclude [get-in select-keys str with-open min max])
#?(:cljs (:require-macros [app.common.data.macros]))
(:require
#?(:clj [clojure.core :as c]
:cljs [cljs.core :as c])
[app.common.data :as d]
[cljs.analyzer.api :as aapi]
[cuerdas.core :as str]))
(defmacro fmt
"String interpolation helper. Can only be used with strings known at
compile time. Can be used with indexed params access or sequential.
(dm/fmt \"url(%)\" my-url) ; sequential
(dm/fmt \"url(%1)\" my-url) ; indexed
"
[s & params]
`(str/ffmt ~s ~@params))
clojure/core.typed
(ns ^:skip-wiki clojure.core.typed.ann.clojure
"Type annotations for the base Clojure distribution."
(:require [#?(:clj clojure.core.typed
:cljs cljs.core.typed)
:refer [defalias] :as t]))
(defalias
^{:doc "A type that can be used to create a sequence of member type x."
:forms '[(Seqable t)]}
t/Seqable
(t/TFn [[x :variance :covariant]]
#?(:clj (clojure.lang.Seqable x)
:cljs (cljs.core/ISeqable x))))
(defalias
^{:doc "A non-empty lazy sequence of type t"
:forms '[(NonEmptyLazySeq t)]}
t/NonEmptyLazySeq
(t/TFn [[t :variance :covariant]]
(t/I (clojure.lang.LazySeq t)
t/NonEmptyCount)))
(defalias
^{:doc "A type that can be used to create a sequence of member type x
with count greater than 0."
:forms '[(NonEmptySeqable t)]}
t/NonEmptySeqable
(t/TFn [[x :variance :covariant]]
(t/I (t/Seqable x)
t/NonEmptyCount)))
(defalias
^{:doc "A type that can be used to create a sequence of member type x
with count 0."
:forms '[(EmptySeqable t)]}
t/EmptySeqable
(t/TFn [[x :variance :covariant]]
(t/I (t/Seqable x)
t/EmptyCount)))
(defalias
^{:doc "A persistent sequence of member type x."
:forms '[(Seq t)]}
t/Seq
(t/TFn [[x :variance :covariant]]
(clojure.lang.ISeq x)))
(defalias
^{:doc "A persistent sequence of member type x with count greater than 0."
:forms '[(NonEmptySeq t)]}
t/NonEmptySeq
(t/TFn [[x :variance :covariant]]
(t/I (t/Seq x)
t/NonEmptyCount)))
(defalias
^{:doc "A persistent sequence of member type x with count greater than 0, or nil."
:forms '[(NilableNonEmptySeq t)]}
t/NilableNonEmptySeq
(t/TFn [[x :variance :covariant]]
(t/Nilable
(t/NonEmptySeq x))))
(defalias
^{:doc "A sequential collection."
:forms '[Sequential]}
t/Sequential
clojure.lang.Sequential)
(defalias
^{:doc "A sequential, seqable collection. Seq's aren't always Sequential."
:forms '[(SequentialSeqable t)]}
t/SequentialSeqable
(t/TFn [[x :variance :covariant]]
(t/I t/Sequential
(t/Seqable x))))
(defalias
^{:doc "A Clojure sequential sequence. Seq's aren't always Sequential."
:forms '[(SequentialSeq t)]}
t/SequentialSeq
(t/TFn [[x :variance :covariant]]
(t/I t/Sequential
(clojure.lang.ISeq x))))
(defalias
^{:doc "A sequential seq returned from clojure.core/seq"
:forms '[(ASeq t)]}
t/ASeq
(t/TFn [[x :variance :covariant]]
(t/I (t/SequentialSeq x)
(Iterable x)
(java.util.Collection x)
(java.util.List x)
clojure.lang.IObj)))
(defalias
^{:doc "A sequential non-empty seq retured from clojure.core/seq"
:forms '[(NonEmptyASeq t)]}
t/NonEmptyASeq
(t/TFn [[x :variance :covariant]]
(t/I (t/ASeq x)
t/NonEmptyCount)))
mikera/core.matrix
WARNING: because they lack efficient indexed access, sequences will perform badly for most
array operations. In general they should be converted to other implementations before use."
(:require [clojure.core.matrix.protocols :as mp]
[clojure.core.matrix.implementations :as imp]
#?(:clj [clojure.core.matrix.macros :refer [scalar-coerce error]]))
#?(:clj (:import [clojure.lang ISeq])
:cljs (:require-macros [clojure.core.matrix.macros :refer [scalar-coerce error]])))
(extend-protocol mp/PImplementation
ISeq
(implementation-key [m] :sequence)
(meta-info [m]
{:doc "Core.matrix implementation for Clojure ISeq objects"})
(new-vector [m length]
(mp/new-vector [] length))
(new-matrix [m rows columns]
(mp/new-matrix [] rows columns))
(new-matrix-nd [m dims]
(mp/new-matrix-nd [] dims))
(construct-matrix [m data]
(mp/coerce-param [] data))
(supports-dimensionality? [m dims]
true))
(extend-protocol mp/PFunctionalOperations
ISeq
(element-seq [m]
(if (== 0 (long (mp/dimensionality (first m))))
m ;; handle 1D case, just return this sequence unchanged
(mapcat mp/element-seq m)))
(element-map
([m f]
(mapv #(mp/element-map % f) m))
([m f a]
(let [[m a] (mp/broadcast-compatible m a)]
(mapv #(mp/element-map % f %2) m (mp/get-major-slice-seq a))))
([m f a more]
(let [[m a & more] (apply mp/broadcast-compatible m a more)] ; FIXME
(mapv #(mp/element-map % f %2 %3) m (mp/get-major-slice-seq a) (map mp/get-major-slice-seq more)))))
(element-map!
([m f]
(error "Sequence arrays are not mutable!"))
([m f a]
(error "Sequence arrays are not mutable!"))
([m f a more]
(error "Sequence arrays are not mutable!")))
(element-reduce
([m f]
(reduce f (mapcat mp/element-seq m)))
([m f init]
(reduce f init (mapcat mp/element-seq m)))))
hraberg/deuce
(ns deuce.emacs.menu
(:use [deuce.emacs-lisp :only (defun defvar)])
(:require [clojure.core :as c])
(:refer-clojure :exclude []))
When MENU is a keymap or a list of keymaps, the return value is the
list of events corresponding to the user's choice. Note that
`x-popup-menu' does not actually execute the command bound to that
sequence of events.
If POSITION is nil, don't display the menu at all, just precalculate the
cached information about equivalent key sequences.
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))))
(t/defalias
^{:doc "A type that can be used to create a sequence of member type x
with count greater than 0."
:forms '[(NonEmptySeqable x)]}
t/NonEmptySeqable
(t/TFn [[x :variance :covariant]]
(t/I (t/Seqable x)
t/NonEmptyCount)))
(t/defalias
^{:doc "A type that can be used to create a sequence of member type x
with count 0."
:forms '[(EmptySeqable x)]}
t/EmptySeqable
(t/TFn [[x :variance :covariant]]
(t/I (t/Seqable x)
t/EmptyCount)))
(t/defalias
^{:doc "A persistent sequence of member type x."
:forms '[(Seq x)]}
t/Seq
(t/TFn [[x :variance :covariant]]
#?(:clj (clojure.lang.ISeq x)
:cljs (t/I (cljs.core/ISeq x)
cljs.core/IWithMeta
cljs.core/IMeta
(t/Seqable x)
(cljs.core/IIterable x)
;(cljs.core/INext x)
cljs.core/ICollection
cljs.core/IEmptyableCollection
cljs.core/ISequential
cljs.core/IEquiv))))
(t/defalias
^{:doc "A persistent sequence of member type x with count greater than 0."
:forms '[(NonEmptySeq x)]}
t/NonEmptySeq
(t/TFn [[x :variance :covariant]]
(t/I (t/Seq x)
t/NonEmptyCount)))
(t/defalias
^{:doc "A persistent sequence of member type x with count greater than 0, or nil."
:forms '[(NilableNonEmptySeq x)]}
t/NilableNonEmptySeq
(t/TFn [[x :variance :covariant]]
(t/Nilable
(t/NonEmptySeq x))))
(t/defalias
^{:doc "A persistent sequence with count greater than 0, or nil."
:forms '[AnyNilableNonEmptySeq]}
t/AnyNilableNonEmptySeq
(t/NilableNonEmptySeq t/Any))
(t/defalias
^{:doc "A sequential collection."
:forms '[Sequential]}
t/Sequential
#?(:clj clojure.lang.Sequential
:cljs cljs.core/ISequential))
(t/defalias
^{:doc "A sequential, seqable collection. Seq's aren't always Sequential."
:forms '[(SequentialSeqable x)]}
t/SequentialSeqable
(t/TFn [[x :variance :covariant]]
(t/I t/Sequential
(t/Seqable x))))
(t/defalias
^{:doc "A sequential, seqable Clojure collection."
:forms '[(SequentialColl x)]}
t/SequentialColl
(t/TFn [[x :variance :covariant]]
(t/I t/Sequential
(t/Coll x))))
(t/defalias
^{:doc "A Clojure sequential sequence. Seq's aren't always Sequential."
:forms '[(SequentialSeq x)]}
t/SequentialSeq
(t/TFn [[x :variance :covariant]]
(t/I t/Sequential
(t/Seq x))))
(t/defalias
^{:doc "A sequential seq returned from clojure.core/seq"
:forms '[(ASeq x)]}
t/ASeq
(t/TFn [[x :variance :covariant]]
(t/I (t/SequentialSeq x)
#?@(:clj [(Iterable x)
(java.util.Collection x)
(java.util.List x)
clojure.lang.IObj]))))
(t/defalias
^{:doc "A sequential non-empty seq retured from clojure.core/seq"
:forms '[(NonEmptyASeq x)]}
t/NonEmptyASeq
(t/TFn [[x :variance :covariant]]
(t/I (t/ASeq x)
t/NonEmptyCount)))
cc/associative? (t/Pred (t/Associative t/Any t/Any))
cc/coll? (t/Pred (t/Coll t/Any))
;TODO should these be parameterized?
cc/sequential? (t/Pred t/Sequential)
cc/sorted? (t/Pred (t/Sorted t/Any))
cc/meta [t/Any :-> (t/Nilable (t/Map t/Any t/Any))]
;; FIXME IObj annotations are a hack. doesn't literally return the same reference.
cc/with-meta (t/All [[x :< #?(:clj clojure.lang.IObj
:cljs cljs.core/IWithMeta)]]
[x (t/Nilable (t/Map t/Any t/Any)) :-> x])
cc/vary-meta (t/All [[x :< #?(:clj clojure.lang.IObj
:cljs cljs.core/IWithMeta)] b :..]
[x [(t/Nilable (t/Map t/Any t/Any)) b :.. b :-> (t/Nilable (t/Map t/Any t/Any))] b :.. b :-> x])
cc/map-indexed (t/All [x y] (t/IFn [[t/Int x :-> y] :-> (t/Transducer x y)]
[[t/Int x :-> y] (t/Seqable x) :-> (t/ASeq y)]))
cc/keep-indexed (t/All [a c] (t/IFn [[t/Int a :-> (t/U nil c)] :-> (t/Transducer a c)]
[[t/Int a :-> (t/U nil c)] (t/Seqable a) :-> (t/Seq c)]))
cc/bounded-count [(t/U t/Counted t/AnySeqable) :-> t/Int]
cc/keep (t/All [a b] (t/IFn [[a :-> (t/Option b)] :-> (t/Transducer a b)]
[[a :-> (t/Option b)] (t/Seqable a) :-> (t/ASeq b)]))
cc/dedupe (t/All [x] (t/IFn [:-> (t/Transducer x x)]
[(t/Seqable x) :-> (t/ASeq x)]))
cc/random-sample (t/All [x] (t/IFn [t/Num :-> (t/Transducer x x)]
[t/Num (t/Seqable x) :-> (t/ASeq x)]))
cc/halt-when (t/All [x] (t/IFn [[x :-> t/Any]
;; TODO opens a can of worms. requires knowledge of transduction context.
;; overrides final value of `into`, while doing nothing in `sequence`.
;(t/Option [t/Any v :-> t/Any]) :?
:-> (t/Transducer x x)]
))
cc/sequence (t/All [a b] (t/IFn [(t/Seqable a) :-> (t/ASeq a)]
;;TODO rest arity
[(t/Transducer a b) (t/Seqable a) :-> (t/ASeq b)]))
cc/find (t/All [x y]
(t/IFn [nil t/Any :-> nil]
[(t/Nilable (t/Associative x y)) t/Any :-> (t/Nilable (t/AMapEntry x y))]
;#?(:clj [(t/Nilable (t/U (t/Associative t/Any t/Any) java.util.Map)) t/Any :-> (t/Nilable (java.util.Map$Entry t/Any t/Any))])
;;TODO TransientAssociative2
))