mapToSudokuString
Converts an Iterable of elements to a String representation using toJEncodedCell for mapping.
Example:
val sudokuBoard: Iterable<Iterable<Int>> = listOf(
listOf(1, 2, 3),
listOf(4, 5, 6),
listOf(7, 8, 9)
)
// Convert the sudokuBoard to a string using mapToSudokuString
val sudokuString: String = sudokuBoard.mapToSudokuString()
Content copied to clipboard
Receiver
The Iterable of elements to be converted.
Return
A string representation of the elements, with each element converted using toJEncodedCell.
See also
inline fun <T> Iterable<Iterable<T>>.mapToSudokuString(crossinline valueMapper: T.() -> Int): String
Converts an Iterable of elements to a String representation using toJEncodedCell for mapping.
Example:
data class Cell(val number: Int)
val board: Iterable<Iterable<Cell>> = listOf(
listOf(Cell(1), Cell(2), Cell(3)),
listOf(Cell(4), Cell(5), Cell(6)),
listOf(Cell(7), Cell(8), Cell(9))
)
// Convert the board to a string using mapToSudokuString with a custom valueMapper
val sudokuString: String = board.mapToSudokuString { number }
Content copied to clipboard
Receiver
The Iterable of elements to be converted.
Return
A string representation of the elements, with each element converted using toJEncodedCell.
Parameters
valueMapper
A function that maps each element of the list to an integer to be used in the string representation.