diff options
Diffstat (limited to 'doc/index.html')
-rw-r--r-- | doc/index.html | 4197 |
1 files changed, 2843 insertions, 1354 deletions
diff --git a/doc/index.html b/doc/index.html index bace80a..6d0263e 100644 --- a/doc/index.html +++ b/doc/index.html @@ -4,7 +4,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <head> <title>Moses documentation</title> - <link rel="stylesheet" href="ldoc.css" type="text/css" /> + <link rel="stylesheet" href="ldoc_fixed.css" type="text/css" /> </head> <body> @@ -29,6 +29,7 @@ <h2>Contents</h2> <ul> +<li><a href="#Operator_functions">Operator functions </a></li> <li><a href="#Table_functions">Table functions </a></li> <li><a href="#Array_functions">Array functions </a></li> <li><a href="#Utility_functions">Utility functions </a></li> @@ -40,9 +41,9 @@ <ul class="nowrap"> <li><strong>moses</strong></li> </ul> -<h2>Topics</h2> -<ul class=""> - <li><a href="topics/tutorial.md.html">tutorial</a></li> +<h2>Manual</h2> +<ul class="nowrap"> + <li><a href="manual/tutorial.md.html">tutorial</a></li> </ul> </div> @@ -52,105 +53,177 @@ <h1>Module <code>moses</code></h1> <p>Utility-belt library for functional programming in Lua (<a href="http://github.com/Yonaba/Moses">source</a>)</p> <p> + </p> <h3>Info:</h3> <ul> - <li><strong>Copyright</strong>: 2012-2017</li> - <li><strong>Release</strong>: 1.6.1</li> + <li><strong>Copyright</strong>: 2012-2018</li> + <li><strong>Release</strong>: 2.0.0</li> <li><strong>License</strong>: <a href="http://www.opensource.org/licenses/mit-license.php">MIT</a></li> <li><strong>Author</strong>: <a href="http://github.com/Yonaba">Roland Yonaba</a></li> </ul> -<h2><a href="#Table_functions">Table functions </a></h2> +<h2><a href="#Operator_functions">Operator functions </a></h2> <table class="function_list"> <tr> - <td class="name" nowrap><a href="#clear">clear (t)</a></td> - <td class="summary">Clears a table.</td> + <td class="name" nowrap><a href="#operator.add">operator.add (a, b)</a></td> + <td class="summary">Returns a + b.</td> </tr> <tr> - <td class="name" nowrap><a href="#each">each (t, f[, ...])</a></td> - <td class="summary">Iterates on key-value pairs, calling <code>f (k, v)</code> at every step.</td> + <td class="name" nowrap><a href="#operator.concat">operator.concat (a, b)</a></td> + <td class="summary">Returns concatenation of a and b.</td> </tr> <tr> - <td class="name" nowrap><a href="#eachi">eachi (t, f[, ...])</a></td> - <td class="summary">Iterates on integer key-value pairs, calling <code>f(k, v)</code> every step.</td> + <td class="name" nowrap><a href="#operator.div">operator.div (a, b)</a></td> + <td class="summary">Returns a / b.</td> </tr> <tr> - <td class="name" nowrap><a href="#at">at (t, ...)</a></td> - <td class="summary">Collects values at given keys and return them wrapped in an array.</td> + <td class="name" nowrap><a href="#operator.eq">operator.eq (a, b)</a></td> + <td class="summary">Checks if a equals b.</td> </tr> <tr> - <td class="name" nowrap><a href="#count">count (t[, value])</a></td> - <td class="summary">Counts occurrences of a given value in a table.</td> + <td class="name" nowrap><a href="#operator.exp">operator.exp (a, b)</a></td> + <td class="summary">Returns a ^ b.</td> </tr> <tr> - <td class="name" nowrap><a href="#countf">countf (t, f[, ...])</a></td> - <td class="summary">Counts occurrences validating a predicate.</td> + <td class="name" nowrap><a href="#operator.floordiv">operator.floordiv (a, b)</a></td> + <td class="summary">Performs floor division (//) between <code>a</code> and <code>b</code>.</td> </tr> <tr> - <td class="name" nowrap><a href="#cycle">cycle (t, n)</a></td> - <td class="summary">Loops <code>n</code> times through a table.</td> + <td class="name" nowrap><a href="#operator.ge">operator.ge (a, b)</a></td> + <td class="summary">Returns logical a and b.</td> </tr> <tr> - <td class="name" nowrap><a href="#map">map (t, f[, ...])</a></td> - <td class="summary">Maps <code>f (k, v)</code> on key-value pairs, collects and returns the results.</td> + <td class="name" nowrap><a href="#operator.ge">operator.ge (a, b)</a></td> + <td class="summary">Checks if a is greater or equal to b.</td> </tr> <tr> - <td class="name" nowrap><a href="#reduce">reduce (t, f[, state])</a></td> - <td class="summary">Reduces a table, left-to-right.</td> + <td class="name" nowrap><a href="#operator.gt">operator.gt (a, b)</a></td> + <td class="summary">Checks if a is strictly greater than b.</td> </tr> <tr> - <td class="name" nowrap><a href="#reduceby">reduceby (t, f, state, pred[, ...])</a></td> - <td class="summary">Reduces values in a table passing a given predicate.</td> + <td class="name" nowrap><a href="#operator.intdiv">operator.intdiv (a, b)</a></td> + <td class="summary">Performs integer division between <code>a</code> and <code>b</code>.</td> </tr> <tr> - <td class="name" nowrap><a href="#reduceRight">reduceRight (t, f[, state])</a></td> - <td class="summary">Reduces a table, right-to-left.</td> + <td class="name" nowrap><a href="#operator.le">operator.le (a, b)</a></td> + <td class="summary">Checks if a is less or equal to b.</td> </tr> <tr> - <td class="name" nowrap><a href="#mapReduce">mapReduce (t, f[, state])</a></td> - <td class="summary">Reduces a table while saving intermediate states.</td> + <td class="name" nowrap><a href="#operator.length">operator.length (a)</a></td> + <td class="summary">Returns the length of a.</td> </tr> <tr> - <td class="name" nowrap><a href="#mapReduceRight">mapReduceRight (t, f[, state])</a></td> - <td class="summary">Reduces a table while saving intermediate states.</td> + <td class="name" nowrap><a href="#operator.lnot">operator.lnot (a)</a></td> + <td class="summary">Returns logical not a.</td> </tr> <tr> - <td class="name" nowrap><a href="#include">include (t, value)</a></td> - <td class="summary">Performs a linear search for a value in a table.</td> + <td class="name" nowrap><a href="#operator.lor">operator.lor (a, b)</a></td> + <td class="summary">Returns logical a or b.</td> </tr> <tr> - <td class="name" nowrap><a href="#detect">detect (t, value)</a></td> - <td class="summary">Performs a linear search for a value in a table.</td> + <td class="name" nowrap><a href="#operator.lt">operator.lt (a, b)</a></td> + <td class="summary">Checks if a is strictly less than b.</td> </tr> <tr> - <td class="name" nowrap><a href="#where">where (t, props)</a></td> - <td class="summary">Returns all values having specified keys <code>props</code>.</td> + <td class="name" nowrap><a href="#operator.mod">operator.mod (a, b)</a></td> + <td class="summary">Returns a % b.</td> </tr> <tr> - <td class="name" nowrap><a href="#findWhere">findWhere (t, props)</a></td> - <td class="summary">Returns the first value having specified keys <code>props</code>.</td> + <td class="name" nowrap><a href="#operator.mul">operator.mul (a, b)</a></td> + <td class="summary">Returns a * b.</td> </tr> <tr> - <td class="name" nowrap><a href="#select">select (t, f[, ...])</a></td> - <td class="summary">Selects and returns values passing an iterator test.</td> + <td class="name" nowrap><a href="#operator.neq">operator.neq (a, b)</a></td> + <td class="summary">Checks if a not equals b.</td> </tr> <tr> - <td class="name" nowrap><a href="#reject">reject (t, f[, ...])</a></td> - <td class="summary">Clones a table while dropping values passing an iterator test.</td> + <td class="name" nowrap><a href="#operator.sub">operator.sub (a, b)</a></td> + <td class="summary">Returns a - b.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#operator.unm">operator.unm (a)</a></td> + <td class="summary">Returns -a.</td> + </tr> +</table> +<h2><a href="#Table_functions">Table functions </a></h2> +<table class="function_list"> + <tr> + <td class="name" nowrap><a href="#adjust">adjust (t, key, f[, ...])</a></td> + <td class="summary">Adjusts the value at a given key using a function or a value.</td> </tr> <tr> <td class="name" nowrap><a href="#all">all (t, f[, ...])</a></td> <td class="summary">Checks if all values in a table are passing an iterator test.</td> </tr> <tr> + <td class="name" nowrap><a href="#at">at (t, ...)</a></td> + <td class="summary">Collects values at given keys and return them wrapped in an array.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#clear">clear (t)</a></td> + <td class="summary">Clears a table.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#containsKeys">containsKeys (t, other)</a></td> + <td class="summary">Checks if all the keys of <code>other</code> table exists in table <code>t</code>.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#count">count (t[, val])</a></td> + <td class="summary">Counts occurrences of a given value in a table.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#countBy">countBy (t, iter[, ...])</a></td> + <td class="summary">Groups values in a collection and counts them.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#countf">countf (t, f[, ...])</a></td> + <td class="summary">Counts the number of values passing a predicate test.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#cycle">cycle (t[, n])</a></td> + <td class="summary">Loops <code>n</code> times through a table.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#detect">detect (t, value)</a></td> + <td class="summary">Performs a linear search for a value in a table.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#each">each (t, f[, ...])</a></td> + <td class="summary">Iterates on key-value pairs, calling <code>f (v, k)</code> at every step.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#eachi">eachi (t, f[, ...])</a></td> + <td class="summary">Iterates on integer key-value pairs, calling <code>f(v, k)</code> every step.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#findWhere">findWhere (t, props)</a></td> + <td class="summary">Returns the first value having specified keys <code>props</code>.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#groupBy">groupBy (t, iter[, ...])</a></td> + <td class="summary">Splits a table into subsets groups.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#include">include (t, value)</a></td> + <td class="summary">Performs a linear search for a value in a table.</td> + </tr> + <tr> <td class="name" nowrap><a href="#invoke">invoke (t, method[, ...])</a></td> <td class="summary">Invokes a method on each value in a table.</td> </tr> <tr> - <td class="name" nowrap><a href="#pluck">pluck (t, key)</a></td> - <td class="summary">Extracts values in a table having a given key.</td> + <td class="name" nowrap><a href="#map">map (t, f[, ...])</a></td> + <td class="summary">Maps <code>f (v, k)</code> on value-key pairs, collects and returns the results.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#mapReduce">mapReduce (t, f[, state])</a></td> + <td class="summary">Reduces a table while saving intermediate states.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#mapReduceRight">mapReduceRight (t, f[, state])</a></td> + <td class="summary">Reduces a table while saving intermediate states.</td> </tr> <tr> <td class="name" nowrap><a href="#max">max (t[, transform[, ...]])</a></td> @@ -161,87 +234,95 @@ <td class="summary">Returns the min value in a collection.</td> </tr> <tr> - <td class="name" nowrap><a href="#shuffle">shuffle (t[, seed])</a></td> - <td class="summary">Returns a shuffled copy of a given collection.</td> + <td class="name" nowrap><a href="#pluck">pluck (t, key)</a></td> + <td class="summary">Extracts values in a table having a given key.</td> </tr> <tr> - <td class="name" nowrap><a href="#same">same (a, b)</a></td> - <td class="summary">Checks if two tables are the same.</td> + <td class="name" nowrap><a href="#reduce">reduce (t, f[, state])</a></td> + <td class="summary">Reduces a table, left-to-right.</td> </tr> <tr> - <td class="name" nowrap><a href="#sort">sort (t[, comp])</a></td> - <td class="summary">Sorts a table, in-place.</td> + <td class="name" nowrap><a href="#reduceRight">reduceRight (t, f[, state])</a></td> + <td class="summary">Reduces a table, right-to-left.</td> </tr> <tr> - <td class="name" nowrap><a href="#sortBy">sortBy (t[, transform[, comp]])</a></td> - <td class="summary">Sorts a table in-place using a transform.</td> + <td class="name" nowrap><a href="#reduceby">reduceby (t, f, pred[, state[, ...]])</a></td> + <td class="summary">Reduces values in a table passing a given predicate.</td> </tr> <tr> - <td class="name" nowrap><a href="#groupBy">groupBy (t, iter[, ...])</a></td> - <td class="summary">Splits a table into subsets groups.</td> + <td class="name" nowrap><a href="#reject">reject (t, f[, ...])</a></td> + <td class="summary">Clones a table while dropping values passing an iterator test.</td> </tr> <tr> - <td class="name" nowrap><a href="#countBy">countBy (t, iter[, ...])</a></td> - <td class="summary">Groups values in a collection and counts them.</td> + <td class="name" nowrap><a href="#same">same (a, b)</a></td> + <td class="summary">Checks if two tables are the same.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#sameKeys">sameKeys (tA, tB)</a></td> + <td class="summary">Checks if both given tables have the same keys.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#select">select (t, f[, ...])</a></td> + <td class="summary">Selects and returns values passing an iterator test.</td> </tr> <tr> <td class="name" nowrap><a href="#size">size ([...])</a></td> <td class="summary">Counts the number of values in a collection.</td> </tr> <tr> - <td class="name" nowrap><a href="#containsKeys">containsKeys (t, other)</a></td> - <td class="summary">Checks if all the keys of <code>other</code> table exists in table <code>t</code>.</td> + <td class="name" nowrap><a href="#sort">sort (t[, comp])</a></td> + <td class="summary">Sorts a table, in-place.</td> </tr> <tr> - <td class="name" nowrap><a href="#sameKeys">sameKeys (tA, tB)</a></td> - <td class="summary">Checks if both given tables have the same keys.</td> + <td class="name" nowrap><a href="#sortBy">sortBy (t[, transform[, comp]])</a></td> + <td class="summary">Sorts a table in-place using a transform.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#where">where (t, props)</a></td> + <td class="summary">Returns all values having specified keys <code>props</code>.</td> </tr> </table> <h2><a href="#Array_functions">Array functions </a></h2> <table class="function_list"> <tr> - <td class="name" nowrap><a href="#sample">sample (array[, n[, seed]])</a></td> - <td class="summary">Samples <code>n</code> random values from an array.</td> + <td class="name" nowrap><a href="#addTop">addTop (array, ...)</a></td> + <td class="summary">Adds all passed-in values at the top of an array.</td> </tr> <tr> - <td class="name" nowrap><a href="#sampleProb">sampleProb (array, prob[, seed])</a></td> - <td class="summary">Return elements from a sequence with a given probability.</td> + <td class="name" nowrap><a href="#aperture">aperture (array[, n])</a></td> + <td class="summary">Iterator returning sliding partitions of an array.</td> </tr> <tr> - <td class="name" nowrap><a href="#toArray">toArray (...)</a></td> - <td class="summary">Converts a list of arguments to an array.</td> + <td class="name" nowrap><a href="#append">append (array, other)</a></td> + <td class="summary">Clones array and appends values from another array.</td> </tr> <tr> - <td class="name" nowrap><a href="#find">find (array, value[, from])</a></td> - <td class="summary">Looks for the first occurrence of a given value in an array.</td> + <td class="name" nowrap><a href="#chunk">chunk (array, f[, ...])</a></td> + <td class="summary">Chunks together consecutive values.</td> </tr> <tr> - <td class="name" nowrap><a href="#reverse">reverse (array)</a></td> - <td class="summary">Returns an array where values are in reverse order.</td> + <td class="name" nowrap><a href="#compact">compact (array)</a></td> + <td class="summary">Returns all truthy values (removes <code>falses</code> and <code>nils</code>).</td> </tr> <tr> - <td class="name" nowrap><a href="#fill">fill (array, value[, i[, j]])</a></td> - <td class="summary">Replaces elements in a given array with a given value.</td> + <td class="name" nowrap><a href="#concat">concat (array[, sep[, i[, j]]])</a></td> + <td class="summary">Concatenates values in a given array.</td> </tr> <tr> - <td class="name" nowrap><a href="#selectWhile">selectWhile (array, f[, ...])</a></td> - <td class="summary">Collects values from a given array.</td> + <td class="name" nowrap><a href="#difference">difference (array, another)</a></td> + <td class="summary">Returns values from an array not present in all passed-in args.</td> </tr> <tr> <td class="name" nowrap><a href="#dropWhile">dropWhile (array, f[, ...])</a></td> <td class="summary">Collects values from a given array.</td> </tr> <tr> - <td class="name" nowrap><a href="#sortedIndex">sortedIndex (array, the[, comp[, sort]])</a></td> - <td class="summary">Returns the index at which a value should be inserted.</td> - </tr> - <tr> - <td class="name" nowrap><a href="#indexOf">indexOf (array, value)</a></td> - <td class="summary">Returns the index of the first occurence of value in an array.</td> + <td class="name" nowrap><a href="#fill">fill (array, value[, i[, j]])</a></td> + <td class="summary">Replaces elements in a given array with a given value.</td> </tr> <tr> - <td class="name" nowrap><a href="#lastIndexOf">lastIndexOf (array, value)</a></td> - <td class="summary">Returns the index of the last occurrence of value in an array.</td> + <td class="name" nowrap><a href="#find">find (array, value[, from])</a></td> + <td class="summary">Looks for the first occurrence of a given value in an array.</td> </tr> <tr> <td class="name" nowrap><a href="#findIndex">findIndex (array, predicate[, ...])</a></td> @@ -252,187 +333,215 @@ <td class="summary">Returns the last index at which a predicate returns true.</td> </tr> <tr> - <td class="name" nowrap><a href="#addTop">addTop (array, ...)</a></td> - <td class="summary">Adds all passed-in values at the top of an array.</td> - </tr> - <tr> - <td class="name" nowrap><a href="#push">push (array, ...)</a></td> - <td class="summary">Pushes all passed-in values at the end of an array.</td> + <td class="name" nowrap><a href="#first">first (array[, n])</a></td> + <td class="summary">Returns the first N values in an array.</td> </tr> <tr> - <td class="name" nowrap><a href="#pop">pop (array[, n])</a></td> - <td class="summary">Removes and returns the values at the top of a given array.</td> + <td class="name" nowrap><a href="#flatten">flatten (array[, shallow])</a></td> + <td class="summary">Flattens a nested array.</td> </tr> <tr> - <td class="name" nowrap><a href="#unshift">unshift (array[, n])</a></td> - <td class="summary">Removes and returns the values at the end of a given array.</td> + <td class="name" nowrap><a href="#indexOf">indexOf (array, value)</a></td> + <td class="summary">Returns the index of the first occurrence of value in an array.</td> </tr> <tr> - <td class="name" nowrap><a href="#pull">pull (array, ...)</a></td> - <td class="summary">Removes all provided values in a given array.</td> + <td class="name" nowrap><a href="#initial">initial (array[, n])</a></td> + <td class="summary">Returns all values in an array excluding the last N values.</td> </tr> <tr> - <td class="name" nowrap><a href="#removeRange">removeRange (array[, start[, finish]])</a></td> - <td class="summary">Removes values at index within the range <code>[start, finish]</code>.</td> + <td class="name" nowrap><a href="#interleave">interleave (...)</a></td> + <td class="summary">Interleaves arrays.</td> </tr> <tr> - <td class="name" nowrap><a href="#chunk">chunk (array, f[, ...])</a></td> - <td class="summary">Chunks together consecutive values.</td> + <td class="name" nowrap><a href="#interpose">interpose (array, value)</a></td> + <td class="summary">Interposes value in-between consecutive pair of values in array.</td> </tr> <tr> - <td class="name" nowrap><a href="#slice">slice (array[, start[, finish]])</a></td> - <td class="summary">Slices values indexed within <code>[start, finish]</code> range.</td> + <td class="name" nowrap><a href="#intersection">intersection (array, ...)</a></td> + <td class="summary">Returns the intersection of all passed-in arrays.</td> </tr> <tr> - <td class="name" nowrap><a href="#first">first (array[, n])</a></td> - <td class="summary">Returns the first N values in an array.</td> + <td class="name" nowrap><a href="#invert">invert (array)</a></td> + <td class="summary">Swaps keys with values.</td> </tr> <tr> - <td class="name" nowrap><a href="#initial">initial (array[, n])</a></td> - <td class="summary">Returns all values in an array excluding the last N values.</td> + <td class="name" nowrap><a href="#isunique">isunique (array)</a></td> + <td class="summary">Checks if a given array contains distinct values.</td> </tr> <tr> <td class="name" nowrap><a href="#last">last (array[, n])</a></td> <td class="summary">Returns the last N values in an array.</td> </tr> <tr> - <td class="name" nowrap><a href="#rest">rest (array[, index])</a></td> - <td class="summary">Removes all values before index.</td> + <td class="name" nowrap><a href="#lastIndexOf">lastIndexOf (array, value)</a></td> + <td class="summary">Returns the index of the last occurrence of value in an array.</td> </tr> <tr> - <td class="name" nowrap><a href="#nth">nth (array, index)</a></td> - <td class="summary">Returns the value at a given index.</td> + <td class="name" nowrap><a href="#mean">mean (array)</a></td> + <td class="summary">Returns the mean of an array of numbers.</td> </tr> <tr> - <td class="name" nowrap><a href="#compact">compact (array)</a></td> - <td class="summary">Removes all falsy (false and nil) values.</td> + <td class="name" nowrap><a href="#median">median (array)</a></td> + <td class="summary">Returns the median of an array of numbers.</td> </tr> <tr> - <td class="name" nowrap><a href="#flatten">flatten (array[, shallow])</a></td> - <td class="summary">Flattens a nested array.</td> + <td class="name" nowrap><a href="#nth">nth (array, index)</a></td> + <td class="summary">Returns the value at a given index.</td> </tr> <tr> - <td class="name" nowrap><a href="#difference">difference (array, another)</a></td> - <td class="summary">Returns values from an array not present in all passed-in args.</td> + <td class="name" nowrap><a href="#ones">ones (n)</a></td> + <td class="summary">Returns an array of <code>n</code> 1's.</td> </tr> <tr> - <td class="name" nowrap><a href="#union">union (...)</a></td> - <td class="summary">Returns the duplicate-free union of all passed in arrays.</td> + <td class="name" nowrap><a href="#overlapping">overlapping (array[, n[, pads]])</a></td> + <td class="summary">Iterator returning overlapping partitions of an array.</td> </tr> <tr> - <td class="name" nowrap><a href="#intersection">intersection (array, ...)</a></td> - <td class="summary">Returns the intersection of all passed-in arrays.</td> + <td class="name" nowrap><a href="#pairwise">pairwise (array)</a></td> + <td class="summary">Iterator returning sliding pairs of an array.</td> </tr> <tr> - <td class="name" nowrap><a href="#symmetricDifference">symmetricDifference (array, array2)</a></td> - <td class="summary">Performs a symmetric difference.</td> + <td class="name" nowrap><a href="#partition">partition (array[, n[, pads]])</a></td> + <td class="summary">Iterator returning partitions of an array.</td> </tr> <tr> - <td class="name" nowrap><a href="#unique">unique (array)</a></td> - <td class="summary">Produces a duplicate-free version of a given array.</td> + <td class="name" nowrap><a href="#permutation">permutation (array)</a></td> + <td class="summary">Iterator returning the permutations of an array.</td> </tr> <tr> - <td class="name" nowrap><a href="#isunique">isunique (array)</a></td> - <td class="summary">Checks if a given array contains distinct values.</td> + <td class="name" nowrap><a href="#powerset">powerset (array)</a></td> + <td class="summary">Returns the powerset of array values.</td> </tr> <tr> - <td class="name" nowrap><a href="#zip">zip (...)</a></td> - <td class="summary">Merges values of each of the passed-in arrays in subsets.</td> + <td class="name" nowrap><a href="#prepend">prepend (array, ...)</a></td> + <td class="summary">Adds all passed-in values at the top of an array.</td> </tr> <tr> - <td class="name" nowrap><a href="#append">append (array, other)</a></td> - <td class="summary">Clones <a href="index.html#array">array</a> and appends <code>other</code> values.</td> + <td class="name" nowrap><a href="#product">product (array)</a></td> + <td class="summary">Returns the product of array values.</td> </tr> <tr> - <td class="name" nowrap><a href="#interleave">interleave (...)</a></td> - <td class="summary">Interleaves arrays.</td> + <td class="name" nowrap><a href="#pull">pull (array, ...)</a></td> + <td class="summary">Removes all provided values in a given array.</td> </tr> <tr> - <td class="name" nowrap><a href="#interpose">interpose (value, array)</a></td> - <td class="summary">Interposes value in-between consecutive pair of values in <a href="index.html#array">array</a>.</td> + <td class="name" nowrap><a href="#push">push (array, ...)</a></td> + <td class="summary">Pushes all passed-in values at the end of an array.</td> </tr> <tr> <td class="name" nowrap><a href="#range">range ([from[, to[, step]]])</a></td> <td class="summary">Produces a flexible list of numbers.</td> </tr> <tr> + <td class="name" nowrap><a href="#removeRange">removeRange (array[, start[, finish]])</a></td> + <td class="summary">Removes values at an index within the range <code>[start, finish]</code>.</td> + </tr> + <tr> <td class="name" nowrap><a href="#rep">rep (value, n)</a></td> <td class="summary">Creates an array list of <code>n</code> values, repeated.</td> </tr> <tr> - <td class="name" nowrap><a href="#partition">partition (array[, n[, pad]])</a></td> - <td class="summary">Iterator returning partitions of an array.</td> + <td class="name" nowrap><a href="#rest">rest (array[, index])</a></td> + <td class="summary">Returns all values after index.</td> </tr> <tr> - <td class="name" nowrap><a href="#sliding.">sliding. (array[, n[, pad]])</a></td> - <td class="summary">Iterator returning sliding partitions of an array.</td> + <td class="name" nowrap><a href="#reverse">reverse (array)</a></td> + <td class="summary">Returns an array where values are in reverse order.</td> </tr> <tr> - <td class="name" nowrap><a href="#permutation">permutation (array)</a></td> - <td class="summary">Iterator returning the permutations of an array.</td> + <td class="name" nowrap><a href="#sample">sample (array[, n[, seed]])</a></td> + <td class="summary">Samples <code>n</code> random values from an array.</td> </tr> <tr> - <td class="name" nowrap><a href="#invert">invert (array)</a></td> - <td class="summary">Swaps keys with values.</td> + <td class="name" nowrap><a href="#sampleProb">sampleProb (array, prob[, seed])</a></td> + <td class="summary">Return elements from a sequence with a given probability.</td> </tr> <tr> - <td class="name" nowrap><a href="#concat">concat (array[, sep[, i[, j]]])</a></td> - <td class="summary">Concatenates values in a given array.</td> + <td class="name" nowrap><a href="#selectWhile">selectWhile (array, f[, ...])</a></td> + <td class="summary">Collects values from a given array.</td> </tr> -</table> -<h2><a href="#Utility_functions">Utility functions </a></h2> -<table class="function_list"> <tr> - <td class="name" nowrap><a href="#noop">noop ()</a></td> - <td class="summary">The no-operation function.</td> + <td class="name" nowrap><a href="#shift">shift (array[, n])</a></td> + <td class="summary">Removes and returns the values at the top of a given array.</td> </tr> <tr> - <td class="name" nowrap><a href="#identity">identity (value)</a></td> - <td class="summary">Returns the passed-in value.</td> + <td class="name" nowrap><a href="#shuffle">shuffle (array[, seed])</a></td> + <td class="summary">Returns a shuffled copy of a given array.</td> </tr> <tr> - <td class="name" nowrap><a href="#constant">constant (value)</a></td> - <td class="summary">Creates a constant function which returns the same output on every call.</td> + <td class="name" nowrap><a href="#slice">slice (array[, start[, finish]])</a></td> + <td class="summary">Slices values indexed within <code>[start, finish]</code> range.</td> </tr> <tr> - <td class="name" nowrap><a href="#memoize">memoize (f[, hash])</a></td> - <td class="summary">Memoizes a given function by caching the computed result.</td> + <td class="name" nowrap><a href="#sortedIndex">sortedIndex (array, the[, comp[, sort]])</a></td> + <td class="summary">Returns the index at which a value should be inserted.</td> </tr> <tr> - <td class="name" nowrap><a href="#once">once (f)</a></td> - <td class="summary">Returns a version of <code>f</code> that runs only once.</td> + <td class="name" nowrap><a href="#sum">sum (array)</a></td> + <td class="summary">Returns the sum of array values.</td> </tr> <tr> - <td class="name" nowrap><a href="#before">before (f, count)</a></td> - <td class="summary">Returns a version of <code>f</code> that will run no more than <a href="index.html#count">count</a> times.</td> + <td class="name" nowrap><a href="#symmetricDifference">symmetricDifference (array, array2)</a></td> + <td class="summary">Performs a symmetric difference.</td> </tr> <tr> - <td class="name" nowrap><a href="#after">after (f, count)</a></td> - <td class="summary">Returns a version of <code>f</code> that runs on the <code>count-th</code> call.</td> + <td class="name" nowrap><a href="#toArray">toArray (...)</a></td> + <td class="summary">Converts a list of arguments to an array.</td> </tr> <tr> - <td class="name" nowrap><a href="#compose">compose (...)</a></td> - <td class="summary">Composes functions.</td> + <td class="name" nowrap><a href="#union">union (...)</a></td> + <td class="summary">Returns the duplicate-free union of all passed in arrays.</td> </tr> <tr> - <td class="name" nowrap><a href="#pipe">pipe (value, ...)</a></td> - <td class="summary">Pipes a value through a series of functions.</td> + <td class="name" nowrap><a href="#unique">unique (array)</a></td> + <td class="summary">Produces a duplicate-free version of a given array.</td> </tr> <tr> - <td class="name" nowrap><a href="#complement">complement (f)</a></td> - <td class="summary">Returns the logical complement of a given function.</td> + <td class="name" nowrap><a href="#unshift">unshift (array[, n])</a></td> + <td class="summary">Removes and returns the values at the end of a given array.</td> </tr> <tr> - <td class="name" nowrap><a href="#juxtapose">juxtapose (value, ...)</a></td> - <td class="summary">Calls a sequence of passed-in functions with the same argument.</td> + <td class="name" nowrap><a href="#vector">vector (value, n)</a></td> + <td class="summary">Returns an array of <code>n</code> times a given value.</td> </tr> <tr> - <td class="name" nowrap><a href="#wrap">wrap (f, wrapper)</a></td> - <td class="summary">Wraps <code>f</code> inside of the <code>wrapper</code> function.</td> + <td class="name" nowrap><a href="#xprod">xprod (array, array2)</a></td> + <td class="summary">Returns all possible pairs built from given arrays.</td> </tr> <tr> - <td class="name" nowrap><a href="#times">times (n, iter, ...)</a></td> - <td class="summary">Runs <code>iter</code> function <code>n</code> times.</td> + <td class="name" nowrap><a href="#zeros">zeros (n)</a></td> + <td class="summary">Returns an array of <code>n</code> zeros.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#zip">zip (...)</a></td> + <td class="summary">Merges values of each of the passed-in arrays in subsets.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#zipWith">zipWith (f, ...)</a></td> + <td class="summary">Merges values using a given function.</td> + </tr> +</table> +<h2><a href="#Utility_functions">Utility functions </a></h2> +<table class="function_list"> + <tr> + <td class="name" nowrap><a href="#after">after (f, count)</a></td> + <td class="summary">Returns a version of <code>f</code> that runs on the <code>count-th</code> call.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#applySpec">applySpec (specs)</a></td> + <td class="summary">Returns a function which applies <code>specs</code> on args.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#array">array (...)</a></td> + <td class="summary">Iterates over an iterator and returns its values in an array.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#ary">ary (f[, n])</a></td> + <td class="summary">Returns a function which accepts up to <code>n</code> args.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#before">before (f, count)</a></td> + <td class="summary">Returns a version of <code>f</code> that will run no more than <em>count</em> times.</td> </tr> <tr> <td class="name" nowrap><a href="#bind">bind (f, v)</a></td> @@ -443,34 +552,82 @@ <td class="summary">Binds <code>v</code> to be the second argument to <code>f</code>.</td> </tr> <tr> + <td class="name" nowrap><a href="#bindall">bindall (obj, ...)</a></td> + <td class="summary">Binds methods to object.</td> + </tr> + <tr> <td class="name" nowrap><a href="#bindn">bindn (f, ...)</a></td> - <td class="summary">Binds <code>…</code> to be the N-first arguments to function <code>f</code>.</td> + <td class="summary">Binds <code>...</code> to be the N-first arguments to function <code>f</code>.</td> </tr> <tr> - <td class="name" nowrap><a href="#bindAll">bindAll (obj, ...)</a></td> - <td class="summary">Binds methods to object.</td> + <td class="name" nowrap><a href="#castArray">castArray (value)</a></td> + <td class="summary">Casts vaue as an array if it is not one.</td> </tr> <tr> - <td class="name" nowrap><a href="#uniqueId">uniqueId ([template[, ...]])</a></td> - <td class="summary">Generates an unique ID for the current session.</td> + <td class="name" nowrap><a href="#complement">complement (f)</a></td> + <td class="summary">Returns the logical complement of a given function.</td> </tr> <tr> - <td class="name" nowrap><a href="#iterator">iterator (f, x)</a></td> - <td class="summary">Produces an iterator which repeatedly apply a function <code>f</code> onto an input.</td> + <td class="name" nowrap><a href="#compose">compose (...)</a></td> + <td class="summary">Composes functions.</td> </tr> <tr> - <td class="name" nowrap><a href="#array">array (...)</a></td> - <td class="summary">Iterates an iterator and returns its values in an array.</td> + <td class="name" nowrap><a href="#cond">cond (conds)</a></td> + <td class="summary">Returns a function which iterate over a set of conditions.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#constant">constant (value)</a></td> + <td class="summary">Creates a constant function which returns the same output on every call.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#converge">converge (f, g, h)</a></td> + <td class="summary">Converges two functions into one.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#curry">curry (f[, n_args])</a></td> + <td class="summary">Curries a function.</td> </tr> <tr> <td class="name" nowrap><a href="#flip">flip (f)</a></td> <td class="summary">Creates a function of <code>f</code> with arguments flipped in reverse order.</td> </tr> <tr> + <td class="name" nowrap><a href="#identity">identity (value)</a></td> + <td class="summary">Returns the passed-in value.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#iterator">iterator (f, value[, n])</a></td> + <td class="summary">Produces an iterator which repeatedly apply a function <code>f</code> onto an input.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#juxtapose">juxtapose (value, ...)</a></td> + <td class="summary">Calls a sequence of passed-in functions with the same argument.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#memoize">memoize (f[, hash])</a></td> + <td class="summary">Memoizes a given function by caching the computed result.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#noop">noop ()</a></td> + <td class="summary">The no operation function.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#nthArg">nthArg (n)</a></td> + <td class="summary">Returns a function that gets the nth argument.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#once">once (f)</a></td> + <td class="summary">Returns a version of <code>f</code> that runs only once.</td> + </tr> + <tr> <td class="name" nowrap><a href="#over">over (...)</a></td> <td class="summary">Creates a function that runs transforms on all arguments it receives.</td> </tr> <tr> + <td class="name" nowrap><a href="#overArgs">overArgs (f, ...)</a></td> + <td class="summary">Creates a function that invokes <code>f</code> with its arguments transformed.</td> + </tr> + <tr> <td class="name" nowrap><a href="#overEvery">overEvery (...)</a></td> <td class="summary">Creates a validation function.</td> </tr> @@ -479,10 +636,6 @@ <td class="summary">Creates a validation function.</td> </tr> <tr> - <td class="name" nowrap><a href="#overArgs">overArgs (f, ...)</a></td> - <td class="summary">Creates a function that invokes <code>f</code> with its arguments transformed.</td> - </tr> - <tr> <td class="name" nowrap><a href="#partial">partial (f, ...)</a></td> <td class="summary">Partially apply a function by filling in any number of its arguments.</td> </tr> @@ -491,43 +644,47 @@ <td class="summary">Similar to <a href="index.html#partial">partial</a>, but from the right.</td> </tr> <tr> - <td class="name" nowrap><a href="#curry">curry (f[, n_args])</a></td> - <td class="summary">Curries a function.</td> + <td class="name" nowrap><a href="#pipe">pipe (value, ...)</a></td> + <td class="summary">Pipes a value through a series of functions.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#rearg">rearg (f, indexes)</a></td> + <td class="summary">Returns a function which runs with arguments rearranged.</td> </tr> <tr> <td class="name" nowrap><a href="#time">time (f[, ...])</a></td> - <td class="summary">Returns the execution time of <code>f (…)</code> and its returned values.</td> + <td class="summary">Returns the execution time of <code>f (...)</code> and its returned values.</td> </tr> -</table> -<h2><a href="#Object_functions">Object functions </a></h2> -<table class="function_list"> <tr> - <td class="name" nowrap><a href="#keys">keys (obj)</a></td> - <td class="summary">Returns the keys of the object properties.</td> + <td class="name" nowrap><a href="#times">times (iter[, n[, ...]])</a></td> + <td class="summary">Runs <code>iter</code> function <code>n</code> times.</td> </tr> <tr> - <td class="name" nowrap><a href="#values">values (obj)</a></td> - <td class="summary">Returns the values of the object properties.</td> + <td class="name" nowrap><a href="#unary">unary (f)</a></td> + <td class="summary">Returns a function which accepts up to one arg.</td> </tr> <tr> - <td class="name" nowrap><a href="#kvpairs">kvpairs (obj)</a></td> - <td class="summary">Converts keys and values a an array-list of [k, v].</td> + <td class="name" nowrap><a href="#unfold">unfold (f, seed)</a></td> + <td class="summary">Builds a list from a seed value.</td> </tr> <tr> - <td class="name" nowrap><a href="#toObj">toObj (kvpairs)</a></td> - <td class="summary">Converts an array list of <a href="index.html#kvpairs">kvpairs</a> to an object.</td> + <td class="name" nowrap><a href="#uniqueId">uniqueId ([template[, ...]])</a></td> + <td class="summary">Generates an unique ID for the current session.</td> </tr> <tr> - <td class="name" nowrap><a href="#property">property (key)</a></td> - <td class="summary">Returns a function that will return the key property of any passed-in object.</td> + <td class="name" nowrap><a href="#wrap">wrap (f, wrapper)</a></td> + <td class="summary">Wraps <code>f</code> inside of the <code>wrapper</code> function.</td> </tr> +</table> +<h2><a href="#Object_functions">Object functions </a></h2> +<table class="function_list"> <tr> - <td class="name" nowrap><a href="#propertyOf">propertyOf (obj)</a></td> - <td class="summary">Returns a function which will return the value of an object property.</td> + <td class="name" nowrap><a href="#chain">chain (value)</a></td> + <td class="summary">Returns a wrapped object.</td> </tr> <tr> - <td class="name" nowrap><a href="#toBoolean">toBoolean (value)</a></td> - <td class="summary">Converts any given value to a boolean</td> + <td class="name" nowrap><a href="#clone">clone (obj[, shallow])</a></td> + <td class="summary">Clones a given object properties.</td> </tr> <tr> <td class="name" nowrap><a href="#extend">extend (destObj, ...)</a></td> @@ -538,100 +695,124 @@ <td class="summary">Returns a sorted list of all methods names found in an object.</td> </tr> <tr> - <td class="name" nowrap><a href="#clone">clone (obj[, shallow])</a></td> - <td class="summary">Clones a given object properties.</td> + <td class="name" nowrap><a href="#has">has (obj, key)</a></td> + <td class="summary">Checks if a given object implements a property.</td> </tr> <tr> - <td class="name" nowrap><a href="#tap">tap (obj, f[, ...])</a></td> - <td class="summary">Invokes interceptor with the object, and then returns object.</td> + <td class="name" nowrap><a href="#import">import ([context[, noConflict]])</a></td> + <td class="summary">Imports all library functions into a context.</td> </tr> <tr> - <td class="name" nowrap><a href="#has">has (obj, key)</a></td> - <td class="summary">Checks if a given object implements a property.</td> + <td class="name" nowrap><a href="#isArray">isArray (obj)</a></td> + <td class="summary">Checks if the given argument is an array.</td> </tr> <tr> - <td class="name" nowrap><a href="#pick">pick (obj, ...)</a></td> - <td class="summary">Returns an object copy having white-listed properties.</td> + <td class="name" nowrap><a href="#isBoolean">isBoolean (obj)</a></td> + <td class="summary">Checks if the given argument is a boolean.</td> </tr> <tr> - <td class="name" nowrap><a href="#omit">omit (obj, ...)</a></td> - <td class="summary">Returns an object copy without black-listed properties.</td> + <td class="name" nowrap><a href="#isCallable">isCallable (obj)</a></td> + <td class="summary">Checks if the given argument is callable.</td> </tr> <tr> - <td class="name" nowrap><a href="#template">template (obj[, template])</a></td> - <td class="summary">Applies a template to an object, preserving non-nil properties.</td> + <td class="name" nowrap><a href="#isEmpty">isEmpty ([obj])</a></td> + <td class="summary">Checks if the given pbject is empty.</td> </tr> <tr> <td class="name" nowrap><a href="#isEqual">isEqual (objA, objB[, useMt])</a></td> <td class="summary">Performs a deep comparison test between two objects.</td> </tr> <tr> - <td class="name" nowrap><a href="#result">result (obj, method[, ...])</a></td> - <td class="summary">Invokes an object method.</td> - </tr> - <tr> - <td class="name" nowrap><a href="#isTable">isTable (t)</a></td> - <td class="summary">Checks if the given arg is a table.</td> + <td class="name" nowrap><a href="#isFinite">isFinite (obj)</a></td> + <td class="summary">Checks if the given argument is a finite number.</td> </tr> <tr> - <td class="name" nowrap><a href="#isCallable">isCallable (obj)</a></td> - <td class="summary">Checks if the given argument is callable.</td> + <td class="name" nowrap><a href="#isFunction">isFunction (obj)</a></td> + <td class="summary">Checks if the given argument is a function.</td> </tr> <tr> - <td class="name" nowrap><a href="#isArray">isArray (obj)</a></td> - <td class="summary">Checks if the given argument is an array.</td> + <td class="name" nowrap><a href="#isInteger">isInteger (obj)</a></td> + <td class="summary">Checks if the given argument is an integer.</td> </tr> <tr> <td class="name" nowrap><a href="#isIterable">isIterable (obj)</a></td> <td class="summary">Checks if the given object is iterable with <a href="https://www.lua.org/manual/5.1/manual.html#pdf-pairs">pairs</a> (or <a href="https://www.lua.org/manual/5.1/manual.html#pdf-ipairs">ipairs</a>).</td> </tr> <tr> - <td class="name" nowrap><a href="#isEmpty">isEmpty ([obj])</a></td> - <td class="summary">Checks if the given pbject is empty.</td> + <td class="name" nowrap><a href="#isNaN">isNaN (obj)</a></td> + <td class="summary">Checks if the given argument is NaN (see <a href="http://en.wikipedia.org/wiki/NaN">Not-A-Number</a>).</td> + </tr> + <tr> + <td class="name" nowrap><a href="#isNil">isNil (obj)</a></td> + <td class="summary">Checks if the given argument is nil.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#isNumber">isNumber (obj)</a></td> + <td class="summary">Checks if the given argument is a number.</td> </tr> <tr> <td class="name" nowrap><a href="#isString">isString (obj)</a></td> <td class="summary">Checks if the given argument is a string.</td> </tr> <tr> - <td class="name" nowrap><a href="#isFunction">isFunction (obj)</a></td> - <td class="summary">Checks if the given argument is a function.</td> + <td class="name" nowrap><a href="#isTable">isTable (t)</a></td> + <td class="summary">Checks if the given arg is a table.</td> </tr> <tr> - <td class="name" nowrap><a href="#isNil">isNil (obj)</a></td> - <td class="summary">Checks if the given argument is nil.</td> + <td class="name" nowrap><a href="#keys">keys (obj)</a></td> + <td class="summary">Returns the keys of the object properties.</td> </tr> <tr> - <td class="name" nowrap><a href="#isNumber">isNumber (obj)</a></td> - <td class="summary">Checks if the given argument is a number.</td> + <td class="name" nowrap><a href="#kvpairs">kvpairs (obj)</a></td> + <td class="summary">Converts key-value pairs to an array-list of <code>[k, v]</code> pairs.</td> </tr> <tr> - <td class="name" nowrap><a href="#isNaN">isNaN (obj)</a></td> - <td class="summary">Checks if the given argument is NaN (see <a href="http://en.wikipedia.org/wiki/NaN">Not-A-Number</a>).</td> + <td class="name" nowrap><a href="#obj:value">obj:value ()</a></td> + <td class="summary">Extracts the value of a wrapped object.</td> </tr> <tr> - <td class="name" nowrap><a href="#isFinite">isFinite (obj)</a></td> - <td class="summary">Checks if the given argument is a finite number.</td> + <td class="name" nowrap><a href="#omit">omit (obj, ...)</a></td> + <td class="summary">Returns an object copy without black-listed properties.</td> </tr> <tr> - <td class="name" nowrap><a href="#isBoolean">isBoolean (obj)</a></td> - <td class="summary">Checks if the given argument is a boolean.</td> + <td class="name" nowrap><a href="#path">path (obj, ...)</a></td> + <td class="summary">Returns the value at a given path in an object.</td> </tr> <tr> - <td class="name" nowrap><a href="#isInteger">isInteger (obj)</a></td> - <td class="summary">Checks if the given argument is an integer.</td> + <td class="name" nowrap><a href="#pick">pick (obj, ...)</a></td> + <td class="summary">Returns an object copy having white-listed properties.</td> </tr> <tr> - <td class="name" nowrap><a href="#chain">chain (value)</a></td> - <td class="summary">Returns a wrapped object.</td> + <td class="name" nowrap><a href="#property">property (key)</a></td> + <td class="summary">Returns a function that will return the key property of any passed-in object.</td> </tr> <tr> - <td class="name" nowrap><a href="#obj:value">obj:value ()</a></td> - <td class="summary">Extracts the value of a wrapped object.</td> + <td class="name" nowrap><a href="#propertyOf">propertyOf (obj)</a></td> + <td class="summary">Returns a function which will return the value of an object property.</td> </tr> <tr> - <td class="name" nowrap><a href="#import">import ([context[, noConflict]])</a></td> - <td class="summary">Imports all library functions into a context.</td> + <td class="name" nowrap><a href="#result">result (obj, method[, ...])</a></td> + <td class="summary">Invokes an object method.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#tap">tap (obj, f[, ...])</a></td> + <td class="summary">Invokes interceptor with the object, and then returns object.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#template">template (obj[, template])</a></td> + <td class="summary">Applies a template to an object, preserving non-nil properties.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#toBoolean">toBoolean (value)</a></td> + <td class="summary">Converts any given value to a boolean</td> + </tr> + <tr> + <td class="name" nowrap><a href="#toObj">toObj (kvpairs)</a></td> + <td class="summary">Converts an array list of <code>[k,v]</code> pairs to an object.</td> + </tr> + <tr> + <td class="name" nowrap><a href="#values">values (obj)</a></td> + <td class="summary">Returns the values of the object properties.</td> </tr> </table> @@ -639,28 +820,31 @@ <br/> - <h2 class="section-header "><a name="Table_functions"></a>Table functions </h2> + <h2 class="section-header "><a name="Operator_functions"></a>Operator functions </h2> <dl class="function"> <dt> - <a name = "clear"></a> - <strong>clear (t)</strong> + <a name = "operator.add"></a> + <strong>operator.add (a, b)</strong> </dt> <dd> - Clears a table. All its values become nil. + Returns a + b. <em>Aliased as <code>op.add</code></em>. <h3>Parameters:</h3> <ul> - <li><span class="parameter">t</span> - a table + <li><span class="parameter">a</span> + a value + </li> + <li><span class="parameter">b</span> + a value </li> </ul> <h3>Returns:</h3> <ol> - the given table, cleared. + a + b </ol> @@ -668,93 +852,196 @@ </dd> <dt> - <a name = "each"></a> - <strong>each (t, f[, ...])</strong> + <a name = "operator.concat"></a> + <strong>operator.concat (a, b)</strong> </dt> <dd> - Iterates on key-value pairs, calling <code>f (k, v)</code> at every step. - <br/><em>Aliased as <code>forEach</code></em>. + Returns concatenation of a and b. <em>Aliased as <code>op.concat</code></em>. <h3>Parameters:</h3> <ul> - <li><span class="parameter">t</span> - a table + <li><span class="parameter">a</span> + a value </li> - <li><span class="parameter">f</span> - a function, prototyped as <code>f (k, v, …)</code> + <li><span class="parameter">b</span> + a value </li> - <li><span class="parameter">...</span> - Optional args to be passed to <code>f</code> - (<em>optional</em>) + </ul> + + <h3>Returns:</h3> + <ol> + + a .. b + </ol> + + + + +</dd> + <dt> + <a name = "operator.div"></a> + <strong>operator.div (a, b)</strong> + </dt> + <dd> + Returns a / b. <em>Aliased as <code>op.div</code></em>. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">a</span> + a value + </li> + <li><span class="parameter">b</span> + a value </li> </ul> + <h3>Returns:</h3> + <ol> + a / b + </ol> - <h3>See also:</h3> + + + +</dd> + <dt> + <a name = "operator.eq"></a> + <strong>operator.eq (a, b)</strong> + </dt> + <dd> + Checks if a equals b. <em>Aliased as <code>op.eq</code></em>. + + + <h3>Parameters:</h3> <ul> - <a href="index.html#eachi">eachi</a> + <li><span class="parameter">a</span> + a value + </li> + <li><span class="parameter">b</span> + a value + </li> </ul> + <h3>Returns:</h3> + <ol> + + a == b + </ol> + + + </dd> <dt> - <a name = "eachi"></a> - <strong>eachi (t, f[, ...])</strong> + <a name = "operator.exp"></a> + <strong>operator.exp (a, b)</strong> </dt> <dd> - Iterates on integer key-value pairs, calling <code>f(k, v)</code> every step.<br/> - Only applies to values located at integer keys. The table can be a sparse array. - Iteration will start from the lowest integer key found to the highest one. - <br/><em>Aliased as <code>forEachi</code></em>. + Returns a ^ b. <em>Aliased as <code>op.exp</code>, <code>op.pow</code></em>. <h3>Parameters:</h3> <ul> - <li><span class="parameter">t</span> - a table + <li><span class="parameter">a</span> + a value </li> - <li><span class="parameter">f</span> - a function, prototyped as <code>f (k, v, …)</code> + <li><span class="parameter">b</span> + a value </li> - <li><span class="parameter">...</span> - Optional args to be passed to <code>f</code> - (<em>optional</em>) + </ul> + + <h3>Returns:</h3> + <ol> + + a ^ b + </ol> + + + + +</dd> + <dt> + <a name = "operator.floordiv"></a> + <strong>operator.floordiv (a, b)</strong> + </dt> + <dd> + Performs floor division (//) between <code>a</code> and <code>b</code>. It rounds the quotient towards minus infinity. + <em>Aliased as <code>op.floordiv</code></em>. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">a</span> + a value + </li> + <li><span class="parameter">b</span> + a value </li> </ul> + <h3>Returns:</h3> + <ol> + a // b + </ol> - <h3>See also:</h3> + + + +</dd> + <dt> + <a name = "operator.ge"></a> + <strong>operator.ge (a, b)</strong> + </dt> + <dd> + Returns logical a and b. <em>Aliased as <code>op.land</code></em>. + + + <h3>Parameters:</h3> <ul> - <a href="index.html#each">each</a> + <li><span class="parameter">a</span> + a value + </li> + <li><span class="parameter">b</span> + a value + </li> </ul> + <h3>Returns:</h3> + <ol> + + a and b + </ol> + + + </dd> <dt> - <a name = "at"></a> - <strong>at (t, ...)</strong> + <a name = "operator.ge"></a> + <strong>operator.ge (a, b)</strong> </dt> <dd> - Collects values at given keys and return them wrapped in an array. + Checks if a is greater or equal to b. <em>Aliased as <code>op.ge</code></em>. <h3>Parameters:</h3> <ul> - <li><span class="parameter">t</span> - a table + <li><span class="parameter">a</span> + a value </li> - <li><span class="parameter">...</span> - A variable number of keys to collect values + <li><span class="parameter">b</span> + a value </li> </ul> <h3>Returns:</h3> <ol> - an array-list of values + a >= b </ol> @@ -762,101 +1049,163 @@ </dd> <dt> - <a name = "count"></a> - <strong>count (t[, value])</strong> + <a name = "operator.gt"></a> + <strong>operator.gt (a, b)</strong> </dt> <dd> - Counts occurrences of a given value in a table. Uses <a href="index.html#isEqual">isEqual</a> to compare values. + Checks if a is strictly greater than b. <em>Aliased as <code>op.gt</code></em>. <h3>Parameters:</h3> <ul> - <li><span class="parameter">t</span> - a table + <li><span class="parameter">a</span> + a value </li> - <li><span class="parameter">value</span> - a value to be searched in the table. If not given, the <a href="index.html#size">size</a> of the table will be returned - (<em>optional</em>) + <li><span class="parameter">b</span> + a value </li> </ul> <h3>Returns:</h3> <ol> - the count of occurrences of the given value + a > b </ol> - <h3>See also:</h3> + + +</dd> + <dt> + <a name = "operator.intdiv"></a> + <strong>operator.intdiv (a, b)</strong> + </dt> + <dd> + Performs integer division between <code>a</code> and <code>b</code>. <em>Aliased as <code>op.intdiv</code></em>. + + + <h3>Parameters:</h3> <ul> - <li><a href="index.html#countf">countf</a></li> - <li><a href="index.html#size">size</a></li> + <li><span class="parameter">a</span> + a value + </li> + <li><span class="parameter">b</span> + a value + </li> </ul> + <h3>Returns:</h3> + <ol> + + a / b + </ol> + + + </dd> <dt> - <a name = "countf"></a> - <strong>countf (t, f[, ...])</strong> + <a name = "operator.le"></a> + <strong>operator.le (a, b)</strong> </dt> <dd> - Counts occurrences validating a predicate. Same as <a href="index.html#count">count</a>, but uses an iterator. - Returns the count for values passing the test <code>f (k, v, …)</code> + Checks if a is less or equal to b. <em>Aliased as <code>op.le</code></em>. <h3>Parameters:</h3> <ul> - <li><span class="parameter">t</span> - a table + <li><span class="parameter">a</span> + a value </li> - <li><span class="parameter">f</span> - an iterator function, prototyped as <code>f (k, v, …)</code> + <li><span class="parameter">b</span> + a value </li> - <li><span class="parameter">...</span> - Optional args to be passed to <code>f</code> - (<em>optional</em>) + </ul> + + <h3>Returns:</h3> + <ol> + + a <= b + </ol> + + + + +</dd> + <dt> + <a name = "operator.length"></a> + <strong>operator.length (a)</strong> + </dt> + <dd> + Returns the length of a. <em>Aliased as <code>op.len</code></em>. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">a</span> + a value </li> </ul> <h3>Returns:</h3> <ol> - the count of values validating the predicate + +<h1>a</h1> + </ol> - <h3>See also:</h3> + + +</dd> + <dt> + <a name = "operator.lnot"></a> + <strong>operator.lnot (a)</strong> + </dt> + <dd> + Returns logical not a. <em>Aliased as <code>op.lnot</code></em>. + + + <h3>Parameters:</h3> <ul> - <li><a href="index.html#count">count</a></li> - <li><a href="index.html#size">size</a></li> + <li><span class="parameter">a</span> + a value + </li> </ul> + <h3>Returns:</h3> + <ol> + + not a + </ol> + + + </dd> <dt> - <a name = "cycle"></a> - <strong>cycle (t, n)</strong> + <a name = "operator.lor"></a> + <strong>operator.lor (a, b)</strong> </dt> <dd> - Loops <code>n</code> times through a table. In case <code>n</code> is omitted, it will loop forever. - In case <code>n</code> is lower or equal to 0, it returns an empty function. - <br/><em>Aliased as <code>loop</code></em>. + Returns logical a or b. <em>Aliased as <code>op.lor</code></em>. <h3>Parameters:</h3> <ul> - <li><span class="parameter">t</span> - a table + <li><span class="parameter">a</span> + a value </li> - <li><span class="parameter">n</span> - the number of loops + <li><span class="parameter">b</span> + a value </li> </ul> <h3>Returns:</h3> <ol> - an iterator function yielding key-value pairs from the passed-in table. + a or b </ol> @@ -864,32 +1213,55 @@ </dd> <dt> - <a name = "map"></a> - <strong>map (t, f[, ...])</strong> + <a name = "operator.lt"></a> + <strong>operator.lt (a, b)</strong> </dt> <dd> - Maps <code>f (k, v)</code> on key-value pairs, collects and returns the results. - <br/><em>Aliased as <code>collect</code></em>. + Checks if a is strictly less than b. <em>Aliased as <code>op.lt</code></em>. <h3>Parameters:</h3> <ul> - <li><span class="parameter">t</span> - a table + <li><span class="parameter">a</span> + a value </li> - <li><span class="parameter">f</span> - an iterator function, prototyped as <code>f (k, v, …)</code> + <li><span class="parameter">b</span> + a value </li> - <li><span class="parameter">...</span> - Optional args to be passed to <code>f</code> - (<em>optional</em>) + </ul> + + <h3>Returns:</h3> + <ol> + + a < b + </ol> + + + + +</dd> + <dt> + <a name = "operator.mod"></a> + <strong>operator.mod (a, b)</strong> + </dt> + <dd> + Returns a % b. <em>Aliased as <code>op.mod</code></em>. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">a</span> + a value + </li> + <li><span class="parameter">b</span> + a value </li> </ul> <h3>Returns:</h3> <ol> - a table of results + a % b </ol> @@ -897,52 +1269,126 @@ </dd> <dt> - <a name = "reduce"></a> - <strong>reduce (t, f[, state])</strong> + <a name = "operator.mul"></a> + <strong>operator.mul (a, b)</strong> </dt> <dd> - Reduces a table, left-to-right. Folds the table from the first element to the last element - to a single value, using a given iterator and an initial state. - The iterator takes a state and a value and returns a new state. - <br/><em>Aliased as <code>inject</code>, <code>foldl</code></em>. + Returns a * b. <em>Aliased as <code>op.mul</code></em>. <h3>Parameters:</h3> <ul> - <li><span class="parameter">t</span> - a table + <li><span class="parameter">a</span> + a value </li> - <li><span class="parameter">f</span> - an iterator function, prototyped as <code>f (state, value)</code> + <li><span class="parameter">b</span> + a value </li> - <li><span class="parameter">state</span> - an initial state of reduction. Defaults to the first value in the table. - (<em>optional</em>) + </ul> + + <h3>Returns:</h3> + <ol> + + a * b + </ol> + + + + +</dd> + <dt> + <a name = "operator.neq"></a> + <strong>operator.neq (a, b)</strong> + </dt> + <dd> + Checks if a not equals b. <em>Aliased as <code>op.neq</code></em>. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">a</span> + a value + </li> + <li><span class="parameter">b</span> + a value </li> </ul> <h3>Returns:</h3> <ol> - the final state of reduction + a ~= b </ol> - <h3>See also:</h3> + + +</dd> + <dt> + <a name = "operator.sub"></a> + <strong>operator.sub (a, b)</strong> + </dt> + <dd> + Returns a - b. <em>Aliased as <code>op.sub</code></em>. + + + <h3>Parameters:</h3> <ul> - <li><a href="index.html#reduceRight">reduceRight</a></li> - <li><a href="index.html#reduceby">reduceby</a></li> + <li><span class="parameter">a</span> + a value + </li> + <li><span class="parameter">b</span> + a value + </li> </ul> + <h3>Returns:</h3> + <ol> + + a - b + </ol> + + + </dd> <dt> - <a name = "reduceby"></a> - <strong>reduceby (t, f, state, pred[, ...])</strong> + <a name = "operator.unm"></a> + <strong>operator.unm (a)</strong> </dt> <dd> - Reduces values in a table passing a given predicate. Folds the table left-to-right, considering - only values validating a given predicate. + Returns -a. <em>Aliased as <code>op.unm</code>, <code>op.neg</code></em>. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">a</span> + a value + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + -a + </ol> + + + + +</dd> +</dl> + <h2 class="section-header "><a name="Table_functions"></a>Table functions </h2> + + <dl class="function"> + <dt> + <a name = "adjust"></a> + <strong>adjust (t, key, f[, ...])</strong> + </dt> + <dd> + Adjusts the value at a given key using a function or a value. In case <code>f</code> is a function, + it should be prototyped <code>f(v, ...)</code>. It does not mutate the given table, but rather + returns a new array. In case the given <code>key</code> does not exist in <code>t</code>, it throws an error. <h3>Parameters:</h3> @@ -950,17 +1396,42 @@ <li><span class="parameter">t</span> a table </li> + <li><span class="parameter">key</span> + a key + </li> <li><span class="parameter">f</span> - an iterator function, prototyped as <code>f (state, value)</code> + a function, prototyped as <code>f(v, ...)</code> or a value </li> - <li><span class="parameter">state</span> - an initial state of reduction. + <li><span class="parameter">...</span> + Optional args to be passed to <code>f</code> + (<em>optional</em>) </li> - <li><span class="parameter">pred</span> - a predicate function <code>pred (k, v, …)</code> to select values to be considered for reduction + </ul> + + + + + +</dd> + <dt> + <a name = "all"></a> + <strong>all (t, f[, ...])</strong> + </dt> + <dd> + Checks if all values in a table are passing an iterator test. + <br/><em>Aliased as <code>every</code></em> + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">t</span> + a table + </li> + <li><span class="parameter">f</span> + an iterator function, prototyped as <code>f (v, k, ...)</code> </li> <li><span class="parameter">...</span> - optional args to be passed to <code>pred</code> + Optional args to be passed to <code>f</code> (<em>optional</em>) </li> </ul> @@ -968,26 +1439,47 @@ <h3>Returns:</h3> <ol> - the final state of reduction + <code>true</code> if all values passes the predicate, <code>false</code> otherwise </ol> - <h3>See also:</h3> + + +</dd> + <dt> + <a name = "at"></a> + <strong>at (t, ...)</strong> + </dt> + <dd> + Collects values at given keys and return them wrapped in an array. + + + <h3>Parameters:</h3> <ul> - <a href="index.html#reduce">reduce</a> + <li><span class="parameter">t</span> + a table + </li> + <li><span class="parameter">...</span> + A variable number of keys to collect values + </li> </ul> + <h3>Returns:</h3> + <ol> + + an array-list of values + </ol> + + + </dd> <dt> - <a name = "reduceRight"></a> - <strong>reduceRight (t, f[, state])</strong> + <a name = "clear"></a> + <strong>clear (t)</strong> </dt> <dd> - Reduces a table, right-to-left. Folds the table from the last element to the first element - to single value, using a given iterator and an initial state. - The iterator takes a state and a value, and returns a new state. - <br/><em>Aliased as <code>injectr</code>, <code>foldr</code></em>. + Clears a table. All its values become nil. <h3>Parameters:</h3> @@ -995,38 +1487,58 @@ <li><span class="parameter">t</span> a table </li> - <li><span class="parameter">f</span> - an iterator function, prototyped as <code>f (state, value)</code> + </ul> + + <h3>Returns:</h3> + <ol> + + the given table, cleared. + </ol> + + + + +</dd> + <dt> + <a name = "containsKeys"></a> + <strong>containsKeys (t, other)</strong> + </dt> + <dd> + Checks if all the keys of <code>other</code> table exists in table <code>t</code>. It does not + compares values. The test is not commutative, i.e table <code>t</code> may contains keys + not existing in <code>other</code>. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">t</span> + a table </li> - <li><span class="parameter">state</span> - an initial state of reduction. Defaults to the last value in the table. - (<em>optional</em>) + <li><span class="parameter">other</span> + another table </li> </ul> <h3>Returns:</h3> <ol> - the final state of reduction + <code>true</code> or <code>false</code> </ol> <h3>See also:</h3> <ul> - <a href="index.html#reduce">reduce</a> + <a href="index.html#sameKeys">sameKeys</a> </ul> </dd> <dt> - <a name = "mapReduce"></a> - <strong>mapReduce (t, f[, state])</strong> + <a name = "count"></a> + <strong>count (t[, val])</strong> </dt> <dd> - Reduces a table while saving intermediate states. Folds the table left-to-right - using a given iterator and an initial state. The iterator takes a state and a value, - and returns a new state. The result is an array of intermediate states. - <br/><em>Aliased as <code>mapr</code></em> + Counts occurrences of a given value in a table. Uses <a href="index.html#isEqual">isEqual</a> to compare values. <h3>Parameters:</h3> @@ -1034,11 +1546,8 @@ <li><span class="parameter">t</span> a table </li> - <li><span class="parameter">f</span> - an iterator function, prototyped as <code>f (state, value)</code> - </li> - <li><span class="parameter">state</span> - an initial state of reduction. Defaults to the first value in the table. + <li><span class="parameter">val</span> + a value to be searched in the table. If not given, the <a href="index.html#size">size</a> of the table will be returned (<em>optional</em>) </li> </ul> @@ -1046,26 +1555,57 @@ <h3>Returns:</h3> <ol> - an array of states + the count of occurrences of the given value </ol> <h3>See also:</h3> <ul> - <a href="index.html#mapReduceRight">mapReduceRight</a> + <li><a href="index.html#countf">countf</a></li> + <li><a href="index.html#size">size</a></li> </ul> </dd> <dt> - <a name = "mapReduceRight"></a> - <strong>mapReduceRight (t, f[, state])</strong> + <a name = "countBy"></a> + <strong>countBy (t, iter[, ...])</strong> </dt> <dd> - Reduces a table while saving intermediate states. Folds the table right-to-left - using a given iterator and an initial state. The iterator takes a state and a value, - and returns a new state. The result is an array of intermediate states. - <br/><em>Aliased as <code>maprr</code></em> + Groups values in a collection and counts them. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">t</span> + a table + </li> + <li><span class="parameter">iter</span> + an iterator function, prototyped as <code>iter (v, k, ...)</code> + </li> + <li><span class="parameter">...</span> + Optional args to be passed to <code>iter</code> + (<em>optional</em>) + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + a table of subsets groups names paired with their count + </ol> + + + + +</dd> + <dt> + <a name = "countf"></a> + <strong>countf (t, f[, ...])</strong> + </dt> + <dd> + Counts the number of values passing a predicate test. Same as <a href="index.html#count">count</a>, but uses an iterator. + Returns the count for values passing the test <code>f (v, k, ...)</code> <h3>Parameters:</h3> @@ -1074,10 +1614,10 @@ a table </li> <li><span class="parameter">f</span> - an iterator function, prototyped as <code>f (state, value)</code> + an iterator function, prototyped as <code>f (v, k, ...)</code> </li> - <li><span class="parameter">state</span> - an initial state of reduction. Defaults to the last value in the table. + <li><span class="parameter">...</span> + Optional args to be passed to <code>f</code> (<em>optional</em>) </li> </ul> @@ -1085,26 +1625,26 @@ <h3>Returns:</h3> <ol> - an array of states + the count of values validating the predicate </ol> <h3>See also:</h3> <ul> - <a href="index.html#mapReduce">mapReduce</a> + <li><a href="index.html#count">count</a></li> + <li><a href="index.html#size">size</a></li> </ul> </dd> <dt> - <a name = "include"></a> - <strong>include (t, value)</strong> + <a name = "cycle"></a> + <strong>cycle (t[, n])</strong> </dt> <dd> - Performs a linear search for a value in a table. It does not work for nested tables. - The given value can be a function prototyped as <code>f (v, value)</code> which should return true when - any v in the table equals the value being searched. - <br/><em>Aliased as <code>any</code>, <code>some</code>, <code>contains</code></em> + Loops <code>n</code> times through a table. In case <code>n</code> is omitted, it will loop forever. + In case <code>n</code> is lower or equal to 0, it returns an empty function. + <br/><em>Aliased as <code>loop</code></em>. <h3>Parameters:</h3> @@ -1112,22 +1652,19 @@ <li><span class="parameter">t</span> a table </li> - <li><span class="parameter">value</span> - a value to search for + <li><span class="parameter">n</span> + the number of loops + (<em>optional</em>) </li> </ul> <h3>Returns:</h3> <ol> - a boolean : <code>true</code> when found, <code>false</code> otherwise + an iterator function yielding value-key pairs from the passed-in table. </ol> - <h3>See also:</h3> - <ul> - <a href="index.html#detect">detect</a> - </ul> </dd> @@ -1138,7 +1675,8 @@ <dd> Performs a linear search for a value in a table. Returns the key of the value if found. The given value can be a function prototyped as <code>f (v, value)</code> which should return true when - any v in the table equals the value being searched. + any v in the table equals the value being searched. This function is similar to <a href="index.html#find">find</a>, + which is mostly meant to work with array. <h3>Parameters:</h3> @@ -1160,17 +1698,19 @@ <h3>See also:</h3> <ul> - <a href="index.html#include">include</a> + <li><a href="index.html#include">include</a></li> + <li><a href="index.html#find">find</a></li> </ul> </dd> <dt> - <a name = "where"></a> - <strong>where (t, props)</strong> + <a name = "each"></a> + <strong>each (t, f[, ...])</strong> </dt> <dd> - Returns all values having specified keys <code>props</code>. + Iterates on key-value pairs, calling <code>f (v, k)</code> at every step. + <br/><em>Aliased as <code>forEach</code></em>. <h3>Parameters:</h3> @@ -1178,21 +1718,54 @@ <li><span class="parameter">t</span> a table </li> - <li><span class="parameter">props</span> - a set of keys + <li><span class="parameter">f</span> + a function, prototyped as <code>f (v, k, ...)</code> + </li> + <li><span class="parameter">...</span> + Optional args to be passed to <code>f</code> + (<em>optional</em>) </li> </ul> - <h3>Returns:</h3> - <ol> - an array of values from the passed-in table - </ol> + + <h3>See also:</h3> + <ul> + <a href="index.html#eachi">eachi</a> + </ul> + + +</dd> + <dt> + <a name = "eachi"></a> + <strong>eachi (t, f[, ...])</strong> + </dt> + <dd> + Iterates on integer key-value pairs, calling <code>f(v, k)</code> every step. <br/> + Only applies to values located at integer keys. The table can be a sparse array. + Iteration will start from the lowest integer key found to the highest one. + <br/><em>Aliased as <code>forEachi</code></em>. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">t</span> + a table + </li> + <li><span class="parameter">f</span> + a function, prototyped as <code>f (v, k, ...)</code> + </li> + <li><span class="parameter">...</span> + Optional args to be passed to <code>f</code> + (<em>optional</em>) + </li> + </ul> + <h3>See also:</h3> <ul> - <a href="index.html#findWhere">findWhere</a> + <a href="index.html#each">each</a> </ul> @@ -1230,12 +1803,11 @@ </dd> <dt> - <a name = "select"></a> - <strong>select (t, f[, ...])</strong> + <a name = "groupBy"></a> + <strong>groupBy (t, iter[, ...])</strong> </dt> <dd> - Selects and returns values passing an iterator test. - <br/><em>Aliased as <code>filter</code></em>. + Splits a table into subsets groups. <h3>Parameters:</h3> @@ -1243,11 +1815,11 @@ <li><span class="parameter">t</span> a table </li> - <li><span class="parameter">f</span> - an iterator function, prototyped as <code>f (k, v, …)</code> + <li><span class="parameter">iter</span> + an iterator function, prototyped as <code>iter (v, k, ...)</code> </li> <li><span class="parameter">...</span> - Optional args to be passed to <code>f</code> + Optional args to be passed to <code>iter</code> (<em>optional</em>) </li> </ul> @@ -1255,24 +1827,54 @@ <h3>Returns:</h3> <ol> - the selected values + a table of subsets groups + </ol> + + + + +</dd> + <dt> + <a name = "include"></a> + <strong>include (t, value)</strong> + </dt> + <dd> + Performs a linear search for a value in a table. It does not work for nested tables. + The given value can be a function prototyped as <code>f (v, value)</code> which should return true when + any v in the table equals the value being searched. + <br/><em>Aliased as <code>any</code>, <code>some</code>, <code>contains</code></em> + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">t</span> + a table + </li> + <li><span class="parameter">value</span> + a value to search for + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + a boolean : <code>true</code> when found, <code>false</code> otherwise </ol> <h3>See also:</h3> <ul> - <a href="index.html#reject">reject</a> + <a href="index.html#detect">detect</a> </ul> </dd> <dt> - <a name = "reject"></a> - <strong>reject (t, f[, ...])</strong> + <a name = "invoke"></a> + <strong>invoke (t, method[, ...])</strong> </dt> <dd> - Clones a table while dropping values passing an iterator test. - <br/><em>Aliased as <code>discard</code></em> + Invokes a method on each value in a table. <h3>Parameters:</h3> @@ -1280,11 +1882,11 @@ <li><span class="parameter">t</span> a table </li> - <li><span class="parameter">f</span> - an iterator function, prototyped as <code>f (k, v, …)</code> + <li><span class="parameter">method</span> + a function, prototyped as <code>f (v, ...)</code> </li> <li><span class="parameter">...</span> - Optional args to be passed to <code>f</code> + Optional args to be passed to <code>method</code> (<em>optional</em>) </li> </ul> @@ -1292,24 +1894,24 @@ <h3>Returns:</h3> <ol> - the remaining values + the result of the call <code>f (v, ...)</code> </ol> <h3>See also:</h3> <ul> - <a href="index.html#select">select</a> + <a href="index.html#pluck">pluck</a> </ul> </dd> <dt> - <a name = "all"></a> - <strong>all (t, f[, ...])</strong> + <a name = "map"></a> + <strong>map (t, f[, ...])</strong> </dt> <dd> - Checks if all values in a table are passing an iterator test. - <br/><em>Aliased as <code>every</code></em> + Maps <code>f (v, k)</code> on value-key pairs, collects and returns the results. + <br/><em>Aliased as <code>collect</code></em>. <h3>Parameters:</h3> @@ -1318,7 +1920,7 @@ a table </li> <li><span class="parameter">f</span> - an iterator function, prototyped as <code>f (k, v, …)</code> + an iterator function, prototyped as <code>f (v, k, ...)</code> </li> <li><span class="parameter">...</span> Optional args to be passed to <code>f</code> @@ -1329,7 +1931,7 @@ <h3>Returns:</h3> <ol> - <code>true</code> if all values passes the predicate, <code>false</code> otherwise + a table of results </ol> @@ -1337,11 +1939,14 @@ </dd> <dt> - <a name = "invoke"></a> - <strong>invoke (t, method[, ...])</strong> + <a name = "mapReduce"></a> + <strong>mapReduce (t, f[, state])</strong> </dt> <dd> - Invokes a method on each value in a table. + Reduces a table while saving intermediate states. Folds the table left-to-right + using a given iterator and an initial state. The iterator takes a state and a value, + and returns a new state. The result is an array of intermediate states. + <br/><em>Aliased as <code>mapr</code></em> <h3>Parameters:</h3> @@ -1349,11 +1954,11 @@ <li><span class="parameter">t</span> a table </li> - <li><span class="parameter">method</span> - a function, prototyped as <code>f (v, …)</code> + <li><span class="parameter">f</span> + an iterator function, prototyped as <code>f (state, value)</code> </li> - <li><span class="parameter">...</span> - Optional args to be passed to <code>method</code> + <li><span class="parameter">state</span> + an initial state of reduction. Defaults to the first value in the table. (<em>optional</em>) </li> </ul> @@ -1361,23 +1966,26 @@ <h3>Returns:</h3> <ol> - the result of the call <code>f (v, …)</code> + an array of states </ol> <h3>See also:</h3> <ul> - <a href="index.html#pluck">pluck</a> + <a href="index.html#mapReduceRight">mapReduceRight</a> </ul> </dd> <dt> - <a name = "pluck"></a> - <strong>pluck (t, key)</strong> + <a name = "mapReduceRight"></a> + <strong>mapReduceRight (t, f[, state])</strong> </dt> <dd> - Extracts values in a table having a given key. + Reduces a table while saving intermediate states. Folds the table right-to-left + using a given iterator and an initial state. The iterator takes a state and a value, + and returns a new state. The result is an array of intermediate states. + <br/><em>Aliased as <code>maprr</code></em> <h3>Parameters:</h3> @@ -1385,18 +1993,26 @@ <li><span class="parameter">t</span> a table </li> - <li><span class="parameter">key</span> - a key, will be used to index in each value: <code>value[key]</code> + <li><span class="parameter">f</span> + an iterator function, prototyped as <code>f (state, value)</code> + </li> + <li><span class="parameter">state</span> + an initial state of reduction. Defaults to the last value in the table. + (<em>optional</em>) </li> </ul> <h3>Returns:</h3> <ol> - an array of values having the given key + an array of states </ol> + <h3>See also:</h3> + <ul> + <a href="index.html#mapReduce">mapReduce</a> + </ul> </dd> @@ -1405,7 +2021,7 @@ <strong>max (t[, transform[, ...]])</strong> </dt> <dd> - Returns the max value in a collection. If an transformation function is passed, it will + Returns the max value in a collection. If a <code>transform</code> function is passed, it will be used to evaluate values by which all objects will be sorted. @@ -1415,7 +2031,7 @@ a table </li> <li><span class="parameter">transform</span> - a transformation function, prototyped as <code>transform (v, …)</code>, defaults to <a href="index.html#identity">identity</a> + a transformation function, prototyped as <code>transform (v, ...)</code>, defaults to <a href="index.html#identity">identity</a> (<em>optional</em>) </li> <li><span class="parameter">...</span> @@ -1443,7 +2059,7 @@ <strong>min (t[, transform[, ...]])</strong> </dt> <dd> - Returns the min value in a collection. If an transformation function is passed, it will + Returns the min value in a collection. If a <code>transform</code> function is passed, it will be used to evaluate values by which all objects will be sorted. @@ -1453,7 +2069,7 @@ a table </li> <li><span class="parameter">transform</span> - a transformation function, prototyped as <code>transform (v, …)</code>, defaults to <a href="index.html#identity">identity</a> + a transformation function, prototyped as <code>transform (v, ...)</code>, defaults to <a href="index.html#identity">identity</a> (<em>optional</em>) </li> <li><span class="parameter">...</span> @@ -1477,12 +2093,11 @@ </dd> <dt> - <a name = "shuffle"></a> - <strong>shuffle (t[, seed])</strong> + <a name = "pluck"></a> + <strong>pluck (t, key)</strong> </dt> <dd> - Returns a shuffled copy of a given collection. If a seed is provided, it will - be used to init the pseudo random number generator (using <a href="https://www.lua.org/manual/5.1/manual.html#pdf-math.randomseed">math.randomseed</a>). + Extracts values in a table having a given key. <h3>Parameters:</h3> @@ -1490,16 +2105,15 @@ <li><span class="parameter">t</span> a table </li> - <li><span class="parameter">seed</span> - a seed - (<em>optional</em>) + <li><span class="parameter">key</span> + a key, will be used to index in each value: <code>value[key]</code> </li> </ul> <h3>Returns:</h3> <ol> - a shuffled copy of the given table + an array of values having the given key </ol> @@ -1507,40 +2121,54 @@ </dd> <dt> - <a name = "same"></a> - <strong>same (a, b)</strong> + <a name = "reduce"></a> + <strong>reduce (t, f[, state])</strong> </dt> <dd> - Checks if two tables are the same. It compares if both tables features the same values, - but not necessarily at the same keys. + Reduces a table, left-to-right. Folds the table from the first element to the last element + to a single value, using a given iterator and an initial state. + The iterator takes a state and a value and returns a new state. + <br/><em>Aliased as <code>inject</code>, <code>foldl</code></em>. <h3>Parameters:</h3> <ul> - <li><span class="parameter">a</span> + <li><span class="parameter">t</span> a table </li> - <li><span class="parameter">b</span> - another table + <li><span class="parameter">f</span> + an iterator function, prototyped as <code>f (state, value)</code> + </li> + <li><span class="parameter">state</span> + an initial state of reduction. Defaults to the first value in the table. + (<em>optional</em>) </li> </ul> <h3>Returns:</h3> <ol> - <code>true</code> or <code>false</code> + the final state of reduction </ol> + <h3>See also:</h3> + <ul> + <li><a href="index.html#reduceRight">reduceRight</a></li> + <li><a href="index.html#reduceby">reduceby</a></li> + </ul> </dd> <dt> - <a name = "sort"></a> - <strong>sort (t[, comp])</strong> + <a name = "reduceRight"></a> + <strong>reduceRight (t, f[, state])</strong> </dt> <dd> - Sorts a table, in-place. If a comparison function is given, it will be used to sort values. + Reduces a table, right-to-left. Folds the table from the last element to the first element + to single value, using a given iterator and an initial state. + The iterator takes a state and a value, and returns a new state. + <br/><em>Aliased as <code>injectr</code>, <code>foldr</code></em>. <h3>Parameters:</h3> @@ -1548,8 +2176,11 @@ <li><span class="parameter">t</span> a table </li> - <li><span class="parameter">comp</span> - a comparison function prototyped as <code>comp (a, b)</code>, defaults to <tt><</tt> operator. + <li><span class="parameter">f</span> + an iterator function, prototyped as <code>f (state, value)</code> + </li> + <li><span class="parameter">state</span> + an initial state of reduction. Defaults to the last value in the table. (<em>optional</em>) </li> </ul> @@ -1557,25 +2188,24 @@ <h3>Returns:</h3> <ol> - the initial table, sorted. + the final state of reduction </ol> <h3>See also:</h3> <ul> - <a href="index.html#sortBy">sortBy</a> + <a href="index.html#reduce">reduce</a> </ul> </dd> <dt> - <a name = "sortBy"></a> - <strong>sortBy (t[, transform[, comp]])</strong> + <a name = "reduceby"></a> + <strong>reduceby (t, f, pred[, state[, ...]])</strong> </dt> <dd> - Sorts a table in-place using a transform. Values are ranked in a custom order of the results of - running <code>transform (v)</code> on all values. <code>transform</code> may also be a string name property sort by. - <code>comp</code> is a comparison function. + Reduces values in a table passing a given predicate. Folds the table left-to-right, considering + only values validating a given predicate. <h3>Parameters:</h3> @@ -1583,12 +2213,18 @@ <li><span class="parameter">t</span> a table </li> - <li><span class="parameter">transform</span> - a <code>transform</code> function to sort elements prototyped as <code>transform (v)</code>. Defaults to <a href="index.html#identity">identity</a> + <li><span class="parameter">f</span> + an iterator function, prototyped as <code>f (state, value)</code> + </li> + <li><span class="parameter">pred</span> + a predicate function <code>pred (v, k, ...)</code> to select values to be considered for reduction + </li> + <li><span class="parameter">state</span> + an initial state of reduction. Defaults to the first value in the table of selected values. (<em>optional</em>) </li> - <li><span class="parameter">comp</span> - a comparision function, defaults to the <code><</code> operator + <li><span class="parameter">...</span> + optional args to be passed to <code>pred</code> (<em>optional</em>) </li> </ul> @@ -1596,23 +2232,24 @@ <h3>Returns:</h3> <ol> - a new array of sorted values + the final state of reduction </ol> <h3>See also:</h3> <ul> - <a href="index.html#sort">sort</a> + <a href="index.html#reduce">reduce</a> </ul> </dd> <dt> - <a name = "groupBy"></a> - <strong>groupBy (t, iter[, ...])</strong> + <a name = "reject"></a> + <strong>reject (t, f[, ...])</strong> </dt> <dd> - Splits a table into subsets groups. + Clones a table while dropping values passing an iterator test. + <br/><em>Aliased as <code>discard</code></em> <h3>Parameters:</h3> @@ -1620,11 +2257,11 @@ <li><span class="parameter">t</span> a table </li> - <li><span class="parameter">iter</span> - an iterator function, prototyped as <code>iter (k, v, …)</code> + <li><span class="parameter">f</span> + an iterator function, prototyped as <code>f (v, k, ...)</code> </li> <li><span class="parameter">...</span> - Optional args to be passed to <code>iter</code> + Optional args to be passed to <code>f</code> (<em>optional</em>) </li> </ul> @@ -1632,19 +2269,85 @@ <h3>Returns:</h3> <ol> - a table of subsets groups + the remaining values </ol> + <h3>See also:</h3> + <ul> + <a href="index.html#select">select</a> + </ul> </dd> <dt> - <a name = "countBy"></a> - <strong>countBy (t, iter[, ...])</strong> + <a name = "same"></a> + <strong>same (a, b)</strong> </dt> <dd> - Groups values in a collection and counts them. + Checks if two tables are the same. It compares if both tables features the same values, + but not necessarily at the same keys. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">a</span> + a table + </li> + <li><span class="parameter">b</span> + another table + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + <code>true</code> or <code>false</code> + </ol> + + + + +</dd> + <dt> + <a name = "sameKeys"></a> + <strong>sameKeys (tA, tB)</strong> + </dt> + <dd> + Checks if both given tables have the same keys. It does not compares values. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">tA</span> + a table + </li> + <li><span class="parameter">tB</span> + another table + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + <code>true</code> or <code>false</code> + </ol> + + + <h3>See also:</h3> + <ul> + <a href="index.html#containsKeys">containsKeys</a> + </ul> + + +</dd> + <dt> + <a name = "select"></a> + <strong>select (t, f[, ...])</strong> + </dt> + <dd> + Selects and returns values passing an iterator test. + <br/><em>Aliased as <code>filter</code></em>. <h3>Parameters:</h3> @@ -1652,11 +2355,11 @@ <li><span class="parameter">t</span> a table </li> - <li><span class="parameter">iter</span> - an iterator function, prototyped as <code>iter (k, v, …)</code> + <li><span class="parameter">f</span> + an iterator function, prototyped as <code>f (v, k, ...)</code> </li> <li><span class="parameter">...</span> - Optional args to be passed to <code>iter</code> + Optional args to be passed to <code>f</code> (<em>optional</em>) </li> </ul> @@ -1664,10 +2367,14 @@ <h3>Returns:</h3> <ol> - a table of subsets groups names paired with their count + the selected values </ol> + <h3>See also:</h3> + <ul> + <a href="index.html#reject">reject</a> + </ul> </dd> @@ -1704,13 +2411,11 @@ </dd> <dt> - <a name = "containsKeys"></a> - <strong>containsKeys (t, other)</strong> + <a name = "sort"></a> + <strong>sort (t[, comp])</strong> </dt> <dd> - Checks if all the keys of <code>other</code> table exists in table <code>t</code>. It does not - compares values. The test is not commutative, i.e table <code>t</code> may contains keys - not existing in <code>other</code>. + Sorts a table, in-place. If a comparison function is given, it will be used to sort values. <h3>Parameters:</h3> @@ -1718,53 +2423,93 @@ <li><span class="parameter">t</span> a table </li> - <li><span class="parameter">other</span> - another table + <li><span class="parameter">comp</span> + a comparison function prototyped as <code>comp (a, b)</code>, defaults to <tt><</tt> operator. + (<em>optional</em>) </li> </ul> <h3>Returns:</h3> <ol> - <code>true</code> or <code>false</code> + the given table, sorted. </ol> <h3>See also:</h3> <ul> - <a href="index.html#sameKeys">sameKeys</a> + <a href="index.html#sortBy">sortBy</a> </ul> </dd> <dt> - <a name = "sameKeys"></a> - <strong>sameKeys (tA, tB)</strong> + <a name = "sortBy"></a> + <strong>sortBy (t[, transform[, comp]])</strong> </dt> <dd> - Checks if both given tables have the same keys. It does not compares values. + Sorts a table in-place using a transform. Values are ranked in a custom order of the results of + running <code>transform (v)</code> on all values. <code>transform</code> may also be a string name property sort by. + <code>comp</code> is a comparison function. <h3>Parameters:</h3> <ul> - <li><span class="parameter">tA</span> + <li><span class="parameter">t</span> a table </li> - <li><span class="parameter">tB</span> - another table + <li><span class="parameter">transform</span> + a <code>transform</code> function to sort elements prototyped as <code>transform (v)</code>. Defaults to <a href="index.html#identity">identity</a> + (<em>optional</em>) + </li> + <li><span class="parameter">comp</span> + a comparison function, defaults to the <code><</code> operator + (<em>optional</em>) </li> </ul> <h3>Returns:</h3> <ol> - <code>true</code> or <code>false</code> + a new array of sorted values </ol> <h3>See also:</h3> <ul> - <a href="index.html#containsKeys">containsKeys</a> + <a href="index.html#sort">sort</a> + </ul> + + +</dd> + <dt> + <a name = "where"></a> + <strong>where (t, props)</strong> + </dt> + <dd> + Returns all values having specified keys <code>props</code>. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">t</span> + a table + </li> + <li><span class="parameter">props</span> + a set of keys + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + an array of values from the passed-in table + </ol> + + + <h3>See also:</h3> + <ul> + <a href="index.html#findWhere">findWhere</a> </ul> @@ -1774,13 +2519,12 @@ <dl class="function"> <dt> - <a name = "sample"></a> - <strong>sample (array[, n[, seed]])</strong> + <a name = "addTop"></a> + <strong>addTop (array, ...)</strong> </dt> <dd> - Samples <code>n</code> random values from an array. If <code>n</code> is not specified, returns a single element. - It uses internally <a href="index.html#shuffle">shuffle</a> to shuffle the array before sampling values. If <code>seed</code> is passed, - it will be used for shuffling. + Adds all passed-in values at the top of an array. The last elements will bubble to the + top of the given array. <h3>Parameters:</h3> @@ -1788,38 +2532,33 @@ <li><span class="parameter">array</span> an array </li> - <li><span class="parameter">n</span> - a number of elements to be sampled. Defaults to 1. - (<em>optional</em>) - </li> - <li><span class="parameter">seed</span> - an optional seed for shuffling - (<em>optional</em>) + <li><span class="parameter">...</span> + a variable number of arguments </li> </ul> <h3>Returns:</h3> <ol> - an array of selected values or a single value when <code>n</code> == 1 + the passed-in array with new values added </ol> <h3>See also:</h3> <ul> - <a href="index.html#sampleProb">sampleProb</a> + <li><a href="index.html#prepend">prepend</a></li> + <li><a href="index.html#push">push</a></li> </ul> </dd> <dt> - <a name = "sampleProb"></a> - <strong>sampleProb (array, prob[, seed])</strong> + <a name = "aperture"></a> + <strong>aperture (array[, n])</strong> </dt> <dd> - Return elements from a sequence with a given probability. It considers each value independently. - Providing a seed will result in deterministic sampling. Given the same seed it will return the same sample - every time. + Iterator returning sliding partitions of an array. + <br/><em>Aliased as <code>sliding</code></em> <h3>Parameters:</h3> @@ -1827,11 +2566,8 @@ <li><span class="parameter">array</span> an array </li> - <li><span class="parameter">prob</span> - a probability for each element in array to be selected - </li> - <li><span class="parameter">seed</span> - an optional seed for deterministic sampling + <li><span class="parameter">n</span> + the size of partitions. Defaults to 2 (and then behaves like <a href="index.html#pairwise">pairwise</a>) (<em>optional</em>) </li> </ul> @@ -1839,36 +2575,41 @@ <h3>Returns:</h3> <ol> - an array of selected values + an iterator function </ol> <h3>See also:</h3> <ul> - <a href="index.html#sample">sample</a> + <li><a href="index.html#partition">partition</a></li> + <li><a href="index.html#overlapping">overlapping</a></li> + <li><a href="index.html#pairwise">pairwise</a></li> </ul> </dd> <dt> - <a name = "toArray"></a> - <strong>toArray (...)</strong> + <a name = "append"></a> + <strong>append (array, other)</strong> </dt> <dd> - Converts a list of arguments to an array. + Clones array and appends values from another array. <h3>Parameters:</h3> <ul> - <li><span class="parameter">...</span> - a list of arguments + <li><span class="parameter">array</span> + an array + </li> + <li><span class="parameter">other</span> + an array </li> </ul> <h3>Returns:</h3> <ol> - an array of all passed-in args + a new array </ol> @@ -1876,24 +2617,25 @@ </dd> <dt> - <a name = "find"></a> - <strong>find (array, value[, from])</strong> + <a name = "chunk"></a> + <strong>chunk (array, f[, ...])</strong> </dt> <dd> - Looks for the first occurrence of a given value in an array. Returns the value index if found. - Uses <a href="index.html#isEqual">isEqual</a> to compare values. + Chunks together consecutive values. Values are chunked on the basis of the return + value of a provided predicate <code>f (k, v, ...)</code>. Consecutive elements which return + the same value are chunked together. Leaves the first argument untouched if it is not an array. <h3>Parameters:</h3> <ul> <li><span class="parameter">array</span> - an array of values + an array </li> - <li><span class="parameter">value</span> - a value to lookup for + <li><span class="parameter">f</span> + an iterator function prototyped as <code>f (v, k, ...)</code> </li> - <li><span class="parameter">from</span> - the index from where the search will start. Defaults to 1. + <li><span class="parameter">...</span> + Optional args to be passed to <code>f</code> (<em>optional</em>) </li> </ul> @@ -1901,19 +2643,23 @@ <h3>Returns:</h3> <ol> - the index of the value if found in the array, <code>nil</code> otherwise. + a table of chunks (arrays) </ol> + <h3>See also:</h3> + <ul> + <a href="index.html#zip">zip</a> + </ul> </dd> <dt> - <a name = "reverse"></a> - <strong>reverse (array)</strong> + <a name = "compact"></a> + <strong>compact (array)</strong> </dt> <dd> - Returns an array where values are in reverse order. The passed-in array should not be sparse. + Returns all truthy values (removes <code>falses</code> and <code>nils</code>). <h3>Parameters:</h3> @@ -1926,7 +2672,7 @@ <h3>Returns:</h3> <ol> - a reversed array + a new array </ol> @@ -1934,29 +2680,31 @@ </dd> <dt> - <a name = "fill"></a> - <strong>fill (array, value[, i[, j]])</strong> + <a name = "concat"></a> + <strong>concat (array[, sep[, i[, j]]])</strong> </dt> <dd> - Replaces elements in a given array with a given value. In case <code>i</code> and <code>j</code> are given - it will only replaces values at indexes between <code>[i,j]</code>. In case <code>j</code> is greather than the array - size, it will append new values, increasing the array. + Concatenates values in a given array. Handles booleans as well. If <code>sep</code> string is + passed, it will be used as a separator. Passing <code>i</code> and <code>j</code> will result in concatenating + only values within <code>[i, j]</code> range. + <br/><em>Aliased as <code>join</code></em> <h3>Parameters:</h3> <ul> <li><span class="parameter">array</span> - an array + a given array </li> - <li><span class="parameter">value</span> - a value + <li><span class="parameter">sep</span> + a separator string, defaults to the empty string <code>''</code>. + (<em>optional</em>) </li> <li><span class="parameter">i</span> - the index from which to start replacing values. Defaults to 1. + the starting index, defaults to 1. (<em>optional</em>) </li> <li><span class="parameter">j</span> - the index where to stop replacing values. Defaults to the array size. + the final index, defaults to the array length. (<em>optional</em>) </li> </ul> @@ -1964,7 +2712,7 @@ <h3>Returns:</h3> <ol> - the original array with values changed + a string </ol> @@ -1972,13 +2720,12 @@ </dd> <dt> - <a name = "selectWhile"></a> - <strong>selectWhile (array, f[, ...])</strong> + <a name = "difference"></a> + <strong>difference (array, another)</strong> </dt> <dd> - Collects values from a given array. The passed-in array should not be sparse. - This function collects values as long as they satisfy a given predicate and returns on the first falsy test. - <br/><em>Aliased as <code>takeWhile</code></em> + Returns values from an array not present in all passed-in args. + <br/><em>Aliased as <code>without</code> and <code>diff</code></em> <h3>Parameters:</h3> @@ -1986,25 +2733,23 @@ <li><span class="parameter">array</span> an array </li> - <li><span class="parameter">f</span> - an iterator function prototyped as <code>f (k, v, …)</code> - </li> - <li><span class="parameter">...</span> - Optional args to be passed to <code>f</code> - (<em>optional</em>) + <li><span class="parameter">another</span> + array </li> </ul> <h3>Returns:</h3> <ol> - a new table containing all values collected + a new array </ol> <h3>See also:</h3> <ul> - <a href="index.html#dropWhile">dropWhile</a> + <li><a href="index.html#union">union</a></li> + <li><a href="index.html#intersection">intersection</a></li> + <li><a href="index.html#symmetricDifference">symmetricDifference</a></li> </ul> @@ -2025,7 +2770,7 @@ an array </li> <li><span class="parameter">f</span> - an iterator function prototyped as <code>f (k,v, …)</code> + an iterator function prototyped as <code>f (v, k, ...)</code> </li> <li><span class="parameter">...</span> Optional args to be passed to <code>f</code> @@ -2040,17 +2785,21 @@ </ol> + <h3>See also:</h3> + <ul> + <a href="index.html#selectWhile">selectWhile</a> + </ul> </dd> <dt> - <a name = "sortedIndex"></a> - <strong>sortedIndex (array, the[, comp[, sort]])</strong> + <a name = "fill"></a> + <strong>fill (array, value[, i[, j]])</strong> </dt> <dd> - Returns the index at which a value should be inserted. This index is evaluated so - that it maintains the sort. If a comparison function is passed, it will be used to sort - values. + Replaces elements in a given array with a given value. In case <code>i</code> and <code>j</code> are given + it will only replaces values at indexes between <code>[i,j]</code>. In case <code>j</code> is greater than the array + size, it will append new values, increasing the array size. <h3>Parameters:</h3> @@ -2058,15 +2807,15 @@ <li><span class="parameter">array</span> an array </li> - <li><span class="parameter">the</span> - value to be inserted + <li><span class="parameter">value</span> + a value </li> - <li><span class="parameter">comp</span> - an comparison function prototyped as <code>f (a, b)</code>, defaults to <tt><</tt> operator. + <li><span class="parameter">i</span> + the index from which to start replacing values. Defaults to 1. (<em>optional</em>) </li> - <li><span class="parameter">sort</span> - whether or not the passed-in array should be sorted + <li><span class="parameter">j</span> + the index where to stop replacing values. Defaults to the array size. (<em>optional</em>) </li> </ul> @@ -2074,7 +2823,7 @@ <h3>Returns:</h3> <ol> - number the index at which the passed-in value should be inserted + the original array with values changed </ol> @@ -2082,43 +2831,48 @@ </dd> <dt> - <a name = "indexOf"></a> - <strong>indexOf (array, value)</strong> + <a name = "find"></a> + <strong>find (array, value[, from])</strong> </dt> <dd> - Returns the index of the first occurence of value in an array. + Looks for the first occurrence of a given value in an array. Returns the value index if found. + Uses <a href="index.html#isEqual">isEqual</a> to compare values. <h3>Parameters:</h3> <ul> <li><span class="parameter">array</span> - an array + an array of values </li> <li><span class="parameter">value</span> - the value to search for + a value to lookup for + </li> + <li><span class="parameter">from</span> + the index from where the search will start. Defaults to 1. + (<em>optional</em>) </li> </ul> <h3>Returns:</h3> <ol> - the index of the passed-in value + the index of the value if found in the array, <code>nil</code> otherwise. </ol> <h3>See also:</h3> <ul> - <a href="index.html#lastIndexOf">lastIndexOf</a> + <a href="index.html#detect">detect</a> </ul> </dd> <dt> - <a name = "lastIndexOf"></a> - <strong>lastIndexOf (array, value)</strong> + <a name = "findIndex"></a> + <strong>findIndex (array, predicate[, ...])</strong> </dt> <dd> - Returns the index of the last occurrence of value in an array. + Returns the first index at which a predicate returns true. <h3>Parameters:</h3> @@ -2126,31 +2880,35 @@ <li><span class="parameter">array</span> an array </li> - <li><span class="parameter">value</span> - the value to search for + <li><span class="parameter">predicate</span> + a predicate function prototyped as <code>predicate (v, k, ...)</code> + </li> + <li><span class="parameter">...</span> + optional arguments to <code>pred</code> + (<em>optional</em>) </li> </ul> <h3>Returns:</h3> <ol> - the index of the last occurrence of the passed-in value or <strong>nil</strong> + the index found or <strong>nil</strong> </ol> <h3>See also:</h3> <ul> - <a href="index.html#indexOf">indexOf</a> + <a href="index.html#findLastIndex">findLastIndex</a> </ul> </dd> <dt> - <a name = "findIndex"></a> - <strong>findIndex (array, predicate[, ...])</strong> + <a name = "findLastIndex"></a> + <strong>findLastIndex (array, predicate[, ...])</strong> </dt> <dd> - Returns the first index at which a predicate returns true. + Returns the last index at which a predicate returns true. <h3>Parameters:</h3> @@ -2159,7 +2917,7 @@ an array </li> <li><span class="parameter">predicate</span> - a predicate function prototyped as <code>predicate (k, v, …)</code> + a predicate function prototyped as <code>predicate (k, v, ...)</code> </li> <li><span class="parameter">...</span> optional arguments to <code>pred</code> @@ -2176,17 +2934,18 @@ <h3>See also:</h3> <ul> - <a href="index.html#findLastIndex">findLastIndex</a> + <a href="index.html#findIndex">findIndex</a> </ul> </dd> <dt> - <a name = "findLastIndex"></a> - <strong>findLastIndex (array, predicate[, ...])</strong> + <a name = "first"></a> + <strong>first (array[, n])</strong> </dt> <dd> - Returns the last index at which a predicate returns true. + Returns the first N values in an array. + <br/><em>Aliased as <code>head</code>, <code>take</code> </em> <h3>Parameters:</h3> @@ -2194,11 +2953,8 @@ <li><span class="parameter">array</span> an array </li> - <li><span class="parameter">predicate</span> - a predicate function prototyped as <code>predicate (k, v, …)</code> - </li> - <li><span class="parameter">...</span> - optional arguments to <code>pred</code> + <li><span class="parameter">n</span> + the number of values to be collected, defaults to 1. (<em>optional</em>) </li> </ul> @@ -2206,24 +2962,25 @@ <h3>Returns:</h3> <ol> - the index found or <strong>nil</strong> + a new array </ol> <h3>See also:</h3> <ul> - <a href="index.html#findIndex">findIndex</a> + <li><a href="index.html#initial">initial</a></li> + <li><a href="index.html#last">last</a></li> + <li><a href="index.html#rest">rest</a></li> </ul> </dd> <dt> - <a name = "addTop"></a> - <strong>addTop (array, ...)</strong> + <a name = "flatten"></a> + <strong>flatten (array[, shallow])</strong> </dt> <dd> - Adds all passed-in values at the top of an array. The last elements will bubble to the - top of the given array. + Flattens a nested array. Passing <code>shallow</code> will only flatten at the first level. <h3>Parameters:</h3> @@ -2231,31 +2988,28 @@ <li><span class="parameter">array</span> an array </li> - <li><span class="parameter">...</span> - a variable number of arguments + <li><span class="parameter">shallow</span> + specifies the flattening depth. Defaults to <code>false</code>.` + (<em>optional</em>) </li> </ul> <h3>Returns:</h3> <ol> - the passed-in array with new values added + a flattened array </ol> - <h3>See also:</h3> - <ul> - <a href="index.html#push">push</a> - </ul> </dd> <dt> - <a name = "push"></a> - <strong>push (array, ...)</strong> + <a name = "indexOf"></a> + <strong>indexOf (array, value)</strong> </dt> <dd> - Pushes all passed-in values at the end of an array. + Returns the index of the first occurrence of value in an array. <h3>Parameters:</h3> @@ -2263,32 +3017,31 @@ <li><span class="parameter">array</span> an array </li> - <li><span class="parameter">...</span> - a variable number of arguments + <li><span class="parameter">value</span> + the value to search for </li> </ul> <h3>Returns:</h3> <ol> - the passed-in array with new added values + the index of the passed-in value </ol> <h3>See also:</h3> <ul> - <a href="index.html#addTop">addTop</a> + <a href="index.html#lastIndexOf">lastIndexOf</a> </ul> </dd> <dt> - <a name = "pop"></a> - <strong>pop (array[, n])</strong> + <a name = "initial"></a> + <strong>initial (array[, n])</strong> </dt> <dd> - Removes and returns the values at the top of a given array. - <br/><em>Aliased as <code>shift</code></em> + Returns all values in an array excluding the last N values. <h3>Parameters:</h3> @@ -2297,7 +3050,7 @@ an array </li> <li><span class="parameter">n</span> - the number of values to be popped. Defaults to 1. + the number of values to be left, defaults to the array length. (<em>optional</em>) </li> </ul> @@ -2305,57 +3058,56 @@ <h3>Returns:</h3> <ol> - the popped values + a new array </ol> <h3>See also:</h3> <ul> - <a href="index.html#unshift">unshift</a> + <li><a href="index.html#first">first</a></li> + <li><a href="index.html#last">last</a></li> + <li><a href="index.html#rest">rest</a></li> </ul> </dd> <dt> - <a name = "unshift"></a> - <strong>unshift (array[, n])</strong> + <a name = "interleave"></a> + <strong>interleave (...)</strong> </dt> <dd> - Removes and returns the values at the end of a given array. + Interleaves arrays. It returns a single array made of values from all + passed in arrays in their given order, interleaved. <h3>Parameters:</h3> <ul> - <li><span class="parameter">array</span> - an array - </li> - <li><span class="parameter">n</span> - the number of values to be unshifted. Defaults to 1. - (<em>optional</em>) + <li><span class="parameter">...</span> + a variable list of arrays </li> </ul> <h3>Returns:</h3> <ol> - the values + a new array </ol> <h3>See also:</h3> <ul> - <a href="index.html#pop">pop</a> + <a href="index.html#interpose">interpose</a> </ul> </dd> <dt> - <a name = "pull"></a> - <strong>pull (array, ...)</strong> + <a name = "interpose"></a> + <strong>interpose (array, value)</strong> </dt> <dd> - Removes all provided values in a given array. - <br/><em>Aliased as <code>remove</code></em> + Interposes value in-between consecutive pair of values in array. + <br/><em>Aliased as <code>intersperse</code></em> <h3>Parameters:</h3> @@ -2363,28 +3115,32 @@ <li><span class="parameter">array</span> an array </li> - <li><span class="parameter">...</span> - a variable number of values to be removed from the array + <li><span class="parameter">value</span> + a value </li> </ul> <h3>Returns:</h3> <ol> - the passed-in array with values removed + a new array </ol> + <h3>See also:</h3> + <ul> + <a href="index.html#interleave">interleave</a> + </ul> </dd> <dt> - <a name = "removeRange"></a> - <strong>removeRange (array[, start[, finish]])</strong> + <a name = "intersection"></a> + <strong>intersection (array, ...)</strong> </dt> <dd> - Removes values at index within the range <code>[start, finish]</code>. - <br/><em>Aliased as <code>rmRange</code>, <code>chop</code></em> + Returns the intersection of all passed-in arrays. + Each value in the result is present in each of the passed-in arrays. <h3>Parameters:</h3> @@ -2392,71 +3148,62 @@ <li><span class="parameter">array</span> an array </li> - <li><span class="parameter">start</span> - the lower bound index, defaults to the first index in the array. - (<em>optional</em>) - </li> - <li><span class="parameter">finish</span> - the upper bound index, defaults to the array length. - (<em>optional</em>) + <li><span class="parameter">...</span> + a variable number of array arguments </li> </ul> <h3>Returns:</h3> <ol> - the passed-in array with values removed + a new array </ol> + <h3>See also:</h3> + <ul> + <li><a href="index.html#difference">difference</a></li> + <li><a href="index.html#union">union</a></li> + <li><a href="index.html#symmetricDifference">symmetricDifference</a></li> + </ul> </dd> <dt> - <a name = "chunk"></a> - <strong>chunk (array, f[, ...])</strong> + <a name = "invert"></a> + <strong>invert (array)</strong> </dt> <dd> - Chunks together consecutive values. Values are chunked on the basis of the return - value of a provided predicate <code>f (k, v, …)</code>. Consecutive elements which return - the same value are chunked together. Leaves the first argument untouched if it is not an array. + Swaps keys with values. Produces a new array where previous keys are now values, + while previous values are now keys. + <br/><em>Aliased as <code>mirror</code></em> <h3>Parameters:</h3> <ul> <li><span class="parameter">array</span> - an array - </li> - <li><span class="parameter">f</span> - an iterator function prototyped as <code>f (k, v, …)</code> - </li> - <li><span class="parameter">...</span> - Optional args to be passed to <code>f</code> - (<em>optional</em>) + a given array </li> </ul> <h3>Returns:</h3> <ol> - a table of chunks (arrays) + a new array </ol> - <h3>See also:</h3> - <ul> - <a href="index.html#zip">zip</a> - </ul> </dd> <dt> - <a name = "slice"></a> - <strong>slice (array[, start[, finish]])</strong> + <a name = "isunique"></a> + <strong>isunique (array)</strong> </dt> <dd> - Slices values indexed within <code>[start, finish]</code> range. - <br/><em>Aliased as <code>_.sub</code></em> + Checks if a given array contains distinct values. Such an array is made of distinct elements, + which only occur once in this array. + <br/><em>Aliased as <code>isuniq</code></em> <h3>Parameters:</h3> @@ -2464,33 +3211,28 @@ <li><span class="parameter">array</span> an array </li> - <li><span class="parameter">start</span> - the lower bound index, defaults to the first index in the array. - (<em>optional</em>) - </li> - <li><span class="parameter">finish</span> - the upper bound index, defaults to the array length. - (<em>optional</em>) - </li> </ul> <h3>Returns:</h3> <ol> - a new array of sliced values + <code>true</code> if the given array is unique, <code>false</code> otherwise. </ol> + <h3>See also:</h3> + <ul> + <a href="index.html#unique">unique</a> + </ul> </dd> <dt> - <a name = "first"></a> - <strong>first (array[, n])</strong> + <a name = "last"></a> + <strong>last (array[, n])</strong> </dt> <dd> - Returns the first N values in an array. - <br/><em>Aliased as <code>head</code>, <code>take</code></em> + Returns the last N values in an array. <h3>Parameters:</h3> @@ -2499,7 +3241,7 @@ an array </li> <li><span class="parameter">n</span> - the number of values to be collected, defaults to 1. + the number of values to be collected, defaults to the array length. (<em>optional</em>) </li> </ul> @@ -2513,19 +3255,19 @@ <h3>See also:</h3> <ul> + <li><a href="index.html#first">first</a></li> <li><a href="index.html#initial">initial</a></li> - <li><a href="index.html#last">last</a></li> <li><a href="index.html#rest">rest</a></li> </ul> </dd> <dt> - <a name = "initial"></a> - <strong>initial (array[, n])</strong> + <a name = "lastIndexOf"></a> + <strong>lastIndexOf (array, value)</strong> </dt> <dd> - Returns all values in an array excluding the last N values. + Returns the index of the last occurrence of value in an array. <h3>Parameters:</h3> @@ -2533,95 +3275,84 @@ <li><span class="parameter">array</span> an array </li> - <li><span class="parameter">n</span> - the number of values to be left, defaults to the array length. - (<em>optional</em>) + <li><span class="parameter">value</span> + the value to search for </li> </ul> <h3>Returns:</h3> <ol> - a new array + the index of the last occurrence of the passed-in value or <strong>nil</strong> </ol> <h3>See also:</h3> <ul> - <li><a href="index.html#first">first</a></li> - <li><a href="index.html#last">last</a></li> - <li><a href="index.html#rest">rest</a></li> + <a href="index.html#indexOf">indexOf</a> </ul> </dd> <dt> - <a name = "last"></a> - <strong>last (array[, n])</strong> + <a name = "mean"></a> + <strong>mean (array)</strong> </dt> <dd> - Returns the last N values in an array. + Returns the mean of an array of numbers. + <br/><em>Aliased as <code>average</code></em> <h3>Parameters:</h3> <ul> <li><span class="parameter">array</span> - an array - </li> - <li><span class="parameter">n</span> - the number of values to be collected, defaults to the array length. - (<em>optional</em>) + an array of numbers </li> </ul> <h3>Returns:</h3> <ol> - a new array + a number </ol> <h3>See also:</h3> <ul> - <li><a href="index.html#first">first</a></li> - <li><a href="index.html#initial">initial</a></li> - <li><a href="index.html#rest">rest</a></li> + <li><a href="index.html#sum">sum</a></li> + <li><a href="index.html#product">product</a></li> + <li><a href="index.html#median">median</a></li> </ul> </dd> <dt> - <a name = "rest"></a> - <strong>rest (array[, index])</strong> + <a name = "median"></a> + <strong>median (array)</strong> </dt> <dd> - Removes all values before index. - <br/><em>Aliased as <code>tail</code></em> + Returns the median of an array of numbers. <h3>Parameters:</h3> <ul> <li><span class="parameter">array</span> - an array - </li> - <li><span class="parameter">index</span> - an index, defaults to 1 - (<em>optional</em>) + an array of numbers </li> </ul> <h3>Returns:</h3> <ol> - a new array + a number </ol> <h3>See also:</h3> <ul> - <li><a href="index.html#first">first</a></li> - <li><a href="index.html#initial">initial</a></li> - <li><a href="index.html#last">last</a></li> + <li><a href="index.html#sum">sum</a></li> + <li><a href="index.html#product">product</a></li> + <li><a href="index.html#mean">mean</a></li> </ul> @@ -2655,36 +3386,43 @@ </dd> <dt> - <a name = "compact"></a> - <strong>compact (array)</strong> + <a name = "ones"></a> + <strong>ones (n)</strong> </dt> <dd> - Removes all falsy (false and nil) values. + Returns an array of <code>n</code> 1's. <h3>Parameters:</h3> <ul> - <li><span class="parameter">array</span> - an array + <li><span class="parameter">n</span> + a number </li> </ul> <h3>Returns:</h3> <ol> - a new array + an array </ol> + <h3>See also:</h3> + <ul> + <li><a href="index.html#zeros">zeros</a></li> + <li><a href="index.html#vector">vector</a></li> + </ul> </dd> <dt> - <a name = "flatten"></a> - <strong>flatten (array[, shallow])</strong> + <a name = "overlapping"></a> + <strong>overlapping (array[, n[, pads]])</strong> </dt> <dd> - Flattens a nested array. Passing <code>shallow</code> will only flatten at the first level. + Iterator returning overlapping partitions of an array. <br/> + If the last subsequence has lower elements than <code>n</code> and <code>pad</code> is + supplied, it will be adjusted to <code>n</code> elements with <code>pad</code> value. <h3>Parameters:</h3> @@ -2692,8 +3430,12 @@ <li><span class="parameter">array</span> an array </li> - <li><span class="parameter">shallow</span> - specifies the flattening depth + <li><span class="parameter">n</span> + the size of partitions. Defaults to 2. + (<em>optional</em>) + </li> + <li><span class="parameter">pads</span> + a value to adjust the last subsequence to the <code>n</code> elements (<em>optional</em>) </li> </ul> @@ -2701,20 +3443,24 @@ <h3>Returns:</h3> <ol> - a new array, flattened + an iterator function </ol> + <h3>See also:</h3> + <ul> + <li><a href="index.html#partition">partition</a></li> + <li><a href="index.html#aperture">aperture</a></li> + </ul> </dd> <dt> - <a name = "difference"></a> - <strong>difference (array, another)</strong> + <a name = "pairwise"></a> + <strong>pairwise (array)</strong> </dt> <dd> - Returns values from an array not present in all passed-in args. - <br/><em>Aliased as <code>without</code> and <code>diff</code></em> + Iterator returning sliding pairs of an array. <h3>Parameters:</h3> @@ -2722,65 +3468,69 @@ <li><span class="parameter">array</span> an array </li> - <li><span class="parameter">another</span> - array - </li> </ul> <h3>Returns:</h3> <ol> - a new array + an iterator function </ol> <h3>See also:</h3> <ul> - <li><a href="index.html#union">union</a></li> - <li><a href="index.html#intersection">intersection</a></li> - <li><a href="index.html#symmetricDifference">symmetricDifference</a></li> + <a href="index.html#overlapping">overlapping</a> </ul> </dd> <dt> - <a name = "union"></a> - <strong>union (...)</strong> + <a name = "partition"></a> + <strong>partition (array[, n[, pads]])</strong> </dt> <dd> - Returns the duplicate-free union of all passed in arrays. + Iterator returning partitions of an array. It returns arrays of length <code>n</code> + made of values from the given array. If the last partition has lower elements than <code>n</code> and + <code>pad</code> is supplied, it will be adjusted to <code>n</code> of elements with <code>pad</code> value. <h3>Parameters:</h3> <ul> - <li><span class="parameter">...</span> - a variable number of arrays arguments + <li><span class="parameter">array</span> + an array + </li> + <li><span class="parameter">n</span> + the size of partitions. Defaults to 1. + (<em>optional</em>) + </li> + <li><span class="parameter">pads</span> + a value to adjust the last subsequence to the <code>n</code> elements + (<em>optional</em>) </li> </ul> <h3>Returns:</h3> <ol> - a new array + an iterator function </ol> <h3>See also:</h3> <ul> - <li><a href="index.html#difference">difference</a></li> - <li><a href="index.html#intersection">intersection</a></li> - <li><a href="index.html#symmetricDifference">symmetricDifference</a></li> + <li><a href="index.html#overlapping">overlapping</a></li> + <li><a href="index.html#aperture">aperture</a></li> </ul> </dd> <dt> - <a name = "intersection"></a> - <strong>intersection (array, ...)</strong> + <a name = "permutation"></a> + <strong>permutation (array)</strong> </dt> <dd> - Returns the intersection of all passed-in arrays. - Each value in the result is present in each of the passed-in arrays. + Iterator returning the permutations of an array. It returns arrays made of all values + from the passed-in array, with values permuted. <h3>Parameters:</h3> @@ -2788,35 +3538,51 @@ <li><span class="parameter">array</span> an array </li> - <li><span class="parameter">...</span> - a variable number of array arguments - </li> </ul> <h3>Returns:</h3> <ol> - a new array + an iterator function </ol> - <h3>See also:</h3> + + +</dd> + <dt> + <a name = "powerset"></a> + <strong>powerset (array)</strong> + </dt> + <dd> + Returns the powerset of array values. For instance, when given the set {1,2,3}, + returns <code>{{1},{2},{3},{1,2},{2,3},{1,2,3}}</code>. + + + <h3>Parameters:</h3> <ul> - <li><a href="index.html#difference">difference</a></li> - <li><a href="index.html#union">union</a></li> - <li><a href="index.html#symmetricDifference">symmetricDifference</a></li> + <li><span class="parameter">array</span> + an array + </li> </ul> + <h3>Returns:</h3> + <ol> + + an array + </ol> + + + </dd> <dt> - <a name = "symmetricDifference"></a> - <strong>symmetricDifference (array, array2)</strong> + <a name = "prepend"></a> + <strong>prepend (array, ...)</strong> </dt> <dd> - Performs a symmetric difference. Returns values from <a href="index.html#array">array</a> not present in <code>array2</code> and also values - from <code>array2</code> not present in <a href="index.html#array">array</a>. - <br/><em>Aliased as <code>symdiff</code></em> + Adds all passed-in values at the top of an array. As opposed to <a href="index.html#addTop">addTop</a>, it preserves the order + of the passed in elements. <h3>Parameters:</h3> @@ -2824,65 +3590,86 @@ <li><span class="parameter">array</span> an array </li> - <li><span class="parameter">array2</span> - another array + <li><span class="parameter">...</span> + a variable number of arguments </li> </ul> <h3>Returns:</h3> <ol> - a new array + the passed-in array with new values added </ol> <h3>See also:</h3> <ul> - <li><a href="index.html#difference">difference</a></li> - <li><a href="index.html#union">union</a></li> - <li><a href="index.html#intersection">intersection</a></li> + <li><a href="index.html#addTop">addTop</a></li> + <li><a href="index.html#push">push</a></li> </ul> </dd> <dt> - <a name = "unique"></a> - <strong>unique (array)</strong> + <a name = "product"></a> + <strong>product (array)</strong> </dt> <dd> - Produces a duplicate-free version of a given array. - <br/><em>Aliased as <code>uniq</code></em> + Returns the product of array values. <h3>Parameters:</h3> <ul> <li><span class="parameter">array</span> - an array + a given array </li> </ul> <h3>Returns:</h3> <ol> - a new array, duplicate-free + the product of array values </ol> - <h3>See also:</h3> + + +</dd> + <dt> + <a name = "pull"></a> + <strong>pull (array, ...)</strong> + </dt> + <dd> + Removes all provided values in a given array. + <br/><em>Aliased as <code>remove</code></em> + + + <h3>Parameters:</h3> <ul> - <a href="index.html#isunique">isunique</a> + <li><span class="parameter">array</span> + an array + </li> + <li><span class="parameter">...</span> + a variable number of values to be removed from the array + </li> </ul> + <h3>Returns:</h3> + <ol> + + the passed-in array with values removed + </ol> + + + </dd> <dt> - <a name = "isunique"></a> - <strong>isunique (array)</strong> + <a name = "push"></a> + <strong>push (array, ...)</strong> </dt> <dd> - Checks if a given array contains distinct values. Such an array is made of distinct elements, - which only occur once in this array. - <br/><em>Aliased as <code>isuniq</code></em> + Pushes all passed-in values at the end of an array. <h3>Parameters:</h3> @@ -2890,43 +3677,56 @@ <li><span class="parameter">array</span> an array </li> + <li><span class="parameter">...</span> + a variable number of arguments + </li> </ul> <h3>Returns:</h3> <ol> - <code>true</code> if the given array is unique, <code>false</code> otherwise. + the passed-in array with new added values </ol> <h3>See also:</h3> <ul> - <a href="index.html#unique">unique</a> + <li><a href="index.html#addTop">addTop</a></li> + <li><a href="index.html#prepend">prepend</a></li> </ul> </dd> <dt> - <a name = "zip"></a> - <strong>zip (...)</strong> + <a name = "range"></a> + <strong>range ([from[, to[, step]]])</strong> </dt> <dd> - Merges values of each of the passed-in arrays in subsets. - Only values indexed with the same key in the given arrays are merged in the same subset. - <br/><em>Aliased as <code>transpose</code></em> + Produces a flexible list of numbers. If one value is passed, will count from 1 to that value, + with a default step of 1 (or -1). If two values are passed, will count from the first one to the second one, + using a default step of 1 (or -1). A third value passed will be considered a step value. <h3>Parameters:</h3> <ul> - <li><span class="parameter">...</span> - a variable number of array arguments + <li><span class="parameter">from</span> + the initial value of the range + (<em>optional</em>) + </li> + <li><span class="parameter">to</span> + the final value of the range + (<em>optional</em>) + </li> + <li><span class="parameter">step</span> + the step of count. Defaults to 1 or -1. + (<em>optional</em>) </li> </ul> <h3>Returns:</h3> <ol> - a new array + a new array of numbers </ol> @@ -2934,11 +3734,12 @@ </dd> <dt> - <a name = "append"></a> - <strong>append (array, other)</strong> + <a name = "removeRange"></a> + <strong>removeRange (array[, start[, finish]])</strong> </dt> <dd> - Clones <a href="index.html#array">array</a> and appends <code>other</code> values. + Removes values at an index within the range <code>[start, finish]</code>. + <br/><em>Aliased as <code>rmRange</code>, <code>chop</code></em> <h3>Parameters:</h3> @@ -2946,15 +3747,20 @@ <li><span class="parameter">array</span> an array </li> - <li><span class="parameter">other</span> - an array + <li><span class="parameter">start</span> + the lower bound index, defaults to the first index in the array. + (<em>optional</em>) + </li> + <li><span class="parameter">finish</span> + the upper bound index, defaults to the array length. + (<em>optional</em>) </li> </ul> <h3>Returns:</h3> <ol> - a new array + the passed-in array with values removed </ol> @@ -2962,51 +3768,51 @@ </dd> <dt> - <a name = "interleave"></a> - <strong>interleave (...)</strong> + <a name = "rep"></a> + <strong>rep (value, n)</strong> </dt> <dd> - Interleaves arrays. It returns a single array made of values from all - passed in arrays in their given order, interleaved. + Creates an array list of <code>n</code> values, repeated. <h3>Parameters:</h3> <ul> - <li><span class="parameter">...</span> - a variable list of arrays + <li><span class="parameter">value</span> + a value to be repeated + </li> + <li><span class="parameter">n</span> + the number of repetitions of value. </li> </ul> <h3>Returns:</h3> <ol> - a new array + a new array of <code>n</code> values </ol> - <h3>See also:</h3> - <ul> - <a href="index.html#interpose">interpose</a> - </ul> </dd> <dt> - <a name = "interpose"></a> - <strong>interpose (value, array)</strong> + <a name = "rest"></a> + <strong>rest (array[, index])</strong> </dt> <dd> - Interposes value in-between consecutive pair of values in <a href="index.html#array">array</a>. + Returns all values after index. + <br/><em>Aliased as <code>tail</code></em> <h3>Parameters:</h3> <ul> - <li><span class="parameter">value</span> - a value - </li> <li><span class="parameter">array</span> an array </li> + <li><span class="parameter">index</span> + an index, defaults to 1 + (<em>optional</em>) + </li> </ul> <h3>Returns:</h3> @@ -3018,33 +3824,59 @@ <h3>See also:</h3> <ul> - <a href="index.html#interleave">interleave</a> + <li><a href="index.html#first">first</a></li> + <li><a href="index.html#initial">initial</a></li> + <li><a href="index.html#last">last</a></li> </ul> </dd> <dt> - <a name = "range"></a> - <strong>range ([from[, to[, step]]])</strong> + <a name = "reverse"></a> + <strong>reverse (array)</strong> </dt> <dd> - Produces a flexible list of numbers. If one positive value is passed, will count from 0 to that value, - with a default step of 1. If two values are passed, will count from the first one to the second one, with the - same default step of 1. A third value passed will be considered a step value. + Returns an array where values are in reverse order. The passed-in array should not be sparse. <h3>Parameters:</h3> <ul> - <li><span class="parameter">from</span> - the initial value of the range - (<em>optional</em>) + <li><span class="parameter">array</span> + an array </li> - <li><span class="parameter">to</span> - the final value of the range + </ul> + + <h3>Returns:</h3> + <ol> + + a reversed array + </ol> + + + + +</dd> + <dt> + <a name = "sample"></a> + <strong>sample (array[, n[, seed]])</strong> + </dt> + <dd> + Samples <code>n</code> random values from an array. If <code>n</code> is not specified, returns a single element. + It uses internally <a href="index.html#shuffle">shuffle</a> to shuffle the array before sampling values. If <code>seed</code> is passed, + it will be used for shuffling. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">array</span> + an array + </li> + <li><span class="parameter">n</span> + a number of elements to be sampled. Defaults to 1. (<em>optional</em>) </li> - <li><span class="parameter">step</span> - the step of count + <li><span class="parameter">seed</span> + an optional seed for shuffling (<em>optional</em>) </li> </ul> @@ -3052,49 +3884,63 @@ <h3>Returns:</h3> <ol> - a new array of numbers + an array of selected values </ol> + <h3>See also:</h3> + <ul> + <a href="index.html#sampleProb">sampleProb</a> + </ul> </dd> <dt> - <a name = "rep"></a> - <strong>rep (value, n)</strong> + <a name = "sampleProb"></a> + <strong>sampleProb (array, prob[, seed])</strong> </dt> <dd> - Creates an array list of <code>n</code> values, repeated. + Return elements from a sequence with a given probability. It considers each value independently. + Providing a seed will result in deterministic sampling. Given the same seed it will return the same sample + every time. <h3>Parameters:</h3> <ul> - <li><span class="parameter">value</span> - a value to be repeated + <li><span class="parameter">array</span> + an array </li> - <li><span class="parameter">n</span> - the number of repetitions of value. + <li><span class="parameter">prob</span> + a probability for each element in array to be selected + </li> + <li><span class="parameter">seed</span> + an optional seed for deterministic sampling + (<em>optional</em>) </li> </ul> <h3>Returns:</h3> <ol> - a new array of <code>n</code> values + an array of selected values </ol> + <h3>See also:</h3> + <ul> + <a href="index.html#sample">sample</a> + </ul> </dd> <dt> - <a name = "partition"></a> - <strong>partition (array[, n[, pad]])</strong> + <a name = "selectWhile"></a> + <strong>selectWhile (array, f[, ...])</strong> </dt> <dd> - Iterator returning partitions of an array. It returns arrays of length <code>n</code> - made of values from the given array. If the last partition has lower elements than <code>n</code> and - <code>pad</code> is supplied, it will be adjusted to <code>n</code> of elements with <code>pad</code> value. + Collects values from a given array. The passed-in array should not be sparse. + This function collects values as long as they satisfy a given predicate and returns on the first falsy test. + <br/><em>Aliased as <code>takeWhile</code></em> <h3>Parameters:</h3> @@ -3102,12 +3948,11 @@ <li><span class="parameter">array</span> an array </li> - <li><span class="parameter">n</span> - the size of partitions. Should be greater than 0. Defaults to 1. - (<em>optional</em>) + <li><span class="parameter">f</span> + an iterator function prototyped as <code>f (v, k, ...)</code> </li> - <li><span class="parameter">pad</span> - a value to adjust the last subsequence to the <code>n</code> elements + <li><span class="parameter">...</span> + Optional args to be passed to <code>f</code> (<em>optional</em>) </li> </ul> @@ -3115,21 +3960,24 @@ <h3>Returns:</h3> <ol> - an iterator function + a new table containing all values collected </ol> + <h3>See also:</h3> + <ul> + <a href="index.html#dropWhile">dropWhile</a> + </ul> </dd> <dt> - <a name = "sliding."></a> - <strong>sliding. (array[, n[, pad]])</strong> + <a name = "shift"></a> + <strong>shift (array[, n])</strong> </dt> <dd> - Iterator returning sliding partitions of an array. It returns overlapping subsequences - of length <code>n</code>. If the last subsequence has lower elements than <code>n</code> and <code>pad</code> is - supplied, it will be adjusted to <code>n</code> elements with <code>pad</code> value. + Removes and returns the values at the top of a given array. + <br/><em>Aliased as <code>pop</code></em> <h3>Parameters:</h3> @@ -3138,11 +3986,7 @@ an array </li> <li><span class="parameter">n</span> - the size of partitions. Should be greater than 1. Defaults to 2. - (<em>optional</em>) - </li> - <li><span class="parameter">pad</span> - a value to adjust the last subsequence to the <code>n</code> elements + the number of values to be popped. Defaults to 1. (<em>optional</em>) </li> </ul> @@ -3150,20 +3994,24 @@ <h3>Returns:</h3> <ol> - an iterator function + the popped values </ol> + <h3>See also:</h3> + <ul> + <a href="index.html#unshift">unshift</a> + </ul> </dd> <dt> - <a name = "permutation"></a> - <strong>permutation (array)</strong> + <a name = "shuffle"></a> + <strong>shuffle (array[, seed])</strong> </dt> <dd> - Iterator returning the permutations of an array. It returns arrays made of all values - from the passed-in array, with values permuted. + Returns a shuffled copy of a given array. If a seed is provided, it will + be used to init the built-in pseudo random number generator (using <a href="https://www.lua.org/manual/5.1/manual.html#pdf-math.randomseed">math.randomseed</a>). <h3>Parameters:</h3> @@ -3171,12 +4019,16 @@ <li><span class="parameter">array</span> an array </li> + <li><span class="parameter">seed</span> + a seed + (<em>optional</em>) + </li> </ul> <h3>Returns:</h3> <ol> - an iterator function + a shuffled copy of the given array </ol> @@ -3184,26 +4036,33 @@ </dd> <dt> - <a name = "invert"></a> - <strong>invert (array)</strong> + <a name = "slice"></a> + <strong>slice (array[, start[, finish]])</strong> </dt> <dd> - Swaps keys with values. Produces a new array where previous keys are now values, - while previous values are now keys. - <br/><em>Aliased as <code>mirror</code></em> + Slices values indexed within <code>[start, finish]</code> range. + <br/><em>Aliased as <code>M.sub</code></em> <h3>Parameters:</h3> <ul> <li><span class="parameter">array</span> - a given array + an array + </li> + <li><span class="parameter">start</span> + the lower bound index, defaults to the first index in the array. + (<em>optional</em>) + </li> + <li><span class="parameter">finish</span> + the upper bound index, defaults to the array length. + (<em>optional</em>) </li> </ul> <h3>Returns:</h3> <ol> - a new array + a new array of sliced values </ol> @@ -3211,31 +4070,29 @@ </dd> <dt> - <a name = "concat"></a> - <strong>concat (array[, sep[, i[, j]]])</strong> + <a name = "sortedIndex"></a> + <strong>sortedIndex (array, the[, comp[, sort]])</strong> </dt> <dd> - Concatenates values in a given array. Handles booleans as well. If <code>sep</code> string is - passed, it will be used as a separator. Passing <code>i</code> and <code>j</code> will result in concatenating - only values within <code>[i, j]</code> range. - <br/><em>Aliased as <code>join</code></em> + Returns the index at which a value should be inserted. This index is evaluated so + that it maintains the sort. If a comparison function is passed, it will be used to sort + values. <h3>Parameters:</h3> <ul> <li><span class="parameter">array</span> - a given array + an array </li> - <li><span class="parameter">sep</span> - a separator string, defaults to the empty string <code>''</code>. - (<em>optional</em>) + <li><span class="parameter">the</span> + value to be inserted </li> - <li><span class="parameter">i</span> - the starting index, defaults to 1. + <li><span class="parameter">comp</span> + an comparison function prototyped as <code>f (a, b)</code>, defaults to <tt><</tt> operator. (<em>optional</em>) </li> - <li><span class="parameter">j</span> - the final index, defaults to the array length. + <li><span class="parameter">sort</span> + whether or not the passed-in array should be sorted (<em>optional</em>) </li> </ul> @@ -3243,30 +4100,32 @@ <h3>Returns:</h3> <ol> - a string + number the index at which the passed-in value should be inserted </ol> </dd> -</dl> - <h2 class="section-header "><a name="Utility_functions"></a>Utility functions </h2> - - <dl class="function"> <dt> - <a name = "noop"></a> - <strong>noop ()</strong> + <a name = "sum"></a> + <strong>sum (array)</strong> </dt> <dd> - The no-operation function. + Returns the sum of array values. + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">array</span> + a given array + </li> + </ul> <h3>Returns:</h3> <ol> - nothing + the sum of array values </ol> @@ -3274,50 +4133,60 @@ </dd> <dt> - <a name = "identity"></a> - <strong>identity (value)</strong> + <a name = "symmetricDifference"></a> + <strong>symmetricDifference (array, array2)</strong> </dt> <dd> - Returns the passed-in value. This function is used internally - as a default iterator. + Performs a symmetric difference. Returns values from <a href="index.html#array">array</a> not present in <code>array2</code> and also values + from <code>array2</code> not present in <a href="index.html#array">array</a>. + <br/><em>Aliased as <code>symdiff</code></em> <h3>Parameters:</h3> <ul> - <li><span class="parameter">value</span> - a value + <li><span class="parameter">array</span> + an array + </li> + <li><span class="parameter">array2</span> + another array </li> </ul> <h3>Returns:</h3> <ol> - the passed-in value + a new array </ol> + <h3>See also:</h3> + <ul> + <li><a href="index.html#difference">difference</a></li> + <li><a href="index.html#union">union</a></li> + <li><a href="index.html#intersection">intersection</a></li> + </ul> </dd> <dt> - <a name = "constant"></a> - <strong>constant (value)</strong> + <a name = "toArray"></a> + <strong>toArray (...)</strong> </dt> <dd> - Creates a constant function which returns the same output on every call. + Converts a list of arguments to an array. <h3>Parameters:</h3> <ul> - <li><span class="parameter">value</span> - a constant value + <li><span class="parameter">...</span> + a list of arguments </li> </ul> <h3>Returns:</h3> <ol> - a constant function + an array of all passed-in args </ol> @@ -3325,208 +4194,267 @@ </dd> <dt> - <a name = "memoize"></a> - <strong>memoize (f[, hash])</strong> + <a name = "union"></a> + <strong>union (...)</strong> </dt> <dd> - Memoizes a given function by caching the computed result. - Useful for speeding-up slow-running functions. If a <code>hash</code> function is passed, - it will be used to compute hash keys for a set of input values for caching. - <br/><em>Aliased as <code>cache</code></em> + Returns the duplicate-free union of all passed in arrays. <h3>Parameters:</h3> <ul> - <li><span class="parameter">f</span> - a function + <li><span class="parameter">...</span> + a variable number of arrays arguments </li> - <li><span class="parameter">hash</span> - a hash function, defaults to <a href="index.html#identity">identity</a> - (<em>optional</em>) + </ul> + + <h3>Returns:</h3> + <ol> + + a new array + </ol> + + + <h3>See also:</h3> + <ul> + <li><a href="index.html#difference">difference</a></li> + <li><a href="index.html#intersection">intersection</a></li> + <li><a href="index.html#symmetricDifference">symmetricDifference</a></li> + </ul> + + +</dd> + <dt> + <a name = "unique"></a> + <strong>unique (array)</strong> + </dt> + <dd> + Produces a duplicate-free version of a given array. + <br/><em>Aliased as <code>uniq</code></em> + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">array</span> + an array </li> </ul> <h3>Returns:</h3> <ol> - a new function + a new array, duplicate-free </ol> + <h3>See also:</h3> + <ul> + <a href="index.html#isunique">isunique</a> + </ul> </dd> <dt> - <a name = "once"></a> - <strong>once (f)</strong> + <a name = "unshift"></a> + <strong>unshift (array[, n])</strong> </dt> <dd> - Returns a version of <code>f</code> that runs only once. Successive calls to <code>f</code> - will keep yielding the same output, no matter what the passed-in arguments are. - It can be used to initialize variables. + Removes and returns the values at the end of a given array. <h3>Parameters:</h3> <ul> - <li><span class="parameter">f</span> - a function + <li><span class="parameter">array</span> + an array + </li> + <li><span class="parameter">n</span> + the number of values to be unshifted. Defaults to 1. + (<em>optional</em>) </li> </ul> <h3>Returns:</h3> <ol> - a new function + the values </ol> <h3>See also:</h3> <ul> - <li><a href="index.html#before">before</a></li> - <li><a href="index.html#after">after</a></li> + <a href="index.html#shift">shift</a> </ul> </dd> <dt> - <a name = "before"></a> - <strong>before (f, count)</strong> + <a name = "vector"></a> + <strong>vector (value, n)</strong> </dt> <dd> - Returns a version of <code>f</code> that will run no more than <a href="index.html#count">count</a> times. Next calls will - keep yielding the results of the count-th call. + Returns an array of <code>n</code> times a given value. <h3>Parameters:</h3> <ul> - <li><span class="parameter">f</span> - a function + <li><span class="parameter">value</span> + a value </li> - <li><span class="parameter">count</span> - a count + <li><span class="parameter">n</span> + a number </li> </ul> <h3>Returns:</h3> <ol> - a new function + an array </ol> <h3>See also:</h3> <ul> - <li><a href="index.html#once">once</a></li> - <li><a href="index.html#after">after</a></li> + <li><a href="index.html#zeros">zeros</a></li> + <li><a href="index.html#ones">ones</a></li> </ul> </dd> <dt> - <a name = "after"></a> - <strong>after (f, count)</strong> + <a name = "xprod"></a> + <strong>xprod (array, array2)</strong> </dt> <dd> - Returns a version of <code>f</code> that runs on the <code>count-th</code> call. - Useful when dealing with asynchronous tasks. + Returns all possible pairs built from given arrays. <h3>Parameters:</h3> <ul> - <li><span class="parameter">f</span> - a function + <li><span class="parameter">array</span> + a first array </li> - <li><span class="parameter">count</span> - the number of calls before <code>f</code> will start running. + <li><span class="parameter">array2</span> + a second array </li> </ul> <h3>Returns:</h3> <ol> - a new function + an array list of all pairs + </ol> + + + + +</dd> + <dt> + <a name = "zeros"></a> + <strong>zeros (n)</strong> + </dt> + <dd> + Returns an array of <code>n</code> zeros. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">n</span> + a number + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + an array </ol> <h3>See also:</h3> <ul> - <li><a href="index.html#once">once</a></li> - <li><a href="index.html#before">before</a></li> + <li><a href="index.html#ones">ones</a></li> + <li><a href="index.html#vector">vector</a></li> </ul> </dd> <dt> - <a name = "compose"></a> - <strong>compose (...)</strong> + <a name = "zip"></a> + <strong>zip (...)</strong> </dt> <dd> - Composes functions. Each passed-in function consumes the return value of the function that follows. - In math terms, composing the functions <code>f</code>, <code>g</code>, and <code>h</code> produces the function <code>f(g(h(…)))</code>. + Merges values of each of the passed-in arrays in subsets. + Only values indexed with the same key in the given arrays are merged in the same subset. + <br/><em>Aliased as <code>transpose</code></em> <h3>Parameters:</h3> <ul> <li><span class="parameter">...</span> - a variable number of functions + a variable number of array arguments </li> </ul> <h3>Returns:</h3> <ol> - a new function + a new array </ol> <h3>See also:</h3> <ul> - <a href="index.html#pipe">pipe</a> + <a href="index.html#zipWith">zipWith</a> </ul> </dd> <dt> - <a name = "pipe"></a> - <strong>pipe (value, ...)</strong> + <a name = "zipWith"></a> + <strong>zipWith (f, ...)</strong> </dt> <dd> - Pipes a value through a series of functions. In math terms, - given some functions <code>f</code>, <code>g</code>, and <code>h</code> in that order, it returns <code>f(g(h(value)))</code>. + Merges values using a given function. + Only values indexed with the same key in the given arrays are merged in the same subset. + Function <code>f</code> is used to combine values. + <br/><em>Aliased as <code>transposeWith</code></em> <h3>Parameters:</h3> <ul> - <li><span class="parameter">value</span> - a value + <li><span class="parameter">f</span> + a function </li> <li><span class="parameter">...</span> - a variable number of functions + a variable number of array arguments </li> </ul> <h3>Returns:</h3> <ol> - the result of the composition of function calls. + a flat array of results </ol> <h3>See also:</h3> <ul> - <a href="index.html#compose">compose</a> + <a href="index.html#zip">zip</a> </ul> </dd> +</dl> + <h2 class="section-header "><a name="Utility_functions"></a>Utility functions </h2> + + <dl class="function"> <dt> - <a name = "complement"></a> - <strong>complement (f)</strong> + <a name = "after"></a> + <strong>after (f, count)</strong> </dt> <dd> - Returns the logical complement of a given function. For a given input, the returned - function will output <code>false</code> if the original function would have returned <code>true</code>, - and vice-versa. + Returns a version of <code>f</code> that runs on the <code>count-th</code> call. + Useful when dealing with asynchronous tasks. <h3>Parameters:</h3> @@ -3534,42 +4462,73 @@ <li><span class="parameter">f</span> a function </li> + <li><span class="parameter">count</span> + the number of calls before <code>f</code> will start running. + </li> </ul> <h3>Returns:</h3> <ol> - the logical complement of the given function <code>f</code>. + a new function </ol> + <h3>See also:</h3> + <ul> + <li><a href="index.html#once">once</a></li> + <li><a href="index.html#before">before</a></li> + </ul> </dd> <dt> - <a name = "juxtapose"></a> - <strong>juxtapose (value, ...)</strong> + <a name = "applySpec"></a> + <strong>applySpec (specs)</strong> </dt> <dd> - Calls a sequence of passed-in functions with the same argument. - Returns a sequence of results. - <br/><em>Aliased as <code>juxt</code></em> + Returns a function which applies <code>specs</code> on args. This function produces an object having + the same structure than <code>specs</code> by mapping each property to the result of calling its + associated function with the supplied arguments <h3>Parameters:</h3> <ul> - <li><span class="parameter">value</span> - a value + <li><span class="parameter">specs</span> + a table </li> + </ul> + + <h3>Returns:</h3> + <ol> + + a function + </ol> + + + + +</dd> + <dt> + <a name = "array"></a> + <strong>array (...)</strong> + </dt> + <dd> + Iterates over an iterator and returns its values in an array. + <br/><em>Aliased as <code>tabulate</code></em>. + + + <h3>Parameters:</h3> + <ul> <li><span class="parameter">...</span> - a variable number of functions + an iterator function (returning a generator, a state and a value) </li> </ul> <h3>Returns:</h3> <ol> - a list of results + an array of results </ol> @@ -3577,63 +4536,70 @@ </dd> <dt> - <a name = "wrap"></a> - <strong>wrap (f, wrapper)</strong> + <a name = "ary"></a> + <strong>ary (f[, n])</strong> </dt> <dd> - Wraps <code>f</code> inside of the <code>wrapper</code> function. It passes <code>f</code> as the first argument to <code>wrapper</code>. - This allows the wrapper to execute code before and after <code>f</code> runs, - adjust the arguments, and execute it conditionally. + Returns a function which accepts up to <code>n</code> args. It ignores any additional arguments. + <br/><em>Aliased as <code>nAry</code></em>. <h3>Parameters:</h3> <ul> <li><span class="parameter">f</span> - a function to be wrapped, prototyped as <code>f (…)</code> + a function </li> - <li><span class="parameter">wrapper</span> - a wrapper function, prototyped as <code>wrapper (f, …)</code> + <li><span class="parameter">n</span> + a number. Defaults to 1. + (<em>optional</em>) </li> </ul> <h3>Returns:</h3> <ol> - the results + a function </ol> + <h3>See also:</h3> + <ul> + <a href="index.html#unary">unary</a> + </ul> </dd> <dt> - <a name = "times"></a> - <strong>times (n, iter, ...)</strong> + <a name = "before"></a> + <strong>before (f, count)</strong> </dt> <dd> - Runs <code>iter</code> function <code>n</code> times. Collects the results of each run and returns them in an array. + Returns a version of <code>f</code> that will run no more than <em>count</em> times. Next calls will + keep yielding the results of the count-th call. <h3>Parameters:</h3> <ul> - <li><span class="parameter">n</span> - the number of times <code>iter</code> should be called - </li> - <li><span class="parameter">iter</span> - an iterator function, prototyped as <code>iter (i, …)</code> + <li><span class="parameter">f</span> + a function </li> - <li><span class="parameter">...</span> - args to be passed to <code>iter</code> function + <li><span class="parameter">count</span> + a count </li> </ul> <h3>Returns:</h3> <ol> - table an array of results + a new function </ol> + <h3>See also:</h3> + <ul> + <li><a href="index.html#once">once</a></li> + <li><a href="index.html#after">after</a></li> + </ul> </dd> @@ -3642,7 +4608,7 @@ <strong>bind (f, v)</strong> </dt> <dd> - Binds <code>v</code> to be the first argument to <code>f</code>. Calling <code>f (…)</code> will result to <code>f (v, …)</code>. + Binds <code>v</code> to be the first argument to <code>f</code>. Calling <code>f (...)</code> will result to <code>f (v, ...)</code>. <h3>Parameters:</h3> @@ -3666,7 +4632,7 @@ <ul> <li><a href="index.html#bind2">bind2</a></li> <li><a href="index.html#bindn">bindn</a></li> - <li><a href="index.html#bindAll">bindAll</a></li> + <li><a href="index.html#bindall">bindall</a></li> </ul> @@ -3676,7 +4642,7 @@ <strong>bind2 (f, v)</strong> </dt> <dd> - Binds <code>v</code> to be the second argument to <code>f</code>. Calling <code>f (a, …)</code> will result to <code>f (a, v, …)</code>. + Binds <code>v</code> to be the second argument to <code>f</code>. Calling <code>f (a, ...)</code> will result to <code>f (a, v, ...)</code>. <h3>Parameters:</h3> @@ -3700,7 +4666,42 @@ <ul> <li><a href="index.html#bind">bind</a></li> <li><a href="index.html#bindn">bindn</a></li> - <li><a href="index.html#bindAll">bindAll</a></li> + <li><a href="index.html#bindall">bindall</a></li> + </ul> + + +</dd> + <dt> + <a name = "bindall"></a> + <strong>bindall (obj, ...)</strong> + </dt> + <dd> + Binds methods to object. As such, whenever any of these methods is invoked, it + always receives the object as its first argument. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">obj</span> + an abject + </li> + <li><span class="parameter">...</span> + a variable number of method names + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + the passed-in object with all methods bound to the object itself. + </ol> + + + <h3>See also:</h3> + <ul> + <li><a href="index.html#bind">bind</a></li> + <li><a href="index.html#bind2">bind2</a></li> + <li><a href="index.html#bindn">bindn</a></li> </ul> @@ -3710,8 +4711,8 @@ <strong>bindn (f, ...)</strong> </dt> <dd> - Binds <code>…</code> to be the N-first arguments to function <code>f</code>.<br/> - Calling <code>f (a1, a2, …, aN)</code> will result to <code>f (…, a1, a2, …,aN)</code>. + Binds <code>...</code> to be the N-first arguments to function <code>f</code>. <br/> + Calling <code>f (a1, a2, ..., aN)</code> will result to <code>f (..., a1, a2, ...,aN)</code>. <h3>Parameters:</h3> @@ -3735,65 +4736,194 @@ <ul> <li><a href="index.html#bind">bind</a></li> <li><a href="index.html#bind2">bind2</a></li> - <li><a href="index.html#bindAll">bindAll</a></li> + <li><a href="index.html#bindall">bindall</a></li> </ul> </dd> <dt> - <a name = "bindAll"></a> - <strong>bindAll (obj, ...)</strong> + <a name = "castArray"></a> + <strong>castArray (value)</strong> </dt> <dd> - Binds methods to object. As such, whenever any of these methods is invoked, it - always receives the object as its first argument. + Casts vaue as an array if it is not one. <h3>Parameters:</h3> <ul> - <li><span class="parameter">obj</span> - an abject + <li><span class="parameter">value</span> + a value </li> + </ul> + + <h3>Returns:</h3> + <ol> + + an array containing the given value + </ol> + + + + +</dd> + <dt> + <a name = "complement"></a> + <strong>complement (f)</strong> + </dt> + <dd> + Returns the logical complement of a given function. For a given input, the returned + function will output <code>false</code> if the original function would have returned <code>true</code>, + and vice-versa. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">f</span> + a function + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + the logical complement of the given function <code>f</code>. + </ol> + + + + +</dd> + <dt> + <a name = "compose"></a> + <strong>compose (...)</strong> + </dt> + <dd> + Composes functions. Each passed-in function consumes the return value of the function that follows. + In math terms, composing the functions <code>f</code>, <code>g</code>, and <code>h</code> produces the function <code>f(g(h(...)))</code>. + + + <h3>Parameters:</h3> + <ul> <li><span class="parameter">...</span> - a variable number of method names + a variable number of functions </li> </ul> <h3>Returns:</h3> <ol> - the passed-in object with all methods bound to the object itself. + a new function </ol> <h3>See also:</h3> <ul> - <li><a href="index.html#bind">bind</a></li> - <li><a href="index.html#bind2">bind2</a></li> - <li><a href="index.html#bindn">bindn</a></li> + <a href="index.html#pipe">pipe</a> </ul> </dd> <dt> - <a name = "uniqueId"></a> - <strong>uniqueId ([template[, ...]])</strong> + <a name = "cond"></a> + <strong>cond (conds)</strong> </dt> <dd> - Generates an unique ID for the current session. If given a string <a href="index.html#template">template</a>, it - will use this template for output formatting. Otherwise, if <a href="index.html#template">template</a> is a function, it - will evaluate <code>template (id, …)</code>. - <br/><em>Aliased as <code>uid</code></em>. + Returns a function which iterate over a set of conditions. It invokes each predicate, + passing it given values. It returns the value of the corresponding function of the first + predicate to return a non-nil value. <h3>Parameters:</h3> <ul> - <li><span class="parameter">template</span> - either a string or a function template to format the ID - (<em>optional</em>) + <li><span class="parameter">conds</span> + an array list of predicate-function pairs </li> - <li><span class="parameter">...</span> - a variable number of arguments to be passed to <a href="index.html#template">template</a>, in case it is a function. + </ul> + + <h3>Returns:</h3> + <ol> + + the result of invoking <code>f(...)</code> of the first predicate to return a non-nil value + </ol> + + + + +</dd> + <dt> + <a name = "constant"></a> + <strong>constant (value)</strong> + </dt> + <dd> + Creates a constant function which returns the same output on every call. + <br/><em>Aliased as <code>always</code></em> + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">value</span> + a constant value + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + a constant function + </ol> + + + + +</dd> + <dt> + <a name = "converge"></a> + <strong>converge (f, g, h)</strong> + </dt> + <dd> + Converges two functions into one. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">f</span> + a function + </li> + <li><span class="parameter">g</span> + a function + </li> + <li><span class="parameter">h</span> + a function + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + a new version of function f + </ol> + + + + +</dd> + <dt> + <a name = "curry"></a> + <strong>curry (f[, n_args])</strong> + </dt> + <dd> + Curries a function. If the given function <code>f</code> takes multiple arguments, it returns another version of + <code>f</code> that takes a single argument (the first of the arguments to the original function) and returns a new + function that takes the remainder of the arguments and returns the result. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">f</span> + a function + </li> + <li><span class="parameter">n_args</span> + the number of arguments expected for <code>f</code>. Defaults to 2. (<em>optional</em>) </li> </ul> @@ -3801,7 +4931,63 @@ <h3>Returns:</h3> <ol> - value an ID + a curried version of <code>f</code> + </ol> + + + <h3>See also:</h3> + <ul> + <li><a href="index.html#partial">partial</a></li> + <li><a href="index.html#partialRight">partialRight</a></li> + </ul> + + +</dd> + <dt> + <a name = "flip"></a> + <strong>flip (f)</strong> + </dt> + <dd> + Creates a function of <code>f</code> with arguments flipped in reverse order. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">f</span> + a function + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + a function + </ol> + + + + +</dd> + <dt> + <a name = "identity"></a> + <strong>identity (value)</strong> + </dt> + <dd> + Returns the passed-in value. This function is used internally + as a default iterator. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">value</span> + a value + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + the passed-in value </ol> @@ -3810,11 +4996,12 @@ </dd> <dt> <a name = "iterator"></a> - <strong>iterator (f, x)</strong> + <strong>iterator (f, value[, n])</strong> </dt> <dd> - Produces an iterator which repeatedly apply a function <code>f</code> onto an input.<br/> - Yields x, then f(x), then f(f(x)), continuously. + Produces an iterator which repeatedly apply a function <code>f</code> onto an input. <br/> + Yields <a href="index.html#obj:value">value</a>, then <code>f(value)</code>, then <code>f(f(value))</code>, continuously. + <br/><em>Aliased as <code>iter</code></em>. <h3>Parameters:</h3> @@ -3822,16 +5009,19 @@ <li><span class="parameter">f</span> a function </li> - <li><span class="parameter">x</span> + <li><span class="parameter">value</span> an initial input to <code>f</code> </li> + <li><span class="parameter">n</span> + the number of times the iterator should run + (<em>optional</em>) + </li> </ul> <h3>Returns:</h3> <ol> - an iterator fnction - <br/><em>Aliased as <code>iter</code></em>. + an iterator function </ol> @@ -3839,24 +5029,29 @@ </dd> <dt> - <a name = "array"></a> - <strong>array (...)</strong> + <a name = "juxtapose"></a> + <strong>juxtapose (value, ...)</strong> </dt> <dd> - Iterates an iterator and returns its values in an array. + Calls a sequence of passed-in functions with the same argument. + Returns a sequence of results. + <br/><em>Aliased as <code>juxt</code></em> <h3>Parameters:</h3> <ul> + <li><span class="parameter">value</span> + a value + </li> <li><span class="parameter">...</span> - an iterator (a function, a table and a value) + a variable number of functions </li> </ul> <h3>Returns:</h3> <ol> - an array of results + a list of results </ol> @@ -3864,11 +5059,14 @@ </dd> <dt> - <a name = "flip"></a> - <strong>flip (f)</strong> + <a name = "memoize"></a> + <strong>memoize (f[, hash])</strong> </dt> <dd> - Creates a function of <code>f</code> with arguments flipped in reverse order. + Memoizes a given function by caching the computed result. + Useful for speeding-up slow-running functions. If a <code>hash</code> function is passed, + it will be used to compute hash keys for a set of input values for caching. + <br/><em>Aliased as <code>cache</code></em> <h3>Parameters:</h3> @@ -3876,6 +5074,55 @@ <li><span class="parameter">f</span> a function </li> + <li><span class="parameter">hash</span> + a hash function, defaults to <a href="index.html#identity">identity</a> + (<em>optional</em>) + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + a new function + </ol> + + + + +</dd> + <dt> + <a name = "noop"></a> + <strong>noop ()</strong> + </dt> + <dd> + The no operation function. + + + + <h3>Returns:</h3> + <ol> + + nothing + </ol> + + + + +</dd> + <dt> + <a name = "nthArg"></a> + <strong>nthArg (n)</strong> + </dt> + <dd> + Returns a function that gets the nth argument. <br/> + If n is negative, the nth argument from the end is returned. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">n</span> + a number + </li> </ul> <h3>Returns:</h3> @@ -3889,6 +5136,38 @@ </dd> <dt> + <a name = "once"></a> + <strong>once (f)</strong> + </dt> + <dd> + Returns a version of <code>f</code> that runs only once. Successive calls to <code>f</code> + will keep yielding the same output, no matter what the passed-in arguments are. + It can be used to initialize variables. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">f</span> + a function + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + a new function + </ol> + + + <h3>See also:</h3> + <ul> + <li><a href="index.html#before">before</a></li> + <li><a href="index.html#after">after</a></li> + </ul> + + +</dd> + <dt> <a name = "over"></a> <strong>over (...)</strong> </dt> @@ -3920,43 +5199,46 @@ </dd> <dt> - <a name = "overEvery"></a> - <strong>overEvery (...)</strong> + <a name = "overArgs"></a> + <strong>overArgs (f, ...)</strong> </dt> <dd> - Creates a validation function. The returned function checks if <em>all</em> of the given predicates return - truthy when invoked with the arguments it receives. + Creates a function that invokes <code>f</code> with its arguments transformed. 1rst arguments will be passed to + the 1rst transform, 2nd arg to the 2nd transform, etc. Remaining arguments will not be transformed. <h3>Parameters:</h3> <ul> + <li><span class="parameter">f</span> + a function + </li> <li><span class="parameter">...</span> - a list of predicate functions + a list of transforms funcs prototyped as <code>f (v)</code> </li> </ul> <h3>Returns:</h3> <ol> - a new function + the result of running <code>f</code> with its transformed arguments </ol> <h3>See also:</h3> <ul> <li><a href="index.html#over">over</a></li> + <li><a href="index.html#overEvery">overEvery</a></li> <li><a href="index.html#overSome">overSome</a></li> - <li><a href="index.html#overArgs">overArgs</a></li> </ul> </dd> <dt> - <a name = "overSome"></a> - <strong>overSome (...)</strong> + <a name = "overEvery"></a> + <strong>overEvery (...)</strong> </dt> <dd> - Creates a validation function. The return function checks if <em>any</em> of a given predicates return + Creates a validation function. The returned function checks if <em>all</em> of the given predicates return truthy when invoked with the arguments it receives. @@ -3977,35 +5259,32 @@ <h3>See also:</h3> <ul> <li><a href="index.html#over">over</a></li> - <li><a href="index.html#overEvery">overEvery</a></li> + <li><a href="index.html#overSome">overSome</a></li> <li><a href="index.html#overArgs">overArgs</a></li> </ul> </dd> <dt> - <a name = "overArgs"></a> - <strong>overArgs (f, ...)</strong> + <a name = "overSome"></a> + <strong>overSome (...)</strong> </dt> <dd> - Creates a function that invokes <code>f</code> with its arguments transformed. 1rst arguments will be passed to - the 1rst transform, 2nd arg to the 2nd transform, etc. Remaining arguments will not be transformed. + Creates a validation function. The return function checks if <em>any</em> of a given predicates return + truthy when invoked with the arguments it receives. <h3>Parameters:</h3> <ul> - <li><span class="parameter">f</span> - a function - </li> <li><span class="parameter">...</span> - a list of transforms funcs prototyped as <code>f (v)</code> + a list of predicate functions </li> </ul> <h3>Returns:</h3> <ol> - the result of running <code>f</code> with its transformed arguments + a new function </ol> @@ -4013,7 +5292,7 @@ <ul> <li><a href="index.html#over">over</a></li> <li><a href="index.html#overEvery">overEvery</a></li> - <li><a href="index.html#overSome">overSome</a></li> + <li><a href="index.html#overArgs">overArgs</a></li> </ul> @@ -4023,8 +5302,8 @@ <strong>partial (f, ...)</strong> </dt> <dd> - Partially apply a function by filling in any number of its arguments.<br/> - One may pass a string <code>'_'</code> as a placeholder in the list of arguments to specify an argument + Partially apply a function by filling in any number of its arguments. <br/> + One may pass a string <code>'M'</code> as a placeholder in the list of arguments to specify an argument that should not be pre-filled, but left open to be supplied at call-time. @@ -4087,47 +5366,45 @@ </dd> <dt> - <a name = "curry"></a> - <strong>curry (f[, n_args])</strong> + <a name = "pipe"></a> + <strong>pipe (value, ...)</strong> </dt> <dd> - Curries a function. If the given function <code>f</code> takes multiple arguments, it returns another version of - <code>f</code> that takes a single argument (the first of the arguments to the original function) and returns a new - function that takes the remainder of the arguments and returns the result. + Pipes a value through a series of functions. In math terms, + given some functions <code>f</code>, <code>g</code>, and <code>h</code> in that order, it returns <code>f(g(h(value)))</code>. <h3>Parameters:</h3> <ul> - <li><span class="parameter">f</span> - a function + <li><span class="parameter">value</span> + a value </li> - <li><span class="parameter">n_args</span> - the number of arguments expected for <code>f</code>. Defaults to 2. - (<em>optional</em>) + <li><span class="parameter">...</span> + a variable number of functions </li> </ul> <h3>Returns:</h3> <ol> - a curried version of <code>f</code> + the result of the composition of function calls. </ol> <h3>See also:</h3> <ul> - <li><a href="index.html#partial">partial</a></li> - <li><a href="index.html#partialRight">partialRight</a></li> + <a href="index.html#compose">compose</a> </ul> </dd> <dt> - <a name = "time"></a> - <strong>time (f[, ...])</strong> + <a name = "rearg"></a> + <strong>rearg (f, indexes)</strong> </dt> <dd> - Returns the execution time of <code>f (…)</code> and its returned values. + Returns a function which runs with arguments rearranged. Arguments are passed to the + returned function in the order of supplied <code>indexes</code> at call-time. <h3>Parameters:</h3> @@ -4135,45 +5412,44 @@ <li><span class="parameter">f</span> a function </li> - <li><span class="parameter">...</span> - optional args to <code>f</code> - (<em>optional</em>) + <li><span class="parameter">indexes</span> + an array list of indexes </li> </ul> <h3>Returns:</h3> <ol> - the execution time and the results of <code>f (…)</code> + a function </ol> </dd> -</dl> - <h2 class="section-header "><a name="Object_functions"></a>Object functions </h2> - - <dl class="function"> <dt> - <a name = "keys"></a> - <strong>keys (obj)</strong> + <a name = "time"></a> + <strong>time (f[, ...])</strong> </dt> <dd> - Returns the keys of the object properties. + Returns the execution time of <code>f (...)</code> and its returned values. <h3>Parameters:</h3> <ul> - <li><span class="parameter">obj</span> - an object + <li><span class="parameter">f</span> + a function + </li> + <li><span class="parameter">...</span> + optional args to <code>f</code> + (<em>optional</em>) </li> </ul> <h3>Returns:</h3> <ol> - an array + the execution time and the results of <code>f (...)</code> </ol> @@ -4181,24 +5457,32 @@ </dd> <dt> - <a name = "values"></a> - <strong>values (obj)</strong> + <a name = "times"></a> + <strong>times (iter[, n[, ...]])</strong> </dt> <dd> - Returns the values of the object properties. + Runs <code>iter</code> function <code>n</code> times. Collects the results of each run and returns them in an array. <h3>Parameters:</h3> <ul> - <li><span class="parameter">obj</span> - an object + <li><span class="parameter">iter</span> + an iterator function, prototyped as <code>iter (i, ...)</code> + </li> + <li><span class="parameter">n</span> + the number of times <code>iter</code> should be called. Defaults to 1. + (<em>optional</em>) + </li> + <li><span class="parameter">...</span> + args to be passed to <code>iter</code> function + (<em>optional</em>) </li> </ul> <h3>Returns:</h3> <ol> - an array + table an array of results </ol> @@ -4206,142 +5490,180 @@ </dd> <dt> - <a name = "kvpairs"></a> - <strong>kvpairs (obj)</strong> + <a name = "unary"></a> + <strong>unary (f)</strong> </dt> <dd> - Converts keys and values a an array-list of [k, v]. + Returns a function which accepts up to one arg. It ignores any additional arguments. <h3>Parameters:</h3> <ul> - <li><span class="parameter">obj</span> - an object + <li><span class="parameter">f</span> + a function </li> </ul> <h3>Returns:</h3> <ol> - an array list of key-values pairs + a function </ol> <h3>See also:</h3> <ul> - <a href="index.html#toObj">toObj</a> + <a href="index.html#ary">ary</a> </ul> </dd> <dt> - <a name = "toObj"></a> - <strong>toObj (kvpairs)</strong> + <a name = "unfold"></a> + <strong>unfold (f, seed)</strong> </dt> <dd> - Converts an array list of <a href="index.html#kvpairs">kvpairs</a> to an object. Keys are taken - from the 1rst column in the <a href="index.html#kvpairs">kvpairs</a> sequence, associated with values in the 2nd - column + Builds a list from a seed value. Accepts an iterator function, which + returns either nil to stop iteration or two values : the value to add to the list + of results and the seed to be used in the next call to the iterator function. <h3>Parameters:</h3> <ul> - <li><span class="parameter">kvpairs</span> - an array-list of <a href="index.html#kvpairs">kvpairs</a> + <li><span class="parameter">f</span> + an iterator function + </li> + <li><span class="parameter">seed</span> + a seed value </li> </ul> <h3>Returns:</h3> <ol> - an object + an array of values </ol> - <h3>See also:</h3> - <ul> - <a href="index.html#kvpairs">kvpairs</a> - </ul> </dd> <dt> - <a name = "property"></a> - <strong>property (key)</strong> + <a name = "uniqueId"></a> + <strong>uniqueId ([template[, ...]])</strong> </dt> <dd> - Returns a function that will return the key property of any passed-in object. + Generates an unique ID for the current session. If given a string <a href="index.html#template">template</a>, it + will use this template for output formatting. Otherwise, if <a href="index.html#template">template</a> is a function, it + will evaluate <code>template (id, ...)</code>. + <br/><em>Aliased as <code>uid</code></em>. <h3>Parameters:</h3> <ul> - <li><span class="parameter">key</span> - a key property name + <li><span class="parameter">template</span> + either a string or a function template to format the ID + (<em>optional</em>) + </li> + <li><span class="parameter">...</span> + a variable number of arguments to be passed to <a href="index.html#template">template</a>, in case it is a function. + (<em>optional</em>) </li> </ul> <h3>Returns:</h3> <ol> - a function which should accept an object as argument + value an ID </ol> - <h3>See also:</h3> - <ul> - <a href="index.html#propertyOf">propertyOf</a> - </ul> </dd> <dt> - <a name = "propertyOf"></a> - <strong>propertyOf (obj)</strong> + <a name = "wrap"></a> + <strong>wrap (f, wrapper)</strong> </dt> <dd> - Returns a function which will return the value of an object property. + Wraps <code>f</code> inside of the <code>wrapper</code> function. It passes <code>f</code> as the first argument to <code>wrapper</code>. + This allows the wrapper to execute code before and after <code>f</code> runs, + adjust the arguments, and execute it conditionally. <h3>Parameters:</h3> <ul> - <li><span class="parameter">obj</span> - an object + <li><span class="parameter">f</span> + a function to be wrapped, prototyped as <code>f (...)</code> + </li> + <li><span class="parameter">wrapper</span> + a wrapper function, prototyped as <code>wrapper (f, ...)</code> </li> </ul> <h3>Returns:</h3> <ol> - a function which should accept a key property argument + the results </ol> - <h3>See also:</h3> + + +</dd> +</dl> + <h2 class="section-header "><a name="Object_functions"></a>Object functions </h2> + + <dl class="function"> + <dt> + <a name = "chain"></a> + <strong>chain (value)</strong> + </dt> + <dd> + Returns a wrapped object. Calling library functions as methods on this object + will continue to return wrapped objects until <a href="index.html#obj:value">obj:value</a> is used. Can be aliased as <code>M(value)</code>. + + + <h3>Parameters:</h3> <ul> - <a href="index.html#property">property</a> + <li><span class="parameter">value</span> + a value to be wrapped + </li> </ul> + <h3>Returns:</h3> + <ol> + + a wrapped object + </ol> + + + </dd> <dt> - <a name = "toBoolean"></a> - <strong>toBoolean (value)</strong> + <a name = "clone"></a> + <strong>clone (obj[, shallow])</strong> </dt> <dd> - Converts any given value to a boolean + Clones a given object properties. If <code>shallow</code> is passed will also clone nested array properties. <h3>Parameters:</h3> <ul> - <li><span class="parameter">value</span> - a value. Can be of any type + <li><span class="parameter">obj</span> + an object + </li> + <li><span class="parameter">shallow</span> + whether or not nested array-properties should be cloned, defaults to false. + (<em>optional</em>) </li> </ul> <h3>Returns:</h3> <ol> - <code>true</code> if value is true, <code>false</code> otherwise (false or nil). + a copy of the passed-in object </ol> @@ -4408,11 +5730,11 @@ </dd> <dt> - <a name = "clone"></a> - <strong>clone (obj[, shallow])</strong> + <a name = "has"></a> + <strong>has (obj, key)</strong> </dt> <dd> - Clones a given object properties. If <code>shallow</code> is passed will also clone nested array properties. + Checks if a given object implements a property. <h3>Parameters:</h3> @@ -4420,16 +5742,15 @@ <li><span class="parameter">obj</span> an object </li> - <li><span class="parameter">shallow</span> - whether or not nested array-properties should be cloned, defaults to false. - (<em>optional</em>) + <li><span class="parameter">key</span> + a key property to be checked </li> </ul> <h3>Returns:</h3> <ol> - a copy of the passed-in object + <code>true</code> or <code>false</code> </ol> @@ -4437,25 +5758,21 @@ </dd> <dt> - <a name = "tap"></a> - <strong>tap (obj, f[, ...])</strong> + <a name = "import"></a> + <strong>import ([context[, noConflict]])</strong> </dt> <dd> - Invokes interceptor with the object, and then returns object. - The primary purpose of this method is to “tap into” a method chain, in order to perform operations - on intermediate results within the chain. + Imports all library functions into a context. <h3>Parameters:</h3> <ul> - <li><span class="parameter">obj</span> - an object - </li> - <li><span class="parameter">f</span> - an interceptor function, should be prototyped as <code>f (obj, …)</code> + <li><span class="parameter">context</span> + a context. Defaults to <code>_ENV or </code>_G`` (current environment). + (<em>optional</em>) </li> - <li><span class="parameter">...</span> - args to be passed to <code>f</code> + <li><span class="parameter">noConflict</span> + if supplied, will not import conflicting functions in the destination context. (<em>optional</em>) </li> </ul> @@ -4463,7 +5780,7 @@ <h3>Returns:</h3> <ol> - the passed-in object + the passed-in context </ol> @@ -4471,11 +5788,12 @@ </dd> <dt> - <a name = "has"></a> - <strong>has (obj, key)</strong> + <a name = "isArray"></a> + <strong>isArray (obj)</strong> </dt> <dd> - Checks if a given object implements a property. + Checks if the given argument is an array. Assumes <code>obj</code> is an array + if is a table with consecutive integer keys starting at 1. <h3>Parameters:</h3> @@ -4483,9 +5801,6 @@ <li><span class="parameter">obj</span> an object </li> - <li><span class="parameter">key</span> - a key property to be checked - </li> </ul> <h3>Returns:</h3> @@ -4499,12 +5814,11 @@ </dd> <dt> - <a name = "pick"></a> - <strong>pick (obj, ...)</strong> + <a name = "isBoolean"></a> + <strong>isBoolean (obj)</strong> </dt> <dd> - Returns an object copy having white-listed properties. - <br/><em>Aliased as <code>choose</code></em>. + Checks if the given argument is a boolean. <h3>Parameters:</h3> @@ -4512,15 +5826,12 @@ <li><span class="parameter">obj</span> an object </li> - <li><span class="parameter">...</span> - a variable number of string keys - </li> </ul> <h3>Returns:</h3> <ol> - the filtered object + <code>true</code> or <code>false</code> </ol> @@ -4528,12 +5839,12 @@ </dd> <dt> - <a name = "omit"></a> - <strong>omit (obj, ...)</strong> + <a name = "isCallable"></a> + <strong>isCallable (obj)</strong> </dt> <dd> - Returns an object copy without black-listed properties. - <br/><em>Aliased as <code>drop</code></em>. + Checks if the given argument is callable. Assumes <code>obj</code> is callable if + it is either a function or a table having a metatable implementing <code>__call</code> metamethod. <h3>Parameters:</h3> @@ -4541,15 +5852,12 @@ <li><span class="parameter">obj</span> an object </li> - <li><span class="parameter">...</span> - a variable number of string keys - </li> </ul> <h3>Returns:</h3> <ol> - the filtered object + <code>true</code> or <code>false</code> </ol> @@ -4557,21 +5865,19 @@ </dd> <dt> - <a name = "template"></a> - <strong>template (obj[, template])</strong> + <a name = "isEmpty"></a> + <strong>isEmpty ([obj])</strong> </dt> <dd> - Applies a template to an object, preserving non-nil properties. - <br/><em>Aliased as <code>defaults</code></em>. + Checks if the given pbject is empty. If <code>obj</code> is a string, will return <code>true</code> + if <code>#obj == 0</code>. Otherwise, if <code>obj</code> is a table, will return whether or not this table + is empty. If <code>obj</code> is <code>nil</code>, it will return true. <h3>Parameters:</h3> <ul> <li><span class="parameter">obj</span> an object - </li> - <li><span class="parameter">template</span> - a template object. Defaults to an empty table <code>{}</code>. (<em>optional</em>) </li> </ul> @@ -4579,7 +5885,7 @@ <h3>Returns:</h3> <ol> - the passed-in object filled + <code>true</code> or <code>false</code> </ol> @@ -4595,7 +5901,7 @@ (by reference), nil, booleans. Compares tables by reference or by values. If <code>useMt</code> is passed, the equality operator <code>==</code> will be used if one of the given objects has a metatable implementing <code>__eq</code>. - <br/><em>Aliased as <code>_.compare</code></em> + <br/><em>Aliased as <code>M.compare</code>, <code>M.matches</code></em> <h3>Parameters:</h3> @@ -4623,12 +5929,11 @@ </dd> <dt> - <a name = "result"></a> - <strong>result (obj, method[, ...])</strong> + <a name = "isFinite"></a> + <strong>isFinite (obj)</strong> </dt> <dd> - Invokes an object method. It passes the object itself as the first argument. if <code>method</code> is not - callable, will return <code>obj[method]</code>. + Checks if the given argument is a finite number. <h3>Parameters:</h3> @@ -4636,19 +5941,12 @@ <li><span class="parameter">obj</span> an object </li> - <li><span class="parameter">method</span> - a string key to index in object <code>obj</code>. - </li> - <li><span class="parameter">...</span> - Optional args to be passed to <code>method</code> - (<em>optional</em>) - </li> </ul> <h3>Returns:</h3> <ol> - the returned value of <code>method (obj, …)</code> call + <code>true</code> or <code>false</code> </ol> @@ -4656,17 +5954,17 @@ </dd> <dt> - <a name = "isTable"></a> - <strong>isTable (t)</strong> + <a name = "isFunction"></a> + <strong>isFunction (obj)</strong> </dt> <dd> - Checks if the given arg is a table. + Checks if the given argument is a function. <h3>Parameters:</h3> <ul> - <li><span class="parameter">t</span> - a value to be tested + <li><span class="parameter">obj</span> + an object </li> </ul> @@ -4681,12 +5979,11 @@ </dd> <dt> - <a name = "isCallable"></a> - <strong>isCallable (obj)</strong> + <a name = "isInteger"></a> + <strong>isInteger (obj)</strong> </dt> <dd> - Checks if the given argument is callable. Assumes <code>obj</code> is callable if - it is either a function or a table having a metatable implementing <code>__call</code> metamethod. + Checks if the given argument is an integer. <h3>Parameters:</h3> @@ -4707,12 +6004,36 @@ </dd> <dt> - <a name = "isArray"></a> - <strong>isArray (obj)</strong> + <a name = "isIterable"></a> + <strong>isIterable (obj)</strong> </dt> <dd> - Checks if the given argument is an array. Assumes <code>obj</code> is an array - if is a table with consecutive integer keys starting at 1. + Checks if the given object is iterable with <a href="https://www.lua.org/manual/5.1/manual.html#pdf-pairs">pairs</a> (or <a href="https://www.lua.org/manual/5.1/manual.html#pdf-ipairs">ipairs</a>). + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">obj</span> + an object + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + <code>true</code> if the object can be iterated with <a href="https://www.lua.org/manual/5.1/manual.html#pdf-pairs">pairs</a> (or <a href="https://www.lua.org/manual/5.1/manual.html#pdf-ipairs">ipairs</a>), <code>false</code> otherwise + </ol> + + + + +</dd> + <dt> + <a name = "isNaN"></a> + <strong>isNaN (obj)</strong> + </dt> + <dd> + Checks if the given argument is NaN (see <a href="http://en.wikipedia.org/wiki/NaN">Not-A-Number</a>). <h3>Parameters:</h3> @@ -4729,15 +6050,19 @@ </ol> + <h3>See also:</h3> + <ul> + <a href="index.html#isNumber">isNumber</a> + </ul> </dd> <dt> - <a name = "isIterable"></a> - <strong>isIterable (obj)</strong> + <a name = "isNil"></a> + <strong>isNil (obj)</strong> </dt> <dd> - Checks if the given object is iterable with <a href="https://www.lua.org/manual/5.1/manual.html#pdf-pairs">pairs</a> (or <a href="https://www.lua.org/manual/5.1/manual.html#pdf-ipairs">ipairs</a>). + Checks if the given argument is nil. <h3>Parameters:</h3> @@ -4750,7 +6075,7 @@ <h3>Returns:</h3> <ol> - <code>true</code> if the object can be iterated with <a href="https://www.lua.org/manual/5.1/manual.html#pdf-pairs">pairs</a> (or <a href="https://www.lua.org/manual/5.1/manual.html#pdf-ipairs">ipairs</a>), <code>false</code> otherwise + <code>true</code> or <code>false</code> </ol> @@ -4758,20 +6083,17 @@ </dd> <dt> - <a name = "isEmpty"></a> - <strong>isEmpty ([obj])</strong> + <a name = "isNumber"></a> + <strong>isNumber (obj)</strong> </dt> <dd> - Checks if the given pbject is empty. If <code>obj</code> is a string, will return <code>true</code> - if <code>#obj == 0</code>. Otherwise, if <code>obj</code> is a table, will return whether or not this table - is empty. If <code>obj</code> is <code>nil</code>, it will return true. + Checks if the given argument is a number. <h3>Parameters:</h3> <ul> <li><span class="parameter">obj</span> an object - (<em>optional</em>) </li> </ul> @@ -4782,6 +6104,10 @@ </ol> + <h3>See also:</h3> + <ul> + <a href="index.html#isNaN">isNaN</a> + </ul> </dd> @@ -4811,11 +6137,36 @@ </dd> <dt> - <a name = "isFunction"></a> - <strong>isFunction (obj)</strong> + <a name = "isTable"></a> + <strong>isTable (t)</strong> </dt> <dd> - Checks if the given argument is a function. + Checks if the given arg is a table. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">t</span> + a value to be tested + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + <code>true</code> or <code>false</code> + </ol> + + + + +</dd> + <dt> + <a name = "keys"></a> + <strong>keys (obj)</strong> + </dt> + <dd> + Returns the keys of the object properties. <h3>Parameters:</h3> @@ -4828,7 +6179,7 @@ <h3>Returns:</h3> <ol> - <code>true</code> or <code>false</code> + an array </ol> @@ -4836,11 +6187,11 @@ </dd> <dt> - <a name = "isNil"></a> - <strong>isNil (obj)</strong> + <a name = "kvpairs"></a> + <strong>kvpairs (obj)</strong> </dt> <dd> - Checks if the given argument is nil. + Converts key-value pairs to an array-list of <code>[k, v]</code> pairs. <h3>Parameters:</h3> @@ -4853,19 +6204,43 @@ <h3>Returns:</h3> <ol> - <code>true</code> or <code>false</code> + an array list of key-value pairs </ol> + <h3>See also:</h3> + <ul> + <a href="index.html#toObj">toObj</a> + </ul> </dd> <dt> - <a name = "isNumber"></a> - <strong>isNumber (obj)</strong> + <a name = "obj:value"></a> + <strong>obj:value ()</strong> </dt> <dd> - Checks if the given argument is a number. + Extracts the value of a wrapped object. Must be called on an chained object (see <a href="index.html#chain">chain</a>). + + + + <h3>Returns:</h3> + <ol> + + the value previously wrapped + </ol> + + + + +</dd> + <dt> + <a name = "omit"></a> + <strong>omit (obj, ...)</strong> + </dt> + <dd> + Returns an object copy without black-listed properties. + <br/><em>Aliased as <code>drop</code></em>. <h3>Parameters:</h3> @@ -4873,28 +6248,114 @@ <li><span class="parameter">obj</span> an object </li> + <li><span class="parameter">...</span> + a variable number of string keys + </li> </ul> <h3>Returns:</h3> <ol> - <code>true</code> or <code>false</code> + the filtered object + </ol> + + + + +</dd> + <dt> + <a name = "path"></a> + <strong>path (obj, ...)</strong> + </dt> + <dd> + Returns the value at a given path in an object. <br/> + Path is given as a vararg list of keys. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">obj</span> + an object + </li> + <li><span class="parameter">...</span> + a vararg list of keys + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + a value or nil + </ol> + + + + +</dd> + <dt> + <a name = "pick"></a> + <strong>pick (obj, ...)</strong> + </dt> + <dd> + Returns an object copy having white-listed properties. + <br/><em>Aliased as <code>choose</code></em>. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">obj</span> + an object + </li> + <li><span class="parameter">...</span> + a variable number of string keys + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + the filtered object + </ol> + + + + +</dd> + <dt> + <a name = "property"></a> + <strong>property (key)</strong> + </dt> + <dd> + Returns a function that will return the key property of any passed-in object. + + + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">key</span> + a key property name + </li> + </ul> + + <h3>Returns:</h3> + <ol> + + a function which should accept an object as argument </ol> <h3>See also:</h3> <ul> - <a href="index.html#isNaN">isNaN</a> + <a href="index.html#propertyOf">propertyOf</a> </ul> </dd> <dt> - <a name = "isNaN"></a> - <strong>isNaN (obj)</strong> + <a name = "propertyOf"></a> + <strong>propertyOf (obj)</strong> </dt> <dd> - Checks if the given argument is NaN (see <a href="http://en.wikipedia.org/wiki/NaN">Not-A-Number</a>). + Returns a function which will return the value of an object property. <h3>Parameters:</h3> @@ -4907,23 +6368,24 @@ <h3>Returns:</h3> <ol> - <code>true</code> or <code>false</code> + a function which should accept a key property argument </ol> <h3>See also:</h3> <ul> - <a href="index.html#isNumber">isNumber</a> + <a href="index.html#property">property</a> </ul> </dd> <dt> - <a name = "isFinite"></a> - <strong>isFinite (obj)</strong> + <a name = "result"></a> + <strong>result (obj, method[, ...])</strong> </dt> <dd> - Checks if the given argument is a finite number. + Invokes an object method. It passes the object itself as the first argument. if <code>method</code> is not + callable, will return <code>obj[method]</code>. <h3>Parameters:</h3> @@ -4931,12 +6393,19 @@ <li><span class="parameter">obj</span> an object </li> + <li><span class="parameter">method</span> + a string key to index in object <code>obj</code>. + </li> + <li><span class="parameter">...</span> + Optional args to be passed to <code>method</code> + (<em>optional</em>) + </li> </ul> <h3>Returns:</h3> <ol> - <code>true</code> or <code>false</code> + the returned value of <code>method (obj, ...)</code> call </ol> @@ -4944,11 +6413,13 @@ </dd> <dt> - <a name = "isBoolean"></a> - <strong>isBoolean (obj)</strong> + <a name = "tap"></a> + <strong>tap (obj, f[, ...])</strong> </dt> <dd> - Checks if the given argument is a boolean. + Invokes interceptor with the object, and then returns object. + The primary purpose of this method is to "tap into" a method chain, in order to perform operations + on intermediate results within the chain. <h3>Parameters:</h3> @@ -4956,12 +6427,19 @@ <li><span class="parameter">obj</span> an object </li> + <li><span class="parameter">f</span> + an interceptor function, should be prototyped as <code>f (obj, ...)</code> + </li> + <li><span class="parameter">...</span> + args to be passed to <code>f</code> + (<em>optional</em>) + </li> </ul> <h3>Returns:</h3> <ol> - <code>true</code> or <code>false</code> + the passed-in object </ol> @@ -4969,11 +6447,12 @@ </dd> <dt> - <a name = "isInteger"></a> - <strong>isInteger (obj)</strong> + <a name = "template"></a> + <strong>template (obj[, template])</strong> </dt> <dd> - Checks if the given argument is an integer. + Applies a template to an object, preserving non-nil properties. + <br/><em>Aliased as <code>defaults</code></em>. <h3>Parameters:</h3> @@ -4981,12 +6460,16 @@ <li><span class="parameter">obj</span> an object </li> + <li><span class="parameter">template</span> + a template object. If <code>nil</code>, leaves <code>obj</code> untouched. + (<em>optional</em>) + </li> </ul> <h3>Returns:</h3> <ol> - <code>true</code> or <code>false</code> + the passed-in object filled </ol> @@ -4994,25 +6477,24 @@ </dd> <dt> - <a name = "chain"></a> - <strong>chain (value)</strong> + <a name = "toBoolean"></a> + <strong>toBoolean (value)</strong> </dt> <dd> - Returns a wrapped object. Calling library functions as methods on this object - will continue to return wrapped objects until <a href="index.html#obj:value">obj:value</a> is used. Can be aliased as <code>_(value)</code>. + Converts any given value to a boolean <h3>Parameters:</h3> <ul> <li><span class="parameter">value</span> - a value to be wrapped + a value. Can be of any type </li> </ul> <h3>Returns:</h3> <ol> - a wrapped object + <code>true</code> if value is true, <code>false</code> otherwise (false or nil). </ol> @@ -5020,48 +6502,55 @@ </dd> <dt> - <a name = "obj:value"></a> - <strong>obj:value ()</strong> + <a name = "toObj"></a> + <strong>toObj (kvpairs)</strong> </dt> <dd> - Extracts the value of a wrapped object. Must be called on an chained object (see <a href="index.html#chain">chain</a>). + Converts an array list of <code>[k,v]</code> pairs to an object. Keys are taken + from the 1rst column in the <code>[k,v]</code> pairs sequence, associated with values in the 2nd + column. + <h3>Parameters:</h3> + <ul> + <li><span class="parameter">kvpairs</span> + an array-list of <code>[k,v]</code> pairs + </li> + </ul> <h3>Returns:</h3> <ol> - the value previously wrapped + an object </ol> + <h3>See also:</h3> + <ul> + <a href="index.html#kvpairs">kvpairs</a> + </ul> </dd> <dt> - <a name = "import"></a> - <strong>import ([context[, noConflict]])</strong> + <a name = "values"></a> + <strong>values (obj)</strong> </dt> <dd> - Imports all library functions into a context. + Returns the values of the object properties. <h3>Parameters:</h3> <ul> - <li><span class="parameter">context</span> - a context. Defaults to <code>_G</code> (global environment) when not given. - (<em>optional</em>) - </li> - <li><span class="parameter">noConflict</span> - if supplied, will not import functions having a key existing in the destination context. - (<em>optional</em>) + <li><span class="parameter">obj</span> + an object </li> </ul> <h3>Returns:</h3> <ol> - the passed-in context + an array of values </ol> @@ -5075,7 +6564,7 @@ </div> <!-- id="main" --> <div id="about"> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> -<i style="float:right;">Last updated 2017-04-27 15:26:55 </i> +<i style="float:right;">Last updated 2018-08-22 18:44:44 </i> </div> <!-- id="about" --> </div> <!-- id="container" --> </body> |