Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Mathematica/FlowControl

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Control Flow If Statements For Loop For[start, test, incr, body] executes start, then repeatedly evaluates body and incr until test fails to give True. Example: For[x=1, x<5, x=x+1, Print["x=",x]] While Loop While[test, body] evaluates test, then body, repetitively, until test first fails to give True. Example: Define a Function f[x] f[x_] := (x^2 -1)/(x+1) Use the function in a while loop to calculate the sum of those terms. i=0; While[i < 0, tot += f[i]; i++]. Note that the roles of ; and , are reversed relative to the C programming language.