Repository navigation
v0.51.0
Highlights
Debug in the terminal. kscript --debug app.kscript (or kscript run --debug) runs a script in a terminal debugger. It pauses before the first statement, shows the lines around it, and reads commands: n step over (Enter repeats), s step into, o step out, c continue, p <expr> print, v variables, w call stack, b <line> / d <line> breakpoints, q quit and h help. --break 12 pauses at that line instead. Stepping and breakpoints behave the same as in VS Code.
Grids by rows and columns. A list of lists reads like a csv with ->cells(), and ->positions_of() finds where things are:
for column in $grid->cells(columns) {
echo $column->join('')
}
$trees = $field->grid()->positions_of('#') // every { row, column } holding a tree
Name each item of a pick. A function given to a pick from ->combinations() or ->permutations() can take one parameter per item:
$trees->combinations(2)->count_of(fn(left, right) => $left.row == $right.row)
Find shapes. ->shapes() finds squares, rectangles, lines and circles in a grid or a list of points, and shapes you draw yourself:
$grid->shapes(square, of: '#', rotated)->count() // level squares and diamonds
$grid->shapes(line, of: /[#@]/, size: 4)
$grid->shapes(circle, of: '~', radius: 3, distance: moves)
/// Three trees in a V, with anything between them.
type Fork {
layout: string = ```text
t~t
~t~
```
symbols: map = { t: /[#@]/, '~': null }
}
$grid->shapes(like: [Fork], rotated)
Each match is { kind, points }, and the editor completes their fields. A missing of: on a grid, or a layout character missing from symbols, is an error with a fix.
Breaking changes
--debugnow starts the terminal debugger. The old flag that shows the .NET stack trace is renamed to--stack-trace, andKSCRIPT_DEBUGtoKSCRIPT_STACK_TRACE.--debugon any other command is an error naming--stack-trace.->transpose()is retired in favour of->cells(columns). It is an error that names the replacement, with a quick fix. See docs/upgrading.md.
Run kscript update to get this release.
What's Changed
- Read a grid's rows and columns, find points in it, and name picked items by @kylepantall in #352
- Debug scripts in the terminal with kscript --debug; rename the stack-trace flag to --stack-trace by @kylepantall in #353
- Find shapes in grids and point lists, and masks of your own by @kylepantall in #354
Full Changelog: v0.50.0...v0.51.0