Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
24
Task/Compound-data-type/Transd/compound-data-type.transd
Normal file
24
Task/Compound-data-type/Transd/compound-data-type.transd
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#lang transd
|
||||
|
||||
// If the Point type needs encapsulation and/or methods, it should be
|
||||
// implemented as class. Otherwise, the named tuple will do.
|
||||
|
||||
class Point: {
|
||||
x: Double(), y: Double(),
|
||||
@init: (λ _x Double() _y Double() (= x _x) (= y _y)),
|
||||
@to-String: (λ ss StringStream() (textout to: ss
|
||||
"Point( x: " x "; y: " y " )"))
|
||||
// ... other methods can be defined here ...
|
||||
}
|
||||
|
||||
MainModule: {
|
||||
Point2: typealias(Tuple<Double Double>()),
|
||||
_start: (λ
|
||||
(with pt Point(2.5 3.7)
|
||||
(lout "Class: " pt)
|
||||
)
|
||||
(with pt Point2(2.5 3.7)
|
||||
(lout "\nNamed tuple: " pt)
|
||||
)
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue