Difference between revisions of "Lists"

From GeoGebra Manual
Jump to: navigation, search
(fixed bad formatting: all the page was formatted as "example")
Line 3: Line 3:
 
Using curly braces you can create a list of several objects (e. g. points, segments, circles).
 
Using curly braces you can create a list of several objects (e. g. points, segments, circles).
  
{{Example|1=<div>
+
{{Example|1=<br>
 
* <code>L = {A, B, C}</code> gives you a list consisting of three prior defined points A, B, and C.
 
* <code>L = {A, B, C}</code> gives you a list consisting of three prior defined points A, B, and C.
 
* <code>L = {(0, 0), (1, 1), (2, 2)}</code> produces a list that consists of the entered points, as well as these nameless points. }}
 
* <code>L = {(0, 0), (1, 1), (2, 2)}</code> produces a list that consists of the entered points, as well as these nameless points. }}
{{Note|By default, the elements of this list are not shown in the Graphics View.</div>}}
+
{{Note|By default, the elements of this list are not shown in the Graphics View.}}
 
==Compare Lists of Objects==
 
==Compare Lists of Objects==
  
Line 33: Line 33:
 
* List^2: Squares every element of the list.
 
* List^2: Squares every element of the list.
 
* 2^List: Creates list of powers of two with exponents from the list.
 
* 2^List: Creates list of powers of two with exponents from the list.
* List1^List2: Creates list of a^b, where a and b are corresponding elements of List1 and List2.
+
* List1^List2: Creates list of ''a^b'', where ''a'' and ''b'' are corresponding elements of List1 and List2.
 
* sin(List): Applies the sine function to every element of the list. User defined [[Functions|functions]] can be applied the same way as well.
 
* sin(List): Applies the sine function to every element of the list. User defined [[Functions|functions]] can be applied the same way as well.

Revision as of 10:54, 13 May 2011


Using curly braces you can create a list of several objects (e. g. points, segments, circles).

Example:
  • L = {A, B, C} gives you a list consisting of three prior defined points A, B, and C.
  • L = {(0, 0), (1, 1), (2, 2)} produces a list that consists of the entered points, as well as these nameless points.
Note: By default, the elements of this list are not shown in the Graphics View.

Compare Lists of Objects

You can compare two lists of objects by using the following syntax:

  • List1 == List2: Checks if the two lists are equal and gives you true or false as a result.
  • List1 != List2: Checks if the two lists are not equal and gives you true or false as a result.

Apply Pre-defined Operations and Functions to Lists

If you apply operations and pre-defined functions to lists, you will always get a new list as a result.

Addition and subtraction

  • List1 + List2: Adds corresponding elements of two lists.
    Note: The two lists need to be of the same length.
  • List + Number: Adds the number to every element of the list.
  • List1 – List2: Subtracts the elements of the second list from corresponding elements of the first list.
    Note: The lists need to be of the same length.
  • List – Number: Subtracts the number from every element of the list.

Multiplication and division

  • List1 * List2: Multiplies corresponding elements of two lists.
    Note: The lists need to be of the same length. If the two lists are compatible matrices, matrix multiplication is used.
  • List * Number: Multiplies every list element with the number.
  • List1 / List2: Divides elements of the first list by corresponding elements of the second list.
    Note: The two lists need to be of the same length.
  • List / Number: Divides every list element by the number.
  • Number / List: Divides the number by every element of the list.

Other examples

  • List^2: Squares every element of the list.
  • 2^List: Creates list of powers of two with exponents from the list.
  • List1^List2: Creates list of a^b, where a and b are corresponding elements of List1 and List2.
  • sin(List): Applies the sine function to every element of the list. User defined functions can be applied the same way as well.
© 2024 International GeoGebra Institute