Warning: include(../../parts/infohead2.php) [function.include]: failed to open stream: No such file or directory in /home/mariuss/manpagez.com/info/asymptote/asymptote-2.15/asymptote-2.15/asymptote_24.php on line 1

Warning: include() [function.include]: Failed opening '../../parts/infohead2.php' for inclusion (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear') in /home/mariuss/manpagez.com/info/asymptote/asymptote-2.15/asymptote-2.15/asymptote_24.php on line 1
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6 Programming

Here is a short introductory example to the Asymptote programming language that highlights the similarity of its control structures with those of C, C++, and Java:

// This is a comment.

// Declaration: Declare x to be a real variable;
real x;

// Assignment: Assign the real variable x the value 1.
x=1.0;

// Conditional: Test if x equals 1 or not.
if(x == 1.0) {
  write("x equals 1.0");
} else {
  write("x is not equal to 1.0");
}

// Loop: iterate 10 times
for(int i=0; i < 10; ++i) {
  write(i);
}

Asymptote supports while, do, break, and continue statements just as in C/C++. It also supports the Java-style shorthand for iterating over all elements of an array:

// Iterate over an array
int[] array={1,1,2,3,5};
for(int k : array) {
  write(k);
}

In addition, it supports many features beyond the ones found in those languages.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on November 17, 2011 using texi2html 5.0.

Warning: include(../../parts/infofoot2.php) [function.include]: failed to open stream: No such file or directory in /home/mariuss/manpagez.com/info/asymptote/asymptote-2.15/asymptote-2.15/asymptote_24.php on line 126

Warning: include() [function.include]: Failed opening '../../parts/infofoot2.php' for inclusion (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear') in /home/mariuss/manpagez.com/info/asymptote/asymptote-2.15/asymptote-2.15/asymptote_24.php on line 126