Skip to content

Commit

Permalink
Refactor intersperce
Browse files Browse the repository at this point in the history
  • Loading branch information
petlyh committed Sep 24, 2024
1 parent 36496c5 commit d6b8e1c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/packages/list_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import "package:collection/collection.dart";

extension ListExtensions on List<dynamic> {
List<T> intersperce<T>(T item) => List<T>.from(this)
.map((element) => [item, element])
.mapIndexed((index, element) => [if (index != 0) item, element])
.flattened
.toList()
.sublist(1);
.toList();

List<T> deduplicate<T>() => toSet().toList() as List<T>;

Expand Down

0 comments on commit d6b8e1c

Please sign in to comment.