Spread Functionality Added to the Rel Standard Library

Posted October 8, 2021 by Huda Nassar ‐ 1 min read

Now supporting a spread functionality with two strategies: even spread and ratio spread.

We are excited to announce that we now support a spread functionality implemented natively in Rel. We support two main strategies: even and ratio.


For the even strategy, we spread an equal number of units to all elements in a relation, and when we can no longer have equal amounts, we spread the remaining singletons in order starting with the first element in a lexicographic order.

def R = {"Flamingo"; "Cat"; "Dog"}

def output = spread[:even, R, 10]

Relation: output



For the ratio strategy, we spread a number proportional to the weight corresponding to each element in a relation (provided by the user). Remaining singletons are spread in order after the elements are sorted according to their weights.

def R = {("Flamingo", 1); ("Cat", 2); ("Dog", 3)}

def output = spread[:ratio, R, decimal[64, 2, 10.0]]

Relation: output


Notice, for decimal numbers the digit precision (here: 2) is preserved during the spread.