SudokuSchemas
Creates a SudokuSchemas using a SudokuSchemas.Builder with a DSL-style configuration.
This function provides a convenient way to construct a SudokuSchemas by configuring it using a lambda with receiver that operates on the SudokuSchemas.Builder. The builder pattern allows for flexible and readable configuration of the schemas included in the set.
Example:
val schemaSet = sudokuSchemas {
// Add individual schemas to the set
add(SudokuSchema(
puzzle = SudokuString("A1B2..."),
solution = SudokuString("1A2B..."),
difficulty = Difficulty.MEDIUM,
sudokuType = SudokuType.Sudoku4x4
))
// Add multiple schemas at once
add(
SudokuSchema(
puzzle = SudokuString("B1C2..."),
solution = SudokuString("2B3C..."),
difficulty = Difficulty.HARD,
sudokuType = SudokuType.Sudoku4x4
),
SudokuSchema(
puzzle = SudokuString("C1D2..."),
solution = SudokuString("3C4D..."),
difficulty = Difficulty.EASY,
sudokuType = SudokuType.Sudoku4x4
)
)
// Add a list of schemas
addAll(
listOf(
SudokuSchema(
puzzle = SudokuString("D1E2..."),
solution = SudokuString("4D5E..."),
difficulty = Difficulty.EASY,
sudokuType = SudokuType.Sudoku4x4
),
SudokuSchema(
puzzle = SudokuString("E1F2..."),
solution = SudokuString("5E6F..."),
difficulty = Difficulty.MEDIUM,
sudokuType = SudokuType.Sudoku4x4
)
)
)
}
Return
A SudokuSchemas containing the schemas configured in the builder.
Parameters
A lambda with receiver of type SudokuSchemas.Builder used to configure the schemas.
See also
Updates an existing SudokuSchemas using a SudokuSchemas.Builder configured with a DSL-style lambda.
This function converts the existing SudokuSchemas into a SudokuSchemas.Builder object, applies the provided lambda to configure the builder, and then builds a new SudokuSchemas with the updated schemas.
Example:
val existingSet = SudokuSchemas(
listOf(
SudokuSchema(
puzzle = SudokuString("A1B2..."),
solution = SudokuString("1A2B..."),
difficulty = Difficulty.MEDIUM,
sudokuType = SudokuType.Sudoku4x4
)
)
)
// Update the existing set with a new schema
val updatedSet = sudokuSchemas(existingSet) {
add(SudokuSchema(
puzzle = SudokuString("B1C2..."),
solution = SudokuString("2B3C..."),
difficulty = Difficulty.HARD,
sudokuType = SudokuType.Sudoku4x4
))
}
Return
A new SudokuSchemas built from the updated configurations.
Parameters
The existing SudokuSchemas to be updated.
A lambda function that configures the SudokuSchemas.Builder with new schemas or modifications.