Polymorphism: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: added syntax colouring the hard way) |
Drkameleon (talk | contribs) (Added Arturo implementation) |
||
Line 439: | Line 439: | ||
Circle(+4.10000000000000e +0 @ +0.00000000000000e +0,+0.00000000000000e +0) |
Circle(+4.10000000000000e +0 @ +0.00000000000000e +0,+0.00000000000000e +0) |
||
</pre> |
</pre> |
||
=={{header|Arturo}}== |
|||
<lang rebol>define :point [x,y][ |
|||
init: [ |
|||
ensure -> is? :floating this\x |
|||
ensure -> is? :floating this\y |
|||
] |
|||
print: [ |
|||
render "point (x: |this\x|, y: |this\y|)" |
|||
] |
|||
] |
|||
define :circle [center,radius][ |
|||
init: [ |
|||
ensure -> is? :point this\center |
|||
ensure -> is? :floating this\radius |
|||
] |
|||
print: [ |
|||
render "circle (center: |this\center|, radius: |this\radius|)" |
|||
] |
|||
] |
|||
p: to :point [10.0, 20.0] |
|||
c: to :circle @[p, 10.0] |
|||
inspect p |
|||
inspect c |
|||
print p |
|||
print c</lang> |
|||
{{out}} |
|||
<pre>[ :point |
|||
x : 10.0 :floating |
|||
y : 20.0 :floating |
|||
] |
|||
[ :circle |
|||
center : [ :point |
|||
x : 10.0 :floating |
|||
y : 20.0 :floating |
|||
] |
|||
radius : 10.0 :floating |
|||
] |
|||
point (x: 10.0, y: 20.0) |
|||
circle (center: point (x: 10.0, y: 20.0), radius: 10.0)</pre> |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |