If ukaz
Iz GeoGebra Manual
Ta stran je del uradnega priročnika za natis in pdf. zaradi ohranjanja strukture običajnim uporabnikom ni dovoljeno spreminjati/urejati te strani. Če najdete napako na tej strani, nas o tem obvestite.Pojdite na verzijo, ki jo lahko urejajo uporabniki
If
Ta članek govori o GeoGebra ukazu.Kategorije ukazov (Vsi ukazi)
- If[ <pogoj>, <objekt> ]
- če je pogoj izpolnjen (ima vrednost true), vrne kopijo objekta, sicer pa vrne nedefiniran objekt.
- If[ <pogoj>, <objekt a>, <objekt b> ]
- če je pogoj izpolnjen (ima vrednost true), vrne kopijo objekta a, sicer pa vrne objekt b.
Opozorilo: | Oba objekta morata biti istega tipa. |
Odsekoma podane funkcije
Ukaz If lahko uporabimo, da ustvarimo odsekoma podane funkcije. Tako podane funkcije lahko uporabimo kot argumente v poljubnem ukazu, ki kot parameter sprejme funkcijo, na primer Odvod, Integral, and Presečišče.
Primeri:
f(x) = If[x < 3, sin(x), x^2]
yields a function that equals sin(x) for x < 3 and x2 for x ≥ 3f(x) = If[x < 3 ∧ x>0, x^3]
yields a function that equals sin(x) for x between 0 and 3 and undefined for x ≥ 3 or x ≤ 0.
Opomba: Glej razdelek: Boolove_vrednosti for the symbols used in conditional statements.
Opomba: Derivative of If[condition, f(x), g(x)] gives If[condition, f'(x), g'(x)]. It does not do any evaluation of limits at the critical points.
If Command in Scripting
In many programming languages if has the meaning "If condition holds, do something; otherwise do something else". In GeoGebra, arguments of If are not commands, but values, one of which becomes the value of the result. Therefore
if you want to e.g. set value of b to 3 provided a > 2, correct way to do this is SetValue[b,If[a>2,3,b]]
. The other way of nesting SetValue and If is incorrect.
Following text is about a feature that is supported only in 5.0 beta version.
Primer: Let n be a number, and A a point. The command If[Mod[n, 2] == 0, SetCoords[A, n, 0], SetCoords[A, n, 1]] modifies the coordinates of point A according to the given condition. |