Difference between revisions of "ParseToFunction Command"

From GeoGebra Manual
Jump to: navigation, search
m (Text replace - "<div class="box info"> 48px|left This page is part of the official manual for print and pdf. For structural reasons normal users can't edit this page. If you found any errors on this page please contact )
 
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
<noinclude>{{Manual Page|version=4.2}}</noinclude>
+
<noinclude>{{Manual Page|version=5.0}}</noinclude>{{command|scripting}}
{{command|scripting}}
+
;ParseToFunction( <Text> )
;ParseToFunction[ <Function f>, <String> ]
+
:Parses the text containing the function definition and creates the corresponding [[Functions|function]].
:Parses the string and stores the result to [[Functions|function]] ''f''. Function ''f'' must be defined and [[Free, Dependent and Auxiliary Objects|free]] before the command is used.
+
:{{examples|1=<div>
:{{example|1=<div> Define <code><nowiki> f(x) = 3x² + 2</nowiki></code> and <code><nowiki> text1 = "f(x) = 3x + 1"</nowiki></code>. </div> <code><nowiki> ParseToFunction[f(x), text1]</nowiki></code> returns ''f(x) = 3x + 1''.}}
+
:*<code><nowiki> ParseToFunction("x^2")</nowiki></code> creates the function ''f''(''x'') = ''x''<sup>2</sup>''.
 +
:*<code><nowiki> ParseToFunction("t+2/t"})</nowiki></code> creates the function ''f''(''t'') = ''t'' + 2/''t''.</div>}}
 +
 
 +
;ParseToFunction( <Function>, <Text> )
 +
:Parses the string and stores the result to a [[Functions|function]] ''f'', which must be defined and [[Free, Dependent and Auxiliary Objects|free]] before the command is used.
 +
:{{example|1=Define <code><nowiki> f(x) = 3x² + 2</nowiki></code> and <code><nowiki> text1 = "f(x) = 3x + 1"</nowiki></code>. <code><nowiki> ParseToFunction(f, text1)</nowiki></code> returns ''f(x) = 3x + 1''.}}
 +
 
 +
;ParseToFunction( <Text>, <List of variables> )
 +
:Parses the text containing the function definition and creates the corresponding [[Functions|function]] of the variables defined in the list.
 +
:{{example|1=<code><nowiki> ParseToFunction("2u+3v",{"u", "v"})</nowiki></code> creates the function ''a(u,v) = 2u + 3v''.}}
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
{{note|1=See also [[ParseToNumber Command|ParseToNumber]] command. }}

Latest revision as of 18:20, 13 April 2022


ParseToFunction( <Text> )
Parses the text containing the function definition and creates the corresponding function.
Examples:
  • ParseToFunction("x^2") creates the function f(x) = x2.
  • ParseToFunction("t+2/t"}) creates the function f(t) = t + 2/t.


ParseToFunction( <Function>, <Text> )
Parses the string and stores the result to a function f, which must be defined and free before the command is used.
Example: Define f(x) = 3x² + 2 and text1 = "f(x) = 3x + 1". ParseToFunction(f, text1) returns f(x) = 3x + 1.


ParseToFunction( <Text>, <List of variables> )
Parses the text containing the function definition and creates the corresponding function of the variables defined in the list.
Example: ParseToFunction("2u+3v",{"u", "v"}) creates the function a(u,v) = 2u + 3v.





Note: See also ParseToNumber command.
© 2024 International GeoGebra Institute