# Posts tagged by Justin Slepak

## Rank Polymorphism

::

Rank polymorphism gives you code reuse on arguments of different dimensions. Take a linear interpolation function (let’s just call it lerp) for scalars:

(λ ((lo 0) (hi 0) (α 0)) (+ (* lo (- 1 α)) (* hi α)))

The number marks on each argument indicate the expected “rank” of the argument: how many dimensions it should have. In this case, each one is marked 0, indicating a scalar (i.e., 0-dimensional) argument. The function is usable as-is for

• α-blending two RGB pixels

• dimming or brightening an image

• fade transition between video scenes