Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
21
Task/Vector/Unicon/vector.unicon
Normal file
21
Task/Vector/Unicon/vector.unicon
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
procedure main()
|
||||
v1 := vector(5,7)
|
||||
v2 := vector(2,3)
|
||||
write(v1.tostring(),"+",v2.tostring()," = ",(v1 + v2).tostring())
|
||||
write(v1.tostring(),"-",v2.tostring()," = ",(v1 - v2).tostring())
|
||||
write(v1.tostring(),"*123 = ",(v1*123).tostring())
|
||||
write(v1.tostring(),"/0.5 = ",(v1*0.5).tostring())
|
||||
end
|
||||
|
||||
class vector(x,y)
|
||||
method tostring();return "["||x||","||y||"]"; end
|
||||
method add(v); return vector(x+v.x, y+v.y); end
|
||||
method minus(v); return vector(x-v.x, y-v.y); end
|
||||
method mult(z); return vector(x*z, y*z); end
|
||||
method div(z); return vector(x/z, y/z); end
|
||||
# The next four provide operator overloading, if enabled.
|
||||
method __add__(v); return add(v); end
|
||||
method __minus__(v); return minus(v); end
|
||||
method __mult__(z); return mult(z); end
|
||||
method __div__(z); return div(z); end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue