/**
 * stolen from https://github.com/seven-phases-max/less.curious
 */

/**
 * .for()
 */
.for(@i, @n) {
    .-each(@i);
}

.for(@n) when (isnumber(@n)) {
    .for(1, @n);
}

.for(@i, @n) when not (@i = @n)  {
    .for((@i + (@n - @i) / abs(@n - @i)), @n);
}

/**
 * .for-each()
 */
.for(@array) when (default()) {
    .for-impl_(length(@array));
}

.for-impl_(@i) when (@i > 1) {
    .for-impl_((@i - 1));
}

.for-impl_(@i) when (@i > 0) {
    .-each(extract(@array, @i));
}
