Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -6,7 +6,9 @@ PROC main()
|
|||
DEF pt:PTR TO point,
|
||||
|
||||
NEW pt
|
||||
pt.x := 10.4
|
||||
pt.y := 3.14
|
||||
-> Floats are also stored as integer types making
|
||||
-> the float conversion operator necessary.
|
||||
pt.x := !10.4
|
||||
pt.y := !3.14
|
||||
END pt
|
||||
ENDPROC
|
||||
|
|
|
|||
|
|
@ -1 +1,18 @@
|
|||
//using object literal syntax
|
||||
var point = {x : 1, y : 2};
|
||||
|
||||
//using constructor
|
||||
var Point = function (x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
};
|
||||
point = new Point(1, 2);
|
||||
|
||||
//using ES6 class syntax
|
||||
class Point {
|
||||
constructor(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
point = new Point(1, 2);
|
||||
|
|
|
|||
4
Task/Compound-data-type/Julia/compound-data-type-1.julia
Normal file
4
Task/Compound-data-type/Julia/compound-data-type-1.julia
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
type Point{T<:Real}
|
||||
x::T
|
||||
y::T
|
||||
end
|
||||
4
Task/Compound-data-type/Julia/compound-data-type-2.julia
Normal file
4
Task/Compound-data-type/Julia/compound-data-type-2.julia
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
==(u::Point, v::Point) = (u.x == v.x) & (u.y == v.y)
|
||||
-(u::Point) = Point(-u.x, -u.y)
|
||||
+(u::Point, v::Point) = Point(u.x + v.x, u.y + v.y)
|
||||
-(u::Point, v::Point) = Point(u.x - v.x, u.y - v.y)
|
||||
14
Task/Compound-data-type/Julia/compound-data-type-3.julia
Normal file
14
Task/Compound-data-type/Julia/compound-data-type-3.julia
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
a = Point(1, 2)
|
||||
b = Point(3, 7)
|
||||
c = Point(2, 4)
|
||||
|
||||
println("a = ", a)
|
||||
println("b = ", b)
|
||||
println("c = ", c)
|
||||
|
||||
println("a + b = ", a+b)
|
||||
println("-a + b = ", -a+b)
|
||||
println("a - b = ", a-b)
|
||||
println("a + b + c = ", a+b+c)
|
||||
println("a == c ", a == c)
|
||||
println("a + a == c ", a + a == c)
|
||||
4
Task/Compound-data-type/Perl-6/compound-data-type-4.pl6
Normal file
4
Task/Compound-data-type/Perl-6/compound-data-type-4.pl6
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
my $s1 = set <a b c d>; # order is not preserved
|
||||
my $s2 = set <c d e f>;
|
||||
say $s1 (&) $s2; # OUTPUT«set(c, e)»
|
||||
say $s1 ∩ $s2; # we also do Unicode
|
||||
1
Task/Compound-data-type/TXR/compound-data-type-1.txr
Normal file
1
Task/Compound-data-type/TXR/compound-data-type-1.txr
Normal file
|
|
@ -0,0 +1 @@
|
|||
(defstruct point nil (x 0) (y 0))
|
||||
1
Task/Compound-data-type/TXR/compound-data-type-2.txr
Normal file
1
Task/Compound-data-type/TXR/compound-data-type-2.txr
Normal file
|
|
@ -0,0 +1 @@
|
|||
(defstruct point nil x y)
|
||||
3
Task/Compound-data-type/TXR/compound-data-type-3.txr
Normal file
3
Task/Compound-data-type/TXR/compound-data-type-3.txr
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(new point) ;; -> #S(point x 0 y 0)
|
||||
(new point x 1) ;; -> #S(point x 1 y 0)
|
||||
(new point x 1 y 1) ;; -> #S(point x 1 y 1)
|
||||
1
Task/Compound-data-type/TXR/compound-data-type-4.txr
Normal file
1
Task/Compound-data-type/TXR/compound-data-type-4.txr
Normal file
|
|
@ -0,0 +1 @@
|
|||
(defstruct (point x y) nil (x 0) (y 0))
|
||||
1
Task/Compound-data-type/TXR/compound-data-type-5.txr
Normal file
1
Task/Compound-data-type/TXR/compound-data-type-5.txr
Normal file
|
|
@ -0,0 +1 @@
|
|||
(new (point 3 4)) -> #S(point x 3 y 4)
|
||||
3
Task/Compound-data-type/TXR/compound-data-type-6.txr
Normal file
3
Task/Compound-data-type/TXR/compound-data-type-6.txr
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(defun displace-point-destructively (p delta)
|
||||
(inc p.x delta.x)
|
||||
(inc p.y delta.y))
|
||||
Loading…
Add table
Add a link
Reference in a new issue