Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,37 +1,34 @@
|
|||
define :vector [
|
||||
x y
|
||||
][
|
||||
print: -> render "(|this\x|, |this\y|)" ; prettyprint function
|
||||
]
|
||||
init: method [x,y][
|
||||
this\x: x
|
||||
this\y: y
|
||||
]
|
||||
|
||||
ensureVector: function [block][
|
||||
ensure -> every? @block => [is? :vector &]
|
||||
]
|
||||
add: method [that :vector][
|
||||
to :vector @[this\x + that\x, this\y + that\y]
|
||||
]
|
||||
|
||||
vadd: function [a b][
|
||||
ensureVector [a b]
|
||||
to :vector @[a\x + b\x, a\y + b\y]
|
||||
]
|
||||
sub: method [that :vector][
|
||||
to :vector @[this\x - that\x, this\y - that\y]
|
||||
]
|
||||
|
||||
vsub: function [a b][
|
||||
ensureVector [a b]
|
||||
to :vector @[a\x - b\x, a\y - b\y]
|
||||
]
|
||||
mul: method [n :integer][
|
||||
to :vector @[this\x * n, this\y * n]
|
||||
]
|
||||
|
||||
vmul: function [a n][
|
||||
ensureVector [a]
|
||||
to :vector @[a\x * n, a\y * n]
|
||||
]
|
||||
div: method [n :integer][
|
||||
to :vector @[this\x // n, this\y // n]
|
||||
]
|
||||
|
||||
vdiv: function [a n][
|
||||
ensureVector [a]
|
||||
to :vector @[a\x // n, a\y // n]
|
||||
string: method [][
|
||||
render "(|this\x|, |this\y|)"
|
||||
]
|
||||
]
|
||||
|
||||
; test our vector object
|
||||
a: to :vector [5 7]
|
||||
b: to :vector [2 3]
|
||||
print [a '+ b '= vadd a b]
|
||||
print [a '- b '= vsub a b]
|
||||
print [a '* 11 '= vmul a 11]
|
||||
print [a '/ 11 '= vdiv a 2]
|
||||
print [a '+ b '= a + b]
|
||||
print [a '- b '= a - b]
|
||||
print [a '* 11 '= a * 11]
|
||||
print [a '/ 11 '= a / 2]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue