add objects and object types

This commit is contained in:
Mark
2023-11-30 15:44:51 +01:00
parent 9c0d55788f
commit 3d1ce384d0
11 changed files with 421 additions and 11 deletions

View File

@@ -46,16 +46,20 @@ double := x -> {
// Define custom types:
// `[[MyType] TypeDefinition]`
[[City] (Int, Int, Int)]
[[City] {
population: Int
pos_x: Int
pos_y: Int
}]
get_coords := city -> [(Int, Int)] {
// only works with values of type City
(_, x, y) := [City] city
{ population: _, pos_x: x, pos_y: y } := [City] city
// return the coords
(x, y)
}
test_city := (56000, 127, -12)
test_city := { population: 56000, pos_x: 127, pos_y: -12 }
("Coords: ", test_city.get_coords).concat.println