User Tools

Site Tools


en:cachevariables

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
en:cachevariables [2022/11/25 11:53] – [Functions] Add TRUNC function lineflyeren:cachevariables [2022/11/25 11:58] (current) – [Range expressions] New syntax for range expressions lineflyer
Line 187: Line 187:
 ==== Range expressions ==== ==== Range expressions ====
  
-You can specify ranges in formulas using ''[]''. This is needed when variables are used in a context where a range of values should be iterated over. A prominent example is the [[.:waypointcalculator|Generate Waypoints]] function.+You can specify ranges in formulas using ''[:]''. This is needed when variables are used in a context where a range of values should be iterated over. A prominent example is the [[.:waypointcalculator|Generate Waypoints]] function.
  
 **FIXME** Link to anchor on waypoint calc page as soon as its updated to cover waypoint generation with ranges. **FIXME** Link to anchor on waypoint calc page as soon as its updated to cover waypoint generation with ranges.
  
-An example for a range expression is ''[0-9]''. This specifies a range with 10 values (the integer values 0 to 9).+An example for a range expression is ''[:0-9]''. This specifies a range with 10 values (the integer values 0 to 9).
  
 You may specify consecutive values using '','' as a delimiter. You may exclude values or value ranges by prepending a ''^'' to it. Ranges are parsed from left-to-right, giving an order to the elements in the range. For example the following are valid range specifications: You may specify consecutive values using '','' as a delimiter. You may exclude values or value ranges by prepending a ''^'' to it. Ranges are parsed from left-to-right, giving an order to the elements in the range. For example the following are valid range specifications:
-  * ''[0-2, 4]'' evaluates to a range containing ''0'', ''1'', ''2'' and ''4''+  * ''[:0-2, 4]'' evaluates to a range containing ''0'', ''1'', ''2'' and ''4''
-  * ''[0-3, ^1-2]'' evaluates to a range containing ''0'' and ''3''+  * ''[:0-3, ^1-2]'' evaluates to a range containing ''0'' and ''3''
-  * ''[0-3, ^1-2, 5]'' evaluates to a range containing ''0'', ''3'' and ''5''.+  * ''[:0-3, ^1-2, 5]'' evaluates to a range containing ''0'', ''3'' and ''5''.
  
-When a range is used in a context where only one value is allowed (this is the case in normal calculation), the first range value is used for calculation. For example, the expression ''[0-9]'' will evalulate to ''0'' in a normal calculation context, while ''[8, 0-9]'' will evalulate to ''8''.+When a range is used in a context where only one value is allowed (this is the case in normal calculation), the first range value is used for calculation. For example, the expression ''[:0-9]'' will evaluate to ''0'' in a normal calculation context, while ''[:8, 0-9]'' will evaluate to ''8''.
  
 Ranges currently support only positive constant integer values. A range must always be evaluate to at least 1 value and a range may not evaluate to more than 20 values. For example the following ranges are invalid: Ranges currently support only positive constant integer values. A range must always be evaluate to at least 1 value and a range may not evaluate to more than 20 values. For example the following ranges are invalid:
-  * ''[]'': empty +  * ''[:]'': empty 
-  * ''[5, ^0-9]'': evaluates to empty +  * ''[:5, ^0-9]'': evaluates to empty 
-  * ''[0-1000]'': evaluates to more than 20 entries +  * ''[:0-1000]'': evaluates to more than 20 entries 
-  * ''[-5]'': negative int not allowed +  * ''[:-5]'': negative int not allowed 
-  * ''[A]'': variables not allowed+  * ''[:A]'': variables not allowed
  
 A formula may include one or more range definitions mixed with normal other formula parts. For example the following formulas are valid: A formula may include one or more range definitions mixed with normal other formula parts. For example the following formulas are valid:
-  * ''3*[0-2]'': evaluates to values ''0'', ''3'' and ''6'' +  * ''3*[:0-2]'': evaluates to values ''0'', ''3'' and ''6'' 
-  * ''A*[4, 7]'': for ''A=3'' this evaluates to values ''12'' and ''21'' +  * ''A*[:4, 7]'': for ''A=3'' this evaluates to values ''12'' and ''21'' 
-  * ''[1-2]*[3-4]'': evaluates to ''3'', ''6'', ''4'' and ''8''.+  * ''[:1-2]*[:3-4]'': evaluates to ''3'', ''6'', ''4'' and ''8''.
  
  
en/cachevariables.txt · Last modified: 2022/11/25 11:58 by lineflyer