|
Go to the first, previous, next, last section, table of contents.
User defined functionsTo define functions by an user himself, `def' statement must be used. Syntactical errors are detected in the parsing phase of Asir, and notified with an indication of where Asir found the error. If a function with the same name is already defined (regardless to its arity,) the new definition will override the old one, and the user will be told by a message, afo() redefined.
on the screen when a flag def f(X) { if ( !X ) return 1; else return X * f(X-1); } def c(N) { A = newvect(N+1); A[0] = B = newvect(1); B[0] = 1; for ( K = 1; K <= N; K++ ) { A[K] = B = newvect(K+1); B[0] = B[K] = 1; for ( P = A[K-1], J = 1; J < K; J++ ) B[J] = P[J-1]+P[J]; } return A; }
In the second example, In the following, the manner of writing Asir programs is exhibited for those who have no experience in writing C programs.
Go to the first, previous, next, last section, table of contents. |