Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
33
Task/Vector/Wren/vector-1.wren
Normal file
33
Task/Vector/Wren/vector-1.wren
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
class Vector2D {
|
||||
construct new(x, y) {
|
||||
_x = x
|
||||
_y = y
|
||||
}
|
||||
|
||||
static fromPolar(r, theta) { new(r * theta.cos, r * theta.sin) }
|
||||
|
||||
x { _x }
|
||||
y { _y }
|
||||
|
||||
+(v) { Vector2D.new(_x + v.x, _y + v.y) }
|
||||
-(v) { Vector2D.new(_x - v.x, _y - v.y) }
|
||||
*(s) { Vector2D.new(_x * s, _y * s) }
|
||||
/(s) { Vector2D.new(_x / s, _y / s) }
|
||||
|
||||
toString { "(%(_x), %(_y))" }
|
||||
}
|
||||
|
||||
var times = Fn.new { |d, v| v * d }
|
||||
|
||||
var v1 = Vector2D.new(5, 7)
|
||||
var v2 = Vector2D.new(2, 3)
|
||||
var v3 = Vector2D.fromPolar(2.sqrt, Num.pi / 4)
|
||||
System.print("v1 = %(v1)")
|
||||
System.print("v2 = %(v2)")
|
||||
System.print("v3 = %(v3)")
|
||||
System.print()
|
||||
System.print("v1 + v2 = %(v1 + v2)")
|
||||
System.print("v1 - v2 = %(v1 - v2)")
|
||||
System.print("v1 * 11 = %(v1 * 11)")
|
||||
System.print("11 * v2 = %(times.call(11, v2))")
|
||||
System.print("v1 / 2 = %(v1 / 2)")
|
||||
14
Task/Vector/Wren/vector-2.wren
Normal file
14
Task/Vector/Wren/vector-2.wren
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import "./vector" for Vector2
|
||||
|
||||
var v1 = Vector2.new(5, 7)
|
||||
var v2 = Vector2.new(2, 3)
|
||||
var v3 = Vector2.fromPolar(2.sqrt, Num.pi / 4)
|
||||
System.print("v1 = %(v1)")
|
||||
System.print("v2 = %(v2)")
|
||||
System.print("v3 = %(v3)")
|
||||
System.print()
|
||||
System.print("v1 + v2 = %(v1 + v2)")
|
||||
System.print("v1 - v2 = %(v1 - v2)")
|
||||
System.print("v1 * 11 = %(v1 * 11)")
|
||||
System.print("11 * v2 = %(Vector2.scale(11, v2))")
|
||||
System.print("v1 / 2 = %(v1 / 2)")
|
||||
Loading…
Add table
Add a link
Reference in a new issue