Skip to content

Commit

Permalink
Adding Better example
Browse files Browse the repository at this point in the history
  • Loading branch information
rrezel committed Jun 10, 2016
1 parent 446cf00 commit 494eebe
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 48 deletions.
44 changes: 20 additions & 24 deletions example.rix
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
Rectangle :: BaseType

width = int
height = int

::: int width, int height
$.width = width
$.height = height

area -> int: = width * height


Square :: Rectangle

::: int edge
width = edge
height = edge


#r = Rectangle 5, 10
#s = Square 16

print ("Rectange area " + (r area))
print ("Square Area " + (s area))
Point :: BaseType
x = int
y = int

$(int x, int y)
$.x=x
$.y=y

Line :: BaseType
a = Point
b = Point

$(Point a, Point b)
$.a=a
$.b=b

length->float() = (((a.x-b.x)^^2) + ((a.y-b.y)^^2)) ^^ 0.5

#myLine = Line (Point (3, 0), Point (0, 4))
print ("Length of my line is: " + myLine.length())
24 changes: 0 additions & 24 deletions examples/example.rix

This file was deleted.

0 comments on commit 494eebe

Please sign in to comment.