Top
Back: 3.5 The SINGULAR language
Forward: 3.5.2 Special characters
FastBack: 3. General concepts
FastForward: 4. Data types
Up: 3.5 The SINGULAR language
Top: Singular 2-0-4 Manual
Contents: Table of Contents
Index: F. Index
About: About This Document

3.5.1 General command syntax

In SINGULAR a command is either a declaration, an assignment, a call to a function without return value, or a print command. The general form of a command is described in the following subsections.

Declaration

  1. type name = expression ;
    declares a variable with the given name of the given type and assigns the expression as initial value to it. Expression is an expression of the specified type or one that can be converted to that type. See Type conversion and casting.
  2. type name_list = expression_list ;
    declares variables with the given names and assigns successively each expression of expression_list to the corresponding name of name_list. Both lists must be of the same length. Each expression in expression_list is an expression of the specified type or one that can be converted to that type. See Type conversion and casting.
  3. type name ;
    declares a variable with the given name of the given type and assigns the default value of the specific type to it.

See Names, for more information on declarations. See Data types, for a description of all data types known to SINGULAR.

 
ring r;                   // the default ring
poly f,g = x^2+y^3,xy+z2; // the polynomials f=x^2+y^3 and g=x*y+z^2
ideal I = f,g;            // the ideal generated by f and g
matrix m[3][3];           // a 3 x 3 zero matrix
int i=2;                  // the integer i=2

Assignment

  1. name = expression ;
    assigns expression to name.
  2. name_list = expression_list ;
    assigns successively each expression of expression_list to the corresponding name of name_list. Both lists must be of the same length. This is not a simultaneous assignment. Thus, f, g = g, f; does not swap the values of f and g, but rather assigns g to both f and g.

There must be a type conversion of the type of expression to the type of name. See Type conversion and casting.

An assignment itself does not yield a value. Hence, compound assignments like i = j = k; are not allowed and result in an error.

 
f = x^2 + y^2 ;      // overwrites the old value of f
I = jacob(f);
f,g = I[1],x^2+y^2 ; // overwrites the old values of f and g

Function without return value

  1. function_name [ ( argument_list ) ] ;
    calls function function_name with arguments argument_list.

The function may have output (not to be confused with a return value of type string). See Functions. Functions without a return value are specified there to have a return type ’none’.

Some of these functions have to be called without parentheses, e.g., help, LIB.

 
  ring r;
  ideal i=x2+y2,x;
  i=std(i);
  degree(i);        // degree has no return value but prints output
→ 2

Print command

  1. expression ;
    prints the value of an expression, for example, of a variable.

Use the function print (or the procedure show from inout.lib) to get a pretty output of various data types, e.g., matrix or intmat. See print.

 
  int i=2;
  i;
→ 2
  intmat m[2][2]=1,7,10,0;
  print(m);
→      1     7
→     10     0

Top Back: 3.5 The SINGULAR language Forward: 3.5.2 Special characters FastBack: 3. General concepts FastForward: 4. Data types Up: 3.5 The SINGULAR language Top: Singular 2-0-4 Manual Contents: Table of Contents Index: F. Index About: About This Document
            User manual for Singular version 2-0-4, October 2002, generated by texi2html.