Difference between revisions of "Lists"

From GeoGebra Manual
Jump to: navigation, search
(added links)
Line 6: Line 6:
 
* <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.}}
+
{{Note|By default, the elements of this list are not shown in the [[Graphics View]].}}
  
 
To access particular elements of the list you can use Element Command or parentheses (see [[Element Command]] for details). Lists can be used as arguments in list operations (mentioned further in this article) or [[List Commands]].
 
To access particular elements of the list you can use Element Command or parentheses (see [[Element Command]] for details). Lists can be used as arguments in list operations (mentioned further in this article) or [[List Commands]].
Line 18: Line 18:
 
==Apply Predefined Operations and Functions to Lists==
 
==Apply Predefined 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.
+
If you apply [[Predefined Functions and Operators]] to lists, you will always get a new list as a result.
  
 
===Addition and subtraction===
 
===Addition and subtraction===

Revision as of 15:03, 26 July 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.

To access particular elements of the list you can use Element Command or parentheses (see Element Command for details). Lists can be used as arguments in list operations (mentioned further in this article) or List Commands.

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 Predefined Operations and Functions to Lists

If you apply Predefined Functions and Operators 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.
© 2021 International GeoGebra Institute