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
24
Task/Polymorphism/Phix/polymorphism.phix
Normal file
24
Task/Polymorphism/Phix/polymorphism.phix
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
type point(object o)
|
||||
return sequence(o) and length(o)=2 and atom(o[1]) and atom(o[2])
|
||||
end type
|
||||
|
||||
function new_point(atom x=0, atom y=0)
|
||||
return {x,y}
|
||||
end function
|
||||
|
||||
type circle(object o)
|
||||
return sequence(o) and length(o)=2 and point(o[1]) and atom(o[2])
|
||||
end type
|
||||
|
||||
function new_circle(object x=0, atom y=0, atom r=0)
|
||||
if point(x) then
|
||||
r = y -- assume r got passed in y
|
||||
return {x,r} -- {point,r}
|
||||
end if
|
||||
return {{x,y},r}
|
||||
end function
|
||||
|
||||
point p = new_point(4,5)
|
||||
circle c = new_circle(p,6)
|
||||
?p
|
||||
?c
|
||||
Loading…
Add table
Add a link
Reference in a new issue