Add sample for text version of chunked
This commit is contained in:
committed by
Ilya Gorbunov
parent
3f9892a49d
commit
e8ee405cdb
@@ -1456,7 +1456,7 @@ public inline fun CharSequence.sumByDouble(selector: (Char) -> Double): Double {
|
|||||||
*
|
*
|
||||||
* @param size the number of elements to take in each string, must be positive and can be greater than the number of elements in this char sequence.
|
* @param size the number of elements to take in each string, must be positive and can be greater than the number of elements in this char sequence.
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Collections.Transformations.chunked
|
* @sample samples.text.Strings.chunked
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun CharSequence.chunked(size: Int): List<String> {
|
public fun CharSequence.chunked(size: Int): List<String> {
|
||||||
|
|||||||
@@ -49,6 +49,15 @@ class Strings {
|
|||||||
assertPrints(withoutMargin2, "XYZ\nfoo\nbar")
|
assertPrints(withoutMargin2, "XYZ\nfoo\nbar")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Sample
|
||||||
|
fun chunked() {
|
||||||
|
val dnaFragment = "ATTCGCGGCCGCCAA"
|
||||||
|
|
||||||
|
val codons = dnaFragment.chunked(3)
|
||||||
|
|
||||||
|
assertPrints(codons, "[ATT, CGC, GGC, CGC, CAA]")
|
||||||
|
}
|
||||||
|
|
||||||
@Sample
|
@Sample
|
||||||
fun chunkedTransform() {
|
fun chunkedTransform() {
|
||||||
val codonTable = mapOf("ATT" to "Isoleucine", "CAA" to "Glutamine", "CGC" to "Arginine", "GGC" to "Glycine")
|
val codonTable = mapOf("ATT" to "Isoleucine", "CAA" to "Glutamine", "CGC" to "Arginine", "GGC" to "Glycine")
|
||||||
|
|||||||
@@ -868,7 +868,8 @@ object Generators : TemplateGroupBase() {
|
|||||||
@param size the number of elements to take in each ${f.snapshotResult}, must be positive and can be greater than the number of elements in this ${f.collection}.
|
@param size the number of elements to take in each ${f.snapshotResult}, must be positive and can be greater than the number of elements in this ${f.collection}.
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
sample("samples.collections.Collections.Transformations.chunked")
|
specialFor(Iterables, Sequences) { sample("samples.collections.Collections.Transformations.chunked") }
|
||||||
|
specialFor(CharSequences) { sample("samples.text.Strings.chunked") }
|
||||||
specialFor(Iterables) { returns("List<List<T>>") }
|
specialFor(Iterables) { returns("List<List<T>>") }
|
||||||
specialFor(Sequences) { returns("Sequence<List<T>>") }
|
specialFor(Sequences) { returns("Sequence<List<T>>") }
|
||||||
specialFor(CharSequences) { returns("List<String>") }
|
specialFor(CharSequences) { returns("List<String>") }
|
||||||
|
|||||||
Reference in New Issue
Block a user