Tree with string concatenation - Henrik-Peters/Multi-Level-Segment-Tree GitHub Wiki
Segment tree example for the string concatenation to produce substrings:
object StringConcatenation extends Monoid[String] {
def fold(a: String, b: String): String = a concat b
def identity: String = ""
}
val data = List("H", "e", "l", "l", "o")
val tree: SegmentTree[String] = SegmentTree.fromSequence(data, StringConcatenation)
tree.dumpTree("substringtree-example")
This snippet will produce this dump (legend was added for better readability):