mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
Fixed Looping Helpers docs formatting.
This commit is contained in:
parent
0cd34406a3
commit
8b922f7a15
2 changed files with 5 additions and 2 deletions
|
@ -460,18 +460,20 @@ module shape_compare(eps=1/1024) {
|
||||||
|
|
||||||
// Section: Looping Helpers
|
// Section: Looping Helpers
|
||||||
// You can use a list comprehension with a C-style for loop to iteratively make a calculation.
|
// You can use a list comprehension with a C-style for loop to iteratively make a calculation.
|
||||||
|
// .
|
||||||
// The syntax is: `[for (INIT; CONDITION; NEXT) RETVAL]` where:
|
// The syntax is: `[for (INIT; CONDITION; NEXT) RETVAL]` where:
|
||||||
// - INIT is zero or more `let()` style assignments that are evaluated exactly one time, before the first loop.
|
// - INIT is zero or more `let()` style assignments that are evaluated exactly one time, before the first loop.
|
||||||
// - CONDITION is an expression evaluated at the start of each loop. If true, continues with the loop.
|
// - CONDITION is an expression evaluated at the start of each loop. If true, continues with the loop.
|
||||||
// - RETVAL is an expression that returns a list item for each loop.
|
// - RETVAL is an expression that returns a list item for each loop.
|
||||||
// - NEXT is one or more `let()` style assignments that is evaluated at the end of each loop.
|
// - NEXT is one or more `let()` style assignments that is evaluated at the end of each loop.
|
||||||
|
// .
|
||||||
// Since the INIT phase is only run once, and the CONDITION and RETVAL expressions cannot update
|
// Since the INIT phase is only run once, and the CONDITION and RETVAL expressions cannot update
|
||||||
// variables, that means that only the NEXT phase can be used for iterative calculations.
|
// variables, that means that only the NEXT phase can be used for iterative calculations.
|
||||||
// Unfortunately, the NEXT phase runs *after* the RETVAL expression, which means that you need
|
// Unfortunately, the NEXT phase runs *after* the RETVAL expression, which means that you need
|
||||||
// to run the loop one extra time to return the final value. This tends to make the loop code
|
// to run the loop one extra time to return the final value. This tends to make the loop code
|
||||||
// look rather ugly. The `looping()`, `loop_next()` and `loop_done()` functions
|
// look rather ugly. The `looping()`, `loop_next()` and `loop_done()` functions
|
||||||
// can make this somewhat more legible.
|
// can make this somewhat more legible.
|
||||||
// Example(NORENDER):
|
// ```openscad
|
||||||
// function flat_sum(l) = [
|
// function flat_sum(l) = [
|
||||||
// for (
|
// for (
|
||||||
// i = 0,
|
// i = 0,
|
||||||
|
@ -488,6 +490,7 @@ module shape_compare(eps=1/1024) {
|
||||||
// i = i + 1
|
// i = i + 1
|
||||||
// ) if (loop_done(state)) total;
|
// ) if (loop_done(state)) total;
|
||||||
// ].x;
|
// ].x;
|
||||||
|
// ```
|
||||||
|
|
||||||
|
|
||||||
// Function: looping()
|
// Function: looping()
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,441];
|
BOSL_VERSION = [2,0,442];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
|
Loading…
Reference in a new issue