Post Reply 
Plus42 Equations, Preview Release
11-22-2021, 01:42 AM (This post was last modified: 11-22-2021 01:46 AM by Thomas Okken.)
Post: #12
RE: Plus42 Equations, Preview Release
New build uploaded, with a new FOR loop: FOR(init:cond:next:expr-list)
It evaluates 'init' once, at the beginning; then checks 'cond' before entering the body of the loop, exiting if 'cond' evaluates to 'false'; then performs the loop body, consisting of 'expr-list', i.e. one or more expressions; and performs 'next' at the end of each loop.

'expr-list' may be one or more expressions. The return value of the loop is the value returned by the last loop body expression executed, or the value returned by 'init' if the loop body is executed zero times.

All four parameters to FOR are required. If you are looking for a no-op to use in the place of 'init', 'next', or 'expr-list', just use a constant, say, 0; if you want 'cond' to always succeed, use something like 1=1, or 1=2 if you always want it to fail. The latter isn't very useful since you could achieve the same effect using simply 'init' on its own.

Special expressions BREAK and CONTINUE are available and do what you'll probably expect. The whole thing is designed to be similar to the C for loop.

Also: added SEQ(expr-list). Allows executing multiple expressions in places where normally only one would be allowed. The return value of SEQ is the value returned by the last expression in the list. In other words, similar to the C comma operator.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Plus42 Equations, Preview Release - Thomas Okken - 11-22-2021 01:42 AM



User(s) browsing this thread: 1 Guest(s)