mark-naylor-1701

Create persistent queue

Jan 23rd, 2026 (edited)
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;; I found having to explicitly use clojure.lang.PersistentQueue/EMPTY ugly and
  2. ;; takes up too much real estate in a Clojure source file. I wrote this to
  3. ;; emulate the core `list' and `vector' functions.
  4.  
  5. (defn- queue
  6.   "For any number of parameters, create a persistent queue."
  7.   ([]
  8.    clojure.lang.PersistentQueue/EMPTY)
  9.   ([x]
  10.    (conj clojure.lang.PersistentQueue/EMPTY x))
  11.   ([x & xs]
  12.    (into clojure.lang.PersistentQueue/EMPTY (cons x xs))))
  13.  
Advertisement
Add Comment
Please, Sign In to add comment