diff --git a/example.rix b/example.rix index a0ce786..3d29dc2 100644 --- a/example.rix +++ b/example.rix @@ -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()) diff --git a/examples/example.rix b/examples/example.rix deleted file mode 100644 index 653bb26..0000000 --- a/examples/example.rix +++ /dev/null @@ -1,24 +0,0 @@ -int: factorial int n - result = 1 - i for 1,n+1 - result = result * i - ->result - - -int: sum int n - n==0 if - ->n - ->n + (sum (n-1)) - -hello="Hello" -world="World" -helloWorld=hello+" "+world -print helloWorld - -num=5 -f=f1=f2=5.5^^2 -echo "f2 is "+f2 -f3=(((2*3)+1)*4)^^3 -print " and f3 is "+f3 -print "Factorial of "+num + " is " + factorial num -print "Sum of first "+num + " integers is " + sum num