Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #587 from nyalldawson/new_functions
New functions
- Loading branch information
Showing
15 changed files
with
355 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<h3>abs() function</h3> | ||
Returns the absolute value of a number.<br> | ||
|
||
|
||
<h4>Syntax</h4> | ||
abs(<i>value</i>)<br> | ||
|
||
<h4>Arguments</h4> | ||
<code>value</code> - a number.<br> | ||
|
||
<h4>Example</h4> | ||
<code>abs(-2) → 2</code><br> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<h3>Function ceil()</h3> | ||
Rounds a number upwards. | ||
|
||
<h4>Syntax</h4> | ||
<code>ceil(value)</code><br> | ||
|
||
<h4>Arguments</h4> | ||
<code>value</code> - a number. | ||
<br> | ||
|
||
<h4>Example</h4> | ||
<!-- Show example of function.--> | ||
<code>ceil(4.9) → 5</code><br> | ||
<code>ceil(-4.9) → -4</code><br> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<h3>Function floor()</h3> | ||
Rounds a number downwards. | ||
|
||
<h4>Syntax</h4> | ||
<code>floor(value)</code><br> | ||
|
||
<h4>Arguments</h4> | ||
<code>value</code> - a number. | ||
<br> | ||
|
||
<h4>Example</h4> | ||
<!-- Show example of function.--> | ||
<code>floor(4.9) → 4</code><br> | ||
<code>floor(-4.9) → -5</code><br> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<h3>max() function</h3> | ||
Returns the largest value in a set of values. | ||
|
||
<h4>Syntax</h4> | ||
max(<i>value<i>[,<i>value</i>...]) | ||
|
||
<h4>Arguments</h4> | ||
<!-- List args for functions here--> | ||
<i> value</i> → a number.<br> | ||
|
||
<h4>Example</h4> | ||
<!-- Show example of function.--> | ||
max(2,10.2,5.5) → 10.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<h3>min() function</h3> | ||
Returns the smallest value in a set of values. | ||
|
||
<h4>Syntax</h4> | ||
min(<i>value<i>[,<i>value</i>...]) | ||
|
||
<h4>Arguments</h4> | ||
<!-- List args for functions here--> | ||
<i> value</i> → a number.<br> | ||
|
||
<h4>Example</h4> | ||
<!-- Show example of function.--> | ||
min(20.5,10,6.2) → 6.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<h3>rand() function</h3> | ||
Returns a random integer within the range specified by the minimum and | ||
maximum argument (inclusive). | ||
<br> | ||
This function takes two arguments. | ||
<h4>Syntax</h4> | ||
<code>rand(min, max)</code><br> | ||
|
||
<h4>Arguments</h4> | ||
<code>min</code> - an integer representing the smallest possible random number desired.<br> | ||
<code>max</code> - an integer representing the largest possible random number desired. | ||
<br> | ||
|
||
<h4>Example</h4> | ||
<!-- Show example of function.--> | ||
<code>rand(1, 10) → 8</code><br> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<h3>rand() function</h3> | ||
Returns a random float within the range specified by the minimum and | ||
maximum argument (inclusive). | ||
<br> | ||
This function takes two arguments. | ||
<h4>Syntax</h4> | ||
<code>randf(min, max)</code><br> | ||
|
||
<h4>Arguments</h4> | ||
<code>min</code> - a float representing the smallest possible random number desired.<br> | ||
<code>max</code> - a float representing the largest possible random number desired. | ||
<br> | ||
|
||
<h4>Example</h4> | ||
<!-- Show example of function.--> | ||
<code>randf(1, 10) → 4.59258286403147</code><br> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<h3>regexp_substr() function</h3> | ||
Returns the portion of a string which matches a supplied regular expression. | ||
|
||
<p><h4>Syntax</h4> | ||
regexp_substr(<i>string,regex</i>)</p> | ||
|
||
<p><h4>Arguments</h4> | ||
<!-- List args for functions here--> | ||
<i> string</i> → is string. The input string.<br> | ||
<i> regex</i> → is string. The regular expression to match against. Backslash characters must be double escaped (eg "\\s" to match a white space character).<br> | ||
|
||
<p><h4>Example</h4> | ||
<!-- Show example of function.--> | ||
regexp_substr('abc123','(\\d+)') → '123'</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<h3>scale_linear() function</h3> | ||
Transforms a given value from an input domain to an output range using linear interpolation. | ||
|
||
<p><h4>Syntax</h4> | ||
scale_linear(<i>val</i>,<i>domain_min</i>,<i>domain_max</i>,<i>range_min</i>,<i>range_max</i>)</p> | ||
|
||
<p><h4>Arguments</h4> | ||
<!-- List args for functions here--> | ||
<i> val</i> → is a value in the input domain. The function will return a corresponding scaled value in the output range.<br> | ||
<i> domain_min, domain_max</i> → specify the input domain, the smallest and largest values the input <i>val</i> should take.<br> | ||
<i> range_min, range_max</i> → sepcify the output range, the smallest and largest values which should be output by the function.<br> | ||
|
||
<h4>Example</h4> | ||
<!-- Show example of function.--> | ||
scale_linear(5,0,10,0,100) → 50<br> | ||
scale_linear(0.2,0,1,0,360) → 72 <i>(eg, scaling a value between 0 and 1 to an angle between 0 and 360)</i><br> | ||
scale_linear(1500,1000,10000,9,20) → 10.22 <i>(eg, scaling a population which varies between 1000 and 10000 to a font size between 9 and 20)</i><br> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<h3>trim() function</h3> | ||
Removes all leading and trailing whitespace (spaces, tabs, etc) from a string. | ||
|
||
<p><h4>Syntax</h4> | ||
trim(<i>string</i>)</p> | ||
|
||
<p><h4>Arguments</h4> | ||
<!-- List args for functions here--> | ||
<i> string</i> → is string. The string to trim.</p> | ||
|
||
<p><h4>Example</h4> | ||
<!-- Show example of function.--> | ||
trim(' hello world ') → 'hello world'</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.