A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
5
Task/Inheritance-Single/Clojure/inheritance-single-1.clj
Normal file
5
Task/Inheritance-Single/Clojure/inheritance-single-1.clj
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(gen-class :name Animal)
|
||||
(gen-class :name Dog :extends Animal)
|
||||
(gen-class :name Cat :extends Animal)
|
||||
(gen-class :name Lab :extends Dog)
|
||||
(gen-class :name Collie :extends Dog)
|
||||
4
Task/Inheritance-Single/Clojure/inheritance-single-2.clj
Normal file
4
Task/Inheritance-Single/Clojure/inheritance-single-2.clj
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(derive ::dog ::animal)
|
||||
(derive ::cat ::animal)
|
||||
(derive ::lab ::dog)
|
||||
(derive ::collie ::dog)
|
||||
6
Task/Inheritance-Single/Clojure/inheritance-single-3.clj
Normal file
6
Task/Inheritance-Single/Clojure/inheritance-single-3.clj
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
user> (isa? ::dog ::animal)
|
||||
true
|
||||
user> (isa? ::dog ::cat)
|
||||
false
|
||||
user> (isa? ::collie ::animal)
|
||||
true
|
||||
5
Task/Inheritance-Single/Clojure/inheritance-single-4.clj
Normal file
5
Task/Inheritance-Single/Clojure/inheritance-single-4.clj
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(defclass animal () ())
|
||||
(defclass dog (animal) ())
|
||||
(defclass lab (dog) ())
|
||||
(defclass collie (dog) ())
|
||||
(defclass cat (animal) ())
|
||||
5
Task/Inheritance-Single/Clojure/inheritance-single-5.clj
Normal file
5
Task/Inheritance-Single/Clojure/inheritance-single-5.clj
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(defstruct animal)
|
||||
(defstruct (dog (:include animal)))
|
||||
(defstruct (lab (:include dog)))
|
||||
(defstruct (collie (:include dog)))
|
||||
(defstruct (cat (:include animal)))
|
||||
9
Task/Inheritance-Single/Clojure/inheritance-single-6.clj
Normal file
9
Task/Inheritance-Single/Clojure/inheritance-single-6.clj
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
;;; ASN.1 serialization logic specialized for animal class
|
||||
(defmethod serialize-to-asn-1 ((a animal))
|
||||
#| ... |#
|
||||
)
|
||||
|
||||
;;; casually introduce the method over strings too; no relation to animal
|
||||
(defmethod serialize-to-asn-1 ((s string))
|
||||
#| ... #|
|
||||
)
|
||||
6
Task/Inheritance-Single/Clojure/inheritance-single-7.clj
Normal file
6
Task/Inheritance-Single/Clojure/inheritance-single-7.clj
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
TYPE
|
||||
Animal = ABSTRACT RECORD (* *) END;
|
||||
Cat = RECORD (Animal) (* *) END; (* final record (cannot be extended) - by default *)
|
||||
Dog = EXTENSIBLE RECORD (Animal) (* *) END; (* extensible record *)
|
||||
Lab = RECORD (Dog) (* *) END;
|
||||
Collie = RECORD (Dog) (* *) END;
|
||||
Loading…
Add table
Add a link
Reference in a new issue