Difference between revisions of "KeepIf Command"
From GeoGebra Manual
Line 1: | Line 1: | ||
<noinclude>{{Manual Page|version=4.0}}[[Category:Manual (official)|{{PAGENAME}}]]</noinclude> | <noinclude>{{Manual Page|version=4.0}}[[Category:Manual (official)|{{PAGENAME}}]]</noinclude> | ||
{{command|logical}} | {{command|logical}} | ||
− | ; KeepIf[Condition, List]: Creates a new list that only contains those elements of the initial list that fulfil the condition. | + | ; KeepIf[ <Condition>, <List> ]: Creates a new list that only contains those elements of the initial list that fulfil the condition. |
: {{Example|1=<code>KeepIf[x<3, {1, 2, 3, 4, 1, 5, 6}]</code> returns the new list ''{1, 2, 1}''.}} | : {{Example|1=<code>KeepIf[x<3, {1, 2, 3, 4, 1, 5, 6}]</code> returns the new list ''{1, 2, 1}''.}} | ||
{{note|1=For list of numbers arbitrary condition may be used. For list of other objects one can use only conditions of the form <code>x==constant</code> or <code>x!=constant</code>.}} | {{note|1=For list of numbers arbitrary condition may be used. For list of other objects one can use only conditions of the form <code>x==constant</code> or <code>x!=constant</code>.}} | ||
+ | |||
+ | |||
+ | {{betamanual|version=4.2| | ||
+ | 1=; KeepIf[ <Condition>, <Variable>, <List> ] | ||
+ | : This allows a more flexible syntax, eg for Points P, Q, R <code>KeepIf[x(A) <= 3, A, {P, Q, R}]</code> will filter out the points whose x-coordinate is greater than 3. The Variable A is replaced in turn with P then Q then R for the check.} | ||
+ | }} |
Revision as of 14:06, 11 August 2012
- KeepIf[ <Condition>, <List> ]
- Creates a new list that only contains those elements of the initial list that fulfil the condition.
- Example:
KeepIf[x<3, {1, 2, 3, 4, 1, 5, 6}]
returns the new list {1, 2, 1}.
Note: For list of numbers arbitrary condition may be used. For list of other objects one can use only conditions of the form
x==constant
or x!=constant
.
Following text is about a feature that is supported only in GeoGebra 4.2.
|