Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Inheritance-Single/E/inheritance-single-1.e
Normal file
18
Task/Inheritance-Single/E/inheritance-single-1.e
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
def makeType(label, superstamps) {
|
||||
def stamp {
|
||||
to audit(audition) {
|
||||
for s in superstamps { audition.ask(s) }
|
||||
return true
|
||||
}
|
||||
}
|
||||
def guard {
|
||||
to coerce(specimen, ejector) {
|
||||
if (__auditedBy(stamp, specimen)) {
|
||||
return specimen
|
||||
} else {
|
||||
throw.eject(ejector, `$specimen is not a $label`)
|
||||
}
|
||||
}
|
||||
}
|
||||
return [guard, stamp]
|
||||
}
|
||||
7
Task/Inheritance-Single/E/inheritance-single-2.e
Normal file
7
Task/Inheritance-Single/E/inheritance-single-2.e
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
def [Animal, AnimalStamp] := makeType("Animal", [])
|
||||
|
||||
def [Cat, CatStamp] := makeType("Cat", [AnimalStamp])
|
||||
def [Dog, DogStamp] := makeType("Dog", [AnimalStamp])
|
||||
|
||||
def [Lab, LabStamp] := makeType("Lab", [DogStamp])
|
||||
def [Collie, CollieStamp] := makeType("Collie", [DogStamp])
|
||||
3
Task/Inheritance-Single/E/inheritance-single-3.e
Normal file
3
Task/Inheritance-Single/E/inheritance-single-3.e
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
def fido implements LabStamp {}
|
||||
def tom implements CatStamp {}
|
||||
def brick {} # not an animal
|
||||
17
Task/Inheritance-Single/E/inheritance-single-4.e
Normal file
17
Task/Inheritance-Single/E/inheritance-single-4.e
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
? fido :Animal
|
||||
# value: <fido>
|
||||
|
||||
? fido :Cat
|
||||
# problem: <fido> is not a Cat
|
||||
|
||||
? fido :Lab
|
||||
# value: <fido>
|
||||
|
||||
? tom :Animal
|
||||
# value: <tom>
|
||||
|
||||
? tom :Cat
|
||||
# value: <tom>
|
||||
|
||||
? brick :Animal
|
||||
# problem: <brick> is not a Animal
|
||||
Loading…
Add table
Add a link
Reference in a new issue