// Sass.
@use 'sass:list';
// Functions.
@use 'list.nth.function' as *;
// Modules.
@use '../number';
// The `list.from()` function.
@function from($list, $from) {
$result: nth($list, number.range($from, list.length($list)) or $from...);
@return if(
$from <= list.length($list),
if(list.length($list) == $from, ($result,), $result),
null
);
}
The list from which the elements are picked.
// Use.
@use 'angular-package/sass/list';
// Examples.
@debug list.from((('a', 'b', 'c'),), 1); // (('a', 'b', 'c'),)
@debug list.from((('a', 'b', 'c'), 'a', 'b', c, d, 2, 4, 5, (a: 1)), 0); // ("a", "b", "c"), "a", "b", c, d, 2, 4, 5, (a: 1)
@debug list.from((('a', 'b', 'c'), 'a', 'b', c, d, 2, 4, 5, (a: 1)), -1); // (a: 1), ("a", "b", "c"), "a", "b", c, d, 2, 4, 5, (a: 1)
@debug list.from((('a', 'b', 'c'), 'a', 'b', c, d, 2, 4, 5, (a: 1)), 1); // ("a", "b", "c"), "a", "b", c, d, 2, 4, 5, (a: 1)
@debug list.from(('a', 'b', c, d, 2, 4, 5, (a: 1)), 4); // d, 2, 4, 5, (a: 1)
@debug list.from(('a', 'b', c, d, 2, 4, 5, (a: 1)), 7); // 5, (a: 1)
// negative index
@debug list.from((('a', 'b', 'c'), ), -3); // null, null, ("a", "b", "c"), ("a", "b", "c")