RSSAmplifier

Blog

personal web site of janos erdos

Personal web space.

erdos.devRSS feed ↗8 posts

Latest posts

Vega-Lite charts with Clojure and GraalJs

Vega-Lite charts with Clojure and GraalJS For a recent side project I needed a charting tool I could operate on the server-side. I initially used gnuplot which was really nice but had some limitations (for example, making plots clickable) and found the DSL somewhat complex. Then I discovered Vega and Vega-Lite and I really liked the elegant style and flexibility. But since these libraries are…

Faster tree-seq in Clojure with transducers

Faster tree-seq in Clojure with transducers The tree-seq is one of my favourite functions in Clojure. It can be used to lazily iterate in any tree-like data structure in a depth-first order. The definition of the function goes something like this: ( defn tree-seq [ branch? children root ] (( fn walk [ node ] ( lazy-seq ( cons node ( when ( branch? node ) ( mapcat walk ( children node )))))) root…

Reading List for 2019 December

Reading List for 2019 December Advanced Design and Implementation of Virtual Machines JVM Garbage Collectors Benchmarks Report 19.12 Essentials of Garbage Collectors Modern garbage collection Modern garbage collection: Part 2 Garbage Collection

Clojure - testing private vars

How do we test private vars in Clojure? How do we write unit tests for private vars? 1. Namespace for implementation One approach is just not to use private vars. Private vars are hidden, because they are part of the implementation of a functionality. As such, they are not part of the public API of the software, and should not be accessed from the outside world. You could introduce a new namespace…

Clojure collection quirks - A REFERENCE

This is a reference of Clojure’s default data structures and the most common predicates. Functions This table contains the most common predicates applied to the core collections. Seq Vector Map Set nil '(1 2 3) (range 5) (range) (lazy-seq) (cons 1 ()) Persistent Queue/EMPTY [1 2 3] (last {1 1}) (hash-map) (array-map) (sorted-map) #{} (sorted-set) type nil Persistent List LongRange Iterate or…

Clojure collection quirks - Maps

Maps Map data structures in Clojure are much like associative arrays in other languages. The abstraction is very handy and easy to use. Creation You can create maps with two syntaxes. Either by calling the hash-map function or by writing the {} map literal. ( def m1 { :one :a, :two :b, :three :c, :four :d }) One interesting fact when working with maps is that all maps with 8 or less entries maps…

Clojure collection quirks - Vectors

Working with Clojure collections is a pleasure. Yet, sometimes one may run into unexpected behaviors. In this series, we take a look at the most simple Clojure data structures. Vectors Vectors are sequential collections with constant time random access capability. One can also view vectors as integer to element mappings. Examples: ( def v1 [ :zero :one :two :three ]) ( get v1 1 ) => :one ( find v1…

Indexed data structures in Clojure

When rumbling in the Java source codes of the Clojure language, I found the mysterious IndexedSeq interface. What is it good for? Details It provides the int index() method for collections to return the current index of the sequence on them. It extends ISeq , Sequential , Counted interfaces and thus IPersistentCollection and Seqable too. Usage One can easily create a wrapper class that gives an…