Empty list, a seq type.

This namespace defines a type for object which extends IPersistentList and has no items. CLJ format defines syntax for empty list literal, ().

Note that persistent lists are a type of LIFO collections. They are seqs, are counted and support pop. Calling pop on empty list will however result in an exception being thrown.

Except for very special cases, it is idiomatic to use nil rather than empty-list.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(ns foo.bar
  (:api dunaj)
  (:require [dunaj.coll.empty-list :refer [empty-list]]))

;; prefer using nil to empty-list, and prefer using () to empty list

(conj nil 1 2)
;;=> (2 1)

(conj () 1 2) ;; less idiomatic
;;=> (2 1)

(conj empty-list 1 2) ;; even less idiomatic
;;=> (2 1)

;; but empty-list has its valid applications
(def x (chan 10))
(>!! x empty-list) ;; for cases where we have to pass a list, as channels don't accept nils

empty-list

Available since version 1.0 (view source)

not referred automatically

VAR of type EmptyList

An empty list. Same as (). Note that if is often more idiomatic to use nil instead of (any form of) empty list or collection.