Violin is a utility library for Kotlin.
It tries to be human-sized, i.e., small enough that its code can be quickly understood without significant time investment. Hence, it focuses on a few orthogonal features and good documentation.
Violin's main attraction is its stream capabilities.
Streams are best described as iterators, but on which transformations (map
,
filter
, ...) can be applied lazily. Usually the same transformations are
applied eagerly on the stream's source (e.g. kotlin.List
) or lazily on the
source (e.g. kotlin.Sequence
). Violin streams are close to Java streams, but
(1) allow incremental (not all-at-once) consumption from the stream, and (2) do
not complect parallelization with stream processing.
Here is a completely bogus example (you're encouraged to submit a better one!):
1.transitive { it + 1 }
.dropWhile { it < 10 }
.upTo { it > 20 }
.filter { it % 2 == 0 }
.map { it / 2 }
.indexed()
.joinToString(transform = { "${it.index}: ${it.value}" })
.let { println(it) } // prints "0: 5, 1: 6, 2: 7, 3: 8, 4: 9, 5: 10"
The stream interface is dead simple:
interface Stream <out T: Any> {
fun stream(): T?
}
-
A flexible singly linked list implementation.
-
Conversions between functions with and without receivers, over pairs or multiple parameters.
-
A stack interface.
Download the latest release and be include it in your classpath.
curl -T https://github.com/norswap/violin/releases/download/0.0.1/violin-0.0.1.jar
<dependency>
<groupId>com.norswap</groupId>
<artifactId>violin</artifactId>
<version>0.0.1</version>
</dependency>
compile 'com.norswap:violin:0.0.1'
You need make
, curl
and a JDK (8+).
You also need the CLI Kotlin compiler (1.0.3 - superior should be compatible).
If you don't have it, run make kotlin
to install the 1.0.3 compiler locally
before continuing.
make deps
make build
make buildTests
make test
make jar
More targets (docs
, clean
, ...) available in the makefile.
- Implement fast hashtable using Robin Hood Hashing.
- Implement a fast immutable map using optimized hash-array map tries.