Memento: Programmation

Elementary commands


Commands are separated with ; Except the storing, the default programation syntax of giac/xcas is like the C language

Functions

  1. In a program, variables that are not explicitely declared with the local instruction are global.
  2. local variables must be initialised. So to une a formal symbol in a function, either use a non initialised global variable, or do as in example rfact below.
  3. Blocs of code are in { }. One can use several lines in a same bloc.
  4. A program always return the last evaluation. The return command is optional.
  5. Please do not use i as a variable name in loops because it is reserved for the complex number square root of -1.

Tests

Main loops


NB: Les parenthesis and accolades in for, while are mandatory.

Sequences ( , , ) and Lists [ , , ]

Sequences and lists are indexed from 0 (except in mode maple). Use brackets to get an element:
a[0] is the first element of the list or sequence a

Sequences ( , , ) are ordered objects separated with commas. Les parenthesis are simplified. Operators +,* ... are really not the usual operations of vectors

Lists [ , , ] are objets between brackets and separated by commas. They are ordered and no bracket is simplified. They are used for vectors and matrices.

Notions avancées