Back
pop (clj)
(source)function
(pop coll)
For a list or queue, returns a new list/queue without the first
item, for a vector, returns a new vector without the last item. If
the collection is empty, throws an exception. Note - not the same
as next/butlast.
Examples
hoplon/hoplon
(ns hoplon.binding
(:refer-clojure :exclude [binding bound-fn])
(:require [clojure.core :as clj]
[cljs.analyzer :as a]))
(defmacro binding
"See clojure.core/binding."
[bindings & body]
(let [env (assoc &env :ns (a/get-namespace a/*cljs-ns*))
value-exprs (take-nth 2 (rest bindings))
bind-syms (map #(:name (a/resolve-existing-var env %)) (take-nth 2 bindings))
bind-syms' (map (partial list 'quote) bind-syms)
set-syms (repeatedly (count bind-syms) gensym)
setfn (fn [x y]
{:push! `(fn []
(let [z# ~x]
(set! ~x ~y)
(fn [] (set! ~x z#))))})
thunkmaps (map setfn bind-syms set-syms)]
(a/confirm-bindings env bind-syms)
`(let [~@(interleave set-syms value-exprs)]
(hoplon.binding/push-thread-bindings ~(zipmap bind-syms' thunkmaps))
(try ~@body (finally (hoplon.binding/pop-thread-bindings))))))
hraberg/deuce
(ns deuce.emacs.menu
(:use [deuce.emacs-lisp :only (defun defvar)])
(:require [clojure.core :as c])
(:refer-clojure :exclude []))
(defun x-popup-menu (position menu)
"Pop up a deck-of-cards menu and return user's selection.
POSITION is a position specification. This is either a mouse button event
or a list ((XOFFSET YOFFSET) WINDOW)
where XOFFSET and YOFFSET are positions in pixels from the top left
corner of WINDOW. (WINDOW may be a window or a frame object.)
This controls the position of the top left of the menu as a whole.
If POSITION is t, it means to use the current mouse position.
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 the user gets rid of the menu without making a valid choice, for
instance by clicking the mouse away from a valid choice or by typing
keyboard input, then this normally results in a quit and
`x-popup-menu' does not return. But if POSITION is a mouse button
event (indicating that the user invoked the menu with the mouse) then
no quit occurs and `x-popup-menu' returns nil."
)
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 (do
(t/ann-protocol cljs.core/Fn)
(t/ann-protocol cljs.core/IFn)
(t/ann-protocol cljs.core/ICloneable
-clone [cljs.core/ICloneable :-> t/Any])
(t/ann-protocol [[x :variance :covariant]]
cljs.core/IIterable
;; TODO
-iterator [(cljs.core/IIterable x) :-> t/Any #_Object])
(t/ann-protocol cljs.core/ICounted
-count [cljs.core/ICounted :-> t/Num])
(t/ann-protocol cljs.core/IEmptyableCollection
;; :/ TFn param on protocol?
-empty [cljs.core/IEmptyableCollection :-> t/Any])
(t/ann-protocol cljs.core/ICollection
-conj [cljs.core/ICollection t/Any :-> cljs.core/ICollection])
(t/ann-protocol [[x :variance :covariant]] cljs.core/IIndexed
-nth (t/All [y]
[(cljs.core/IIndexed x) t/JSnumber (t/? y) :-> (t/U x y)]))
(t/ann-protocol cljs.core/ASeq)
(t/ann-protocol [[x :variance :covariant
;;FIXME causes mystery error
;:< t/AnyNilableNonEmptySeq
]]
cljs.core/ISeqable)
(t/ann-protocol [[x :variance :covariant]] cljs.core/ISeq
-first [(cljs.core/ISeq x) :-> (t/Nilable x)]
-rest [(cljs.core/ISeq x) :-> (cljs.core/ISeq x)])
;cljs.core/INext [[x :variance :covariant]]
(t/ann-protocol [[v :variance :covariant]] cljs.core/ILookup)
(t/ann-protocol [[k :variance :covariant]
[v :variance :covariant]]
cljs.core/IAssociative
-contains-key [(cljs.core/IAssociative k v) t/Any :-> t/Bool]
-assoc (t/All [k1 v1] [(cljs.core/IAssociative k v) k1 v1 :->
(cljs.core/IAssociative (t/U k k1) (t/U v v1))]))
(t/ann-protocol cljs.core/IMap
-dissoc [cljs.core/IMap t/Any :-> cljs.core/IMap])
(t/ann-protocol [[k :variance :covariant]
[v :variance :covariant]]
cljs.core/IMapEntry
-key [(cljs.core/IMapEntry k v) :-> k]
-val [(cljs.core/IMapEntry k v) :-> v])
(t/ann-protocol cljs.core/ISet
-disjoin (t/All [s] [s t/Any :-> s]))
(t/ann-protocol [[x :variance :covariant]]
cljs.core/IStack
-peek [(cljs.core/IStack x) :-> (t/U nil x)]
-pop [(cljs.core/IStack x) :-> (cljs.core/IStack x)])
(t/ann-protocol [[x :variance :covariant]]
cljs.core/IVector
-assoc-n (t/All [x1] [(cljs.core/IVector x) t/Num x1
:-> (cljs.core/IVector (t/U x x1))]))
(t/ann-protocol [[x :variance :covariant]]
cljs.core/IDeref
-deref [(cljs.core/IDeref x) :-> x])
(t/ann-protocol [[x :variance :covariant]]
cljs.core/IDerefWithTimeout
-deref-with-timeout [(cljs.core/IDerefWithTimeout x) :-> x])
(t/ann-protocol cljs.core/IMeta
-meta [cljs.core/IMeta :-> (t/Nilable (t/Map t/Any t/Any))])
(t/ann-protocol cljs.core/IWithMeta
-with-meta [cljs.core/IWithMeta (t/Nilable (t/Map t/Any t/Any)) :-> cljs.core/IWithMeta])
;TODO
;cljs.core/IReduce [[]]
(t/ann-protocol cljs.core/IKVReduce ;;TODO
-kv-reduce [cljs.core/IKVReduce [t/Any t/Any t/Any :-> t/Any] :-> t/Any])
(t/ann-protocol cljs.core/IList)
(t/ann-protocol cljs.core/IEquiv
-equiv [cljs.core/IEquiv t/Any :-> t/Bool])
(t/ann-protocol cljs.core/IHash
-hash [cljs.core/IHash :-> t/Num])
(t/ann-protocol cljs.core/ISequential)
(t/ann-protocol cljs.core/IRecord)
(t/ann-protocol [[x :variance :covariant]]
cljs.core/IReversible
-rseq [(cljs.core/IReversible x) :-> (t/NilableNonEmptySeq x)])
(t/ann-protocol [[k :variance :covariant]
[v :variance :covariant]] cljs.core/IFind
-find [(cljs.core/IFind k v) t/Any :-> (t/Nilable (cljs.core/IMapEntry k v))]
)
(t/ann-protocol [[x :variance :invariant]]
cljs.core/ISorted
-sorted-seq [(cljs.core/ISorted x) t/Bool :-> (t/Nilable (t/ASeq x))]
;; second arg => comparable?
-sorted-seq-from [(cljs.core/ISorted x) t/Any t/Bool :-> (t/Nilable (t/ASeq x))]
-entry-key [(cljs.core/ISorted x) t/Any :-> t/Any]
-comparator [(cljs.core/ISorted x) :-> [x x :-> t/Num]])
(t/ann-protocol cljs.core/IPending)
;cljs.core/IWriter [[]]
;cljs.core/IPrintWithWriter [[]]
; ;TODO
;;cljs.core/IWatchable [[]]
; ;cljs.core/IEditableCollection [[]]
; ;cljs.core/ITransientCollection [[]]
; ;cljs.core/ITransientAssociative [[]]
; ;cljs.core/ITransientMap [[]]
; ;cljs.core/ITransientVector [[]]
; ;cljs.core/ITransientSet [[]]
(t/ann-protocol [[x :variance :invariant]]
cljs.core/IComparable)
; ;cljs.core/IChunk [[]]
; ;cljs.core/IChunkedSeq [[]]
; ;cljs.core/IChunkedNext [[]]
(t/ann-protocol cljs.core/INamed
-named [cljs.core/INamed :-> t/Str]
-namespace [cljs.core/INamed :-> (t/Nilable t/Str)])
(t/ann-protocol [[x :variance :invariant]]
cljs.core/IVolatile
-vreset! (t/All [x] [(cljs.core/IVolatile x) x :-> x]))
#?@(:cljs [] :default [
cc/pop-thread-bindings [:-> t/Any]
cc/load [t/Str :* :-> t/Any]
cc/read-string [t/Str :-> t/Any]
cc/read [(t/alt (t/cat (t/? java.io.Reader))
(t/cat java.io.Reader t/Bool)
(t/cat java.io.Reader t/Bool t/Any (t/? t/Bool)))
:-> t/Any]
cc/read+string [(t/alt (t/cat (t/? java.io.Reader))
(t/cat java.io.Reader t/Bool)
(t/cat java.io.Reader t/Bool t/Any (t/? t/Bool)))
:-> '[t/Any t/Str]]
cc/read-line [:-> (t/U nil t/Str)]
cc/add-classpath [(t/U t/Str java.net.URL) :-> nil]
])
cc/peek (t/All [x] (t/IFn [(t/I t/NonEmptyCount (t/Stack x)) :-> x]
[(t/Stack x) :-> (t/Nilable x)]))
;;TODO assert non-empty arg
cc/pop (t/All [x] (t/IFn [(t/List x) :-> (t/List x)]
[(t/Vec x) :-> (t/Vec x)]
[(t/Stack x) :-> (t/Stack x)]))