agentsclimarketplace

Run2 scala string processing

Skill cxcscmu/SkillLearnBench/skills/b2-self-feedback-claude-haiku-4-5/python-scala-translation/run2_scala-string-processing

String manipulation, formatting, and regex patterns in ScalaFrom its SKILL.md

Install
npx -y skills add cxcscmu/SkillLearnBench --skill run2_scala-string-processing

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

1.7 KB, 460 tokens by cl100k_base, as published. Nobody here has run it

String Processing in Scala

String Formatting

// f-string style (Scala 2.13+)
val value = 42
val formatted = f"Value: $value%d"

// String format (compatible)
String.format("%.2f", 3.14159)

// String interpolation
val name = "world"
s"Hello $name"  // simple interpolation
f"Pi: ${3.14159}%.2f"  // formatted interpolation

Numeric Precision

// For Double/Float
val d = 3.14159
String.format("%.2f", d)  // "3.14"

// For BigDecimal
val bd: BigDecimal = BigDecimal("3.14159")
String.format("%.2f", bd.doubleValue)

// Using precision variable
val precision = 4
String.format(s"%.${precision}f", value)

Working with Character Sets and Punctuation

// String to set of characters
val punctuation = ".,!?;:'\"()[]{}" .toSet

// Check if character is in set
if (punctuation.contains(c)) { ... }

// Strip leading/trailing punctuation
val stripped = word
  .dropWhile(punctuation.contains)
  .reverse
  .dropWhile(punctuation.contains)
  .reverse

// Or using regex
word.replaceAll("^[.,!?;:'\"]|[.,!?;:'\"']$", "")

Whitespace Splitting

// Split by whitespace
val words = "hello world test".split("\\s+").toVector

// Split with filter
text.split("\\s+").filter(_.nonEmpty)

// Preserve structure
val (first, rest) = words.splitAt(1)

String Validation

// Check if all digits
if (part.forall(_.isDigit)) { ... }

// Check emptiness
if (str.nonEmpty) { ... }
if (str.isEmpty) { ... }

// Check length
if (str.length < minLength) { ... }

Case Conversion

str.toLowerCase  // → "hello"
str.toUpperCase  // → "HELLO"

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.