kotlin-collections-advanced

Applies Kotlin collection operators and sequences to analyze journal entry data.

Updated May 9, 2026
One-click install
npx skills add https://github.com/Bumh3rr/solvyx-app --skill kotlin-collections-advanced-bumh3rr
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: kotlin-collections-advanced
Source: https://github.com/Bumh3rr/solvyx-app/tree/main/.opencode/skill/kotlin-collections-advanced
Command: npx skills add https://github.com/Bumh3rr/solvyx-app --skill kotlin-collections-advanced-bumh3rr

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Processing large lists of journal entries in Kotlin often leads to inefficient manual loops, intermediate list allocations, and slow pipelines. This Skill provides proven patterns for grouping, filtering, windowing, and reducing collections so data analysis code stays readable and performant. ## Core Features & Use Cases - Grouping and Partitioning: Use groupBy, groupingBy, partition, chunked, and windowed to aggregate entries by day, mood, or sliding time windows. - Lazy Sequence Pipelines: Convert long filter-map-reduce chains over large datasets (>10k elements) into lazy Sequences that avoid intermediate list materialization. - Reductions and Set Operations: Apply sumOf, fold, sortedWith, distinctBy, intersect, union, and flatMap for frequency counts, top-N rankings, and per-category sums. - Use Case: Compute the average sleep hours per mood over the last 7 days from a journal entry list using a single lazy Sequence pipeline with mapNotNull and average. ## Quick Start Apply the Kotlin collections skill to rewrite this journal analysis loop using groupBy and a lazy Sequence pipeline.

Frequently Asked Questions about kotlin-collections-advanced

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I group a Kotlin list by a property?▼

Use groupBy with a key selector, such as entries.groupBy { it.animo }, which returns a Map of keys to lists in O(n) time. For counts only, use groupingBy with eachCount to avoid building intermediate lists.

When should I use Sequence instead of List in Kotlin?▼

Use Sequence when the dataset exceeds roughly 10k elements and the pipeline chains more than three operations. Sequences evaluate lazily without materializing intermediate lists, while List is fine for short pipelines on small collections.

What is the difference between chunked and windowed in Kotlin?▼

chunked splits a list into non-overlapping blocks of a fixed size, useful for weekly averages. windowed creates sliding windows with a configurable step, so consecutive windows can overlap, which suits moving-average style analysis.

Does Kotlin average() work on an empty list?▼

No, calling average() on an empty list returns NaN. Guard against this by checking isNotEmpty first, for example with takeIf { it.isNotEmpty() }?.average(), and prefer maxByOrNull over maxBy to avoid exceptions.

How do I get the top N most frequent values in a Kotlin list?▼

Chain groupingBy with eachCount to build a frequency map, then sort entries descending by value and take N. For example: entries.groupingBy { it.animo }.eachCount().entries.sortedByDescending { it.value }.take(3).