Linked list, a sequential LIFO seq type.

This namespace defines a type for object which extends IPersistentList that has at least one item. CLJ format defines syntax for empty list literal, (x y z), but as this syntax is used for function invocation, idiomatic way is to use →lst and lst constructor functions.

Note that persistent lists are a type of LIFO collections. They are seqs, are counted and support pop. Empty list is represented by the special type defined in dunaj.coll.empty-list namespace.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
(->lst 1 2 3 4 5)
;;=> (1 2 3 4 5)

(lst [1 2 3 4 5])
;;=> (1 2 3 4 5)

;; peek returns the front (first) item
(peek (->lst 1 2 3 4 5))
;;=> 1

;; pop removes front (first) item
(pop (->lst 1 2 3 4 5))
;;=> (2 3 4 5)

;; conj inserts into the front
(conj (->lst 1 2 3 4 5) :foo)
;;=> (:foo 1 2 3 4 5)

linked-list-factory

Available since version 1.0 (view source)

not referred automatically

VAR of type ICollectionFactory

A Linked List factory instance. Currently there are no options.

This factory implements ICollectionFactory factory protocol.

New instances of Linked List can be created with collection and ->collection.

1
2
3
4
5
6
7
8
9
10
(ns foo.bar
  (:api dunaj)
  (:require [dunaj.coll :refer [->collection collection]]
            [dunaj.coll.linked-list :refer [linked-list-factory]]))

(->collection linked-list-factory 1 2 3 4 5)
;;=> (1 2 3 4 5)

(collection linked-list-factory [1 2 3 4 5])
;;=> (1 2 3 4 5)