Python scala functional
Mapping Python's functional tools to idiomatic Scala equivalents, including lambdas and collection methods.From its SKILL.md
npx -y skills add cxcscmu/SkillLearnBench --skill python-scala-functionalAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
1.2 KB, 315 tokens by cl100k_base, as published. Nobody here has run it
Python to Scala Functional Programming
This skill focuses on functional patterns and collection transformations.
Lambdas and Functions
- Python:
lambda x: x * 2 - Scala:
(x: Int) => x * 2or_ * 2(placeholder syntax).
Collection Operations
| Operation | Python | Scala |
|---|---|---|
| Map | map(f, items) | items.map(f) |
| Filter | filter(p, items) | items.filter(p) |
| Reduce | functools.reduce(f, items) | items.reduce(f) |
| For-each | for x in items: do(x) | items.foreach(do) |
| Zip | zip(a, b) | a.zip(b) |
| Sort | sorted(items, key=...) | items.sortBy(...) |
Lazy Sequences
- Python: Generators (
yield) andIterator. - Scala:
LazyList,Iterator, orView.
Higher-Order Functions
Scala supports HOFs natively.
def applyFunc(f: Int => String, x: Int): String = f(x)
Pattern Matching (Instance Checks)
Instead of isinstance, use match for clean type dispatch.
value match {
case s: String => "string"
case i: Int => "int"
case _ => "unknown"
}
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.