blob: 4913c2104621d9926d4bb36c327edd6b1495b47a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
module geometry
const (
module_name = 'geometry'
)
pub enum Shape {
circle
rectangle
triangle
}
pub type ShapeMap = map[Shape]string
// used by vlib/v/tests/map_enum_keys_test.v
pub enum Form3D {
sphere
cylinder
cone
cube
invalid
}
pub struct Point {
pub mut:
x int
y int
}
pub struct Line {
pub mut:
ps []Point
}
pub fn (a Point) + (b Point) Point {
return Point{
x: a.x + b.x
y: a.y + b.y
}
}
pub fn (a Point) str() string {
return '$a.x $a.y'
}
pub fn point_str(a Point) string {
return a.str()
}
pub type PointCond = fn (p Point) bool
|