Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
37
Task/Vector/Arturo/vector.arturo
Normal file
37
Task/Vector/Arturo/vector.arturo
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
define :vector [
|
||||
x y
|
||||
][
|
||||
print: -> render "(|this\x|, |this\y|)" ; prettyprint function
|
||||
]
|
||||
|
||||
ensureVector: function [block][
|
||||
ensure -> every? @block => [is? :vector &]
|
||||
]
|
||||
|
||||
vadd: function [a b][
|
||||
ensureVector [a b]
|
||||
to :vector @[a\x + b\x, a\y + b\y]
|
||||
]
|
||||
|
||||
vsub: function [a b][
|
||||
ensureVector [a b]
|
||||
to :vector @[a\x - b\x, a\y - b\y]
|
||||
]
|
||||
|
||||
vmul: function [a n][
|
||||
ensureVector [a]
|
||||
to :vector @[a\x * n, a\y * n]
|
||||
]
|
||||
|
||||
vdiv: function [a n][
|
||||
ensureVector [a]
|
||||
to :vector @[a\x // n, a\y // n]
|
||||
]
|
||||
|
||||
; 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]
|
||||
Loading…
Add table
Add a link
Reference in a new issue