Skip to content

Commit

Permalink
Implement slices method
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Nov 22, 2024
1 parent a52a137 commit e603a28
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/core/gossamer-core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ extension [TextType: Textual](text: TextType)
def upto(ordinal: Ordinal): TextType = text.segment(Prim ~ ordinal)
def from(ordinal: Ordinal): TextType = text.segment(ordinal ~ Ult.of(text))

def slices(size: Int): List[TextType] =
val length = text.length
List.tabulate[TextType]((length - 1)/size + 1): i =>
text.segment(Ordinal.zerary(i*size) ~ Ordinal.natural(((i + 1)*size).min(length)))

def skip(count: Int, bidi: Bidi = Ltr): TextType = bidi match
case Ltr => text.segment(Ordinal.zerary(count) ~ Ult.of(text))
case Rtl => text.segment(Prim ~ Countback(count).of(text))
Expand Down
2 changes: 1 addition & 1 deletion src/core/soundness+gossamer-core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export gossamer.{Bidi, Buffer, Cuttable, Decimalizer, Interpolation, Joinable, N
snip, reverse, contains, trim, where, upto, dropWhile, snipWhere,
mapChars, count, metrics, pad, center, fit, uncamel, unkebab, unsnake, starts, ends,
tr, subscript, superscript, rsub, sub, flatMap, urlEncode, urlDecode, punycode, bytes,
sysBytes, lev, join, add, words, lines, appendln, spaced}
sysBytes, lev, join, add, words, lines, appendln, spaced, slices}

package decimalFormatters:
export gossamer.decimalFormatters.java
Expand Down

0 comments on commit e603a28

Please sign in to comment.