pyret-lang
pyret-lang copied to clipboard
The Pyret language.
Consider this program: ``` include tables type Key = String cities = table: code :: Key, name :: Key row: "PVD", "Providence" row: "EWR", "Newark" row: "SFO", "San Francisco" end...
``` import sets as S type Key = String cities = table: code :: Key, name :: Key row: "PVD", "Providence" row: "EWR", "Newark" row: "SFO", "San Francisco" end flights...
Consider the following code: ```python WIDTH = 3 fun in-bounds(x :: Number) -> Boolean: (0 {Number % (in-bounds); Number % (in-bounds)}: {x; y} end # type Coord = Number %...
This program runs fine without type-checking, but with it it produces an _internal error_ (as opposed to halting gracefully): ``` include reactors include chart data Pt1: pt1(x :: Number) end...
This program reliably produces an internal error on the second `print`: ``` import tables as T lst-in = [list: "a", "b", "c"] lst-freq = [list: 1, 1, 1] fake-table =...
Fairly certain the text from [this page](https://www.pyret.org/docs/latest/tables.html) swaps `2` and `3`: Also, I think it would be better if the text said "ascending" and "descending" instead of "increasing" and "decreasing",...
It came from entering `animals-table.build-column("is-dog",is-dog).filter(is-dog == true)` instead of `animals-table.build-column("is-dog",is-dog).filter(is-dog)`
When printing tables, numeric columns should be decimal-aligned. So for instance, in this table all the numbers would be right-aligned, but if there are decimals, that would further be taken...
Because numeric functions are `num-`, we have `num-to-string`. But string names are `string-`, so we have `string-to-number`. So if you look up the latter and write `string-to-number`, do whatever processing,...
Here's a full program: ``` fun sq(n :: Number): n * n end modulo-power :: Number, Number, Number -> Number fun modulo-power(base, exp, n): if exp == 0: 1 else:...