Difference between revisions of "Z^3 Language Documentation"

From ZCubes Wiki
Jump to navigation Jump to search
Line 131: Line 131:
  
 
==Loops==
 
==Loops==
 +
<pre>
 +
a=1;
 +
do
 +
{
 +
a++
 +
}
 +
until(a>20); // do while(!condition)
 +
a; // here this will be 21, since !condition is checked like a do while loop.
 +
 +
a=11;
 +
b=45;
 +
because(a<b)
 +
{
 +
a++
 +
OUTPUT(a)
 +
}
 +
 +
a=11;
 +
do
 +
{
 +
a++
 +
}
 +
unless(a==11);
 +
a;
 +
 +
</pre>

Revision as of 14:02, 23 June 2016

Operators

@: Function Apply Operator

1..100@SIN

~: Transpose Operator


[[[1..10]~]~]~

↑ and ↓: Ascending and Descending Operator

	
	MAGICSQUARE(5)!
	(1..100)↓
	(1..100)↑

⧓,⧒,⧒ and ⋈: Between Operators

	a=-1;
	⧓(1,a,30)
	a=29;	
	⧓(1,a,30) //between g
	
	a=31;
	⧒(1,a,30) //xlbetween g
	a=30;
	⧒(1,a,30) //xlbetween g
	
	⧒(1,2,30) // xlb g
	⧒(1,1,30)
	
	a=29;
	⋈(1,-1..31,30);
	
	⧓(1,-1..5,4);
	
	[
		⧓(1,1,30),
		⧓(1,0,30),
		⧓(1,10,30),
		⧓(1,31,30),
		⧑(1,29,30),
		⧑(1,30,30),
		⧑(1,1,30),
		⧑(1,30,30),
		⋈(1,1,30),
		⋈(1,3,30)
	]

√: Square Root, Cube Root, Fourth Root and Nth Root Operators

	√(3+34)
	∛(27.01)
	√√64
	ROOTNTH(1..10,4) 
		// root is first parameter
	NTHROOT(1..10,4)
		// root is second parameter
	
	NTHROOT(1..100,2)
	NTHROOT(1..100,4)
	ROOTNTH(1..100,2)
	ROOTNTH(1..100,4)
	3√81


Logical Statements

If Statements

    a=3;
    (a<0)::{"whatever"},
    {
		!(a>4)::
			{"whateverelse"},
			{"whateverelseleft"}
	}  
	
	(a>4)::
			{"whateverelse"},
			{"whateverelseleft"}
			

Switch Statements


	b=0;
	c=343;
	fruits="mango";
	fruits:::
	{
        "apple","tomato":: 
        	   b++;
        	   c=3.4;
           ,
		"mango":: 
        	   b=34905; 
                
            ,
        default::
        	
                b=45.6;
            
	}
	[b,c];  
	
	switch(a)
	{
		case b:
		case c:
			break;
		default:
			break;
	}

Loops

	a=1;
	do
	{
		a++
	}
	until(a>20); // do while(!condition)
	a; // here this will be 21, since !condition is checked like a do while loop.
	
	a=11;
	b=45;
	because(a<b)
	{
		a++
		OUTPUT(a)
	}
	
	a=11;
	do
	{
		a++
	}
	unless(a==11); 
	a;