Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
31
Task/Classes/LFE/classes-1.lfe
Normal file
31
Task/Classes/LFE/classes-1.lfe
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
(defmodule simple-object
|
||||
(export all))
|
||||
|
||||
(defun fish-class (species)
|
||||
"
|
||||
This is the constructor used internally, once the children and fish id are
|
||||
known.
|
||||
"
|
||||
(let ((habitat '"water"))
|
||||
(lambda (method-name)
|
||||
(case method-name
|
||||
('habitat
|
||||
(lambda (self) habitat))
|
||||
('species
|
||||
(lambda (self) species))))))
|
||||
|
||||
(defun get-method (object method-name)
|
||||
"
|
||||
This is a generic function, used to call into the given object (class
|
||||
instance).
|
||||
"
|
||||
(funcall object method-name))
|
||||
|
||||
; define object methods
|
||||
(defun get-habitat (object)
|
||||
"Get a variable set in the class."
|
||||
(funcall (get-method object 'habitat) object))
|
||||
|
||||
(defun get-species (object)
|
||||
"Get a variable passed when constructing the object."
|
||||
(funcall (get-method object 'species) object))
|
||||
8
Task/Classes/LFE/classes-2.lfe
Normal file
8
Task/Classes/LFE/classes-2.lfe
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
> (slurp '"simple-object.lfe")
|
||||
#(ok simple-object)
|
||||
> (set my-fish (fish-class '"Carp"))
|
||||
#Fun<lfe_eval.10.91765564>
|
||||
> (get-habitat my-fish)
|
||||
"water"
|
||||
> (get-species my-fish)
|
||||
"Carp"
|
||||
Loading…
Add table
Add a link
Reference in a new issue