How can I use the Cljs.core.PersistentQueue Clojurescript queue?

I can't seem to find any Cjjuscript documentation on cljs.core.PersistentQueue. Should I use it at all? Or should I use a different Clojurescript queue creation method?

Update

At the same time I use channels, (<!, (>! And go blocks, and this seems to do the trick

+6
source share
2 answers

A PersistentQueue is another persistent data structure with different behaviors and performance characteristics compared to a list, vector, map, and set. If you look at the docstrings for pop and peek , for example, you will see that this data type is referred to as a “queue”.

Since it does not have a syntax literal, you need to start empty with cljs.core.PersistentQueue/EMPTY .

This post provides a good summit summary of the equivalent of Clojure fooobar.com/questions/12464 / ...

+8
source

ClojureScript actually has a tagged literal #queue [] for creating queues, which I found after Mike answered repl

 cljs.user=> cljs.core/PersistentQueue.EMPTY #queue [] cljs.user=> #queue [] #queue [] cljs.user=> (def q #queue [1 2 3]) #queue [1 2 3] cljs.user=> (conj q 4) #queue [1 2 3 4] cljs.user=> (pop q) #queue [2 3] cljs.user=> (peek q) 1 
+11
source

Source: https://habr.com/ru/post/979634/


All Articles