Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Reduce (computer algebra system)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== Conditional statements: if ... then ... else ==== The conditional statement has the form <div class="center" style="width: auto; margin-left: auto; margin-right: auto;"> <code>if</code> ''boolean expression'' <code>then</code> ''statement'' </div> which can optionally be followed by <div class="center" style="width: auto; margin-left: auto; margin-right: auto;"> <code>else</code> ''statement'' </div> For example, the following conditional statement ensures that the value of <math>n</math>, assumed to be numerical, is positive. (It effectively implements the [[Absolute value (algebra)|absolute value]] function.) <syntaxhighlight lang="octave"> if n < 0 then n := -n </syntaxhighlight> The following conditional statement, used as an expression, avoids an error that would be caused by dividing by 0. <syntaxhighlight lang="octave"> recip_x := if x = 0 then infinity else 1/x </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)