Skip to content

Commit 11f6dcf

Browse files
feat(list.invert()): add function to invert elements.
1 parent 9a121bb commit 11f6dcf

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

list/_index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
@forward 'list.has.function';
2222
@forward 'list.index.function';
2323
@forward 'list.insert-nth.function';
24+
@forward 'list.invert.function';
2425
@forward 'list.join.function';
2526
@forward 'list.last.function';
2627
@forward 'list.limit.function';

list/_list.invert.function.scss

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Sass.
2+
@use 'sass:list';
3+
4+
// Status: DONE
5+
// The `list.invert()` function invert `$list` elements.
6+
// @param `$list` The list to invert elements.
7+
// @returns The returned value is a copy of `$list` with inverted elements.
8+
@function invert($list) {
9+
$inverted: ();
10+
@for $i from list.length($list) through 1 {
11+
$inverted: list.append($inverted, list.nth($list, $i), list.separator($list));
12+
}
13+
@return $inverted;
14+
}
15+
16+
// Examples.
17+
// $-list: ('a', 'b', c, d, 2, 4, 5, (a: 1));
18+
19+
// @debug invert($-list);

0 commit comments

Comments
 (0)