Comparing version 0.1.5 to 0.1.6
@@ -324,6 +324,6 @@ (function() { | ||
l.bang = function(i, xs) { | ||
return i < 0 ? "Negative Index" | ||
: l.nil(xs) ? "Index too large" | ||
return i < 0 ? -1 | ||
: l.nil(xs) ? -1 | ||
: i === 0 ? l.head(xs) | ||
: l.bang(l.tail(xs),i-1) | ||
: l.bang(i-1, l.tail(xs)) | ||
} | ||
@@ -330,0 +330,0 @@ l.elemIndex = l.indexOf = function(x, xs) { // tail recursive |
{ | ||
"name": "lists", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "A library of higher-order functions modeled after Haskell's Data.List module", | ||
@@ -5,0 +5,0 @@ "main": "lists.js", |
@@ -35,6 +35,6 @@ # [ l [ i [ s ] t ] s ] | ||
tail : arr|str -> [x] | ||
- Takes an Array of variables or String and produces an array of variables ([x]). | ||
- Takes an Array of Variables or String and produces an Array of Variables ([x]). | ||
map : [x] -> f -> [x] | ||
- Takes an Array of variables and a function and produces an array of variables. | ||
- Takes an Array of Variables and a Function and produces an Array of Variables. | ||
@@ -130,5 +130,5 @@ ----- | ||
* [`lookup`](#lookup) : num|str -> [[num|str,x]] -> boolean | ||
* find : (a -> Bool) -> [a] -> Maybe a | ||
* filter : (a -> Bool) -> [a] -> [a] | ||
* partition : (a -> Bool) -> [a] -> ([a], [a]) | ||
* [`find`](#find) : [x] -> f -> x | ||
* [`filter`](#filter) : [x] -> f -> [x] | ||
* [`partition`](#partition) : [x] -> f -> [[x],[x]] | ||
@@ -139,3 +139,3 @@ ----- | ||
* bang : [a] -> Int -> a | ||
* [`bang`](#bang) : num -> [x] -> x | ||
* elemIndex : Eq a => a -> [a] -> Maybe Int | ||
@@ -402,5 +402,5 @@ * elemIndices : Eq a => a -> [a] -> [Int] | ||
------ | ||
**Description**: Variable returned reducing left to right by applying a binary operator function (f) on a starting variable (x), known as the accumulator, and an Array of Variables or String. | ||
**Description**: Variable returned reducing left to right by applying a binary operator Function (f) on a starting Variable (x), known as the accumulator, and an Array of Variables or String. | ||
**Signature Definition**: Give arg 1 a starting Variable (usually a left identity of the binary operator). Give arg 2 an Array of Variables or a String. Give arg 3 a function (binary operator). Get a Variable. | ||
**Signature Definition**: Give arg 1 a starting Variable (usually a left identity of the binary operator). Give arg 2 an Array of Variables or a String. Give arg 3 a Function (binary operator). Get a Variable. | ||
@@ -418,5 +418,5 @@ **Example Usage**: | ||
------ | ||
**Description**: Variant of foldl without a starting variable (The accumulator begins with the 0th index of the passed Array of Variables or String). Use with non-empty Arrays or Strings. | ||
**Description**: Variant of foldl without a starting Variable (The accumulator begins with the 0th index of the passed Array of Variables or String). Use with non-empty Arrays or Strings. | ||
**Signature Definition**: Give arg 1 an Array of Variables or a String. Give arg 2 a function (binary operator). Get a Variable. | ||
**Signature Definition**: Give arg 1 an Array of Variables or a String. Give arg 2 a Function (binary operator). Get a Variable. | ||
@@ -433,3 +433,3 @@ **Example Usage**: | ||
------ | ||
**Description**: Variable returned reducing right to left by applying a binary operator function (f) on a starting Variable (x), known as the accumulator, and an Array of Variables or String. | ||
**Description**: Variable returned reducing right to left by applying a binary operator Function (f) on a starting Variable (x), known as the accumulator, and an Array of Variables or String. | ||
@@ -478,3 +478,3 @@ **Signature Definition**: Give arg 1 a starting Variable (usually a right identity of the binary operator). Give arg 2 an Array of Variables or a String. Give arg 3 a Function (binary operator). Get a Variable. | ||
------ | ||
**Description**: Array of Variables or String returned by mapping a Function over an Array of variables or String and flattening the result. | ||
**Description**: Array of Variables or String returned by mapping a Function over an Array of Variables or String and flattening the result. | ||
@@ -1025,1 +1025,61 @@ **Signature Definition**: Give arg 1 an Array of Variables or a String. Give arg 2 a Function that produces an Array of Variables or String. Get an Array of Variables or a String. | ||
------ | ||
<a name='find'/> | ||
### find : [x] -> f -> x | ||
------ | ||
**Description**: Retreive a Variable by applying a predicate Function to an Array of Variables. Returns "Nothing" if there is no match. | ||
**Signature Definition**: Give arg 1 an Array of Variables. Give arg 2 a Function. Get a Variable. | ||
**Example Usage**: | ||
```js | ||
lists.find([{a:2}], function(x) { return x.a == 2 }); /* {a:2} */ | ||
lists.find([[1,2]], function(x) { return x[0] == 1}); /* [1,2] */ | ||
lists.find([1,2,3], function(x) { return x == 0 }); /* "Nothing" */ | ||
``` | ||
------ | ||
<a name='filter'/> | ||
### filter : [x] -> f -> [x] | ||
------ | ||
**Description**: An Array of Variables returned by applying a predicate Function to an Array of Variables. | ||
**Signature Definition**: Give arg 1 an Array of Variables. Give arg 2 a Function. Get an Array of Variables. | ||
**Example Usage**: | ||
```js | ||
lists.filter([{a:1},{b:2}], function(obj) { return Object.keys(obj).length > 0 }); /* [{a:1},{b:2}] */ | ||
lists.filter("abc", function(char) { return char == "a" }); /* ["a"] */ | ||
lists.filter([[1],[1,2]], function(arr) { return arr.length > 1 }); /* [[1,2]] */ | ||
``` | ||
------ | ||
<a name='partition'/> | ||
### partition : [x] -> f -> [[x],[x]] | ||
------ | ||
**Description**: An Array of two Arrays of Variables returned by applying a predicate Function to an Array of Variables. The Array of Variables at position 0 are the Variables that satisfy the predicate Function. The Array of Variables at position 1 are the Variables that do not satisfy the predicate Function. | ||
**Signature Definition**: Give arg 1 an Array of Variables. Give arg 2 a Function. Get an Array of two Arrays of Variables. | ||
**Example Usage**: | ||
```js | ||
lists.partition("Abc", function(char) { return char.startsWith("b") }); /* [["b"],["A","c"]] */ | ||
lists.partition([1,2,3,4], function(num) { return num % 2 == 0 }); /* [[2,4],[1,3]] */ | ||
lists.partition([{a:1},{b:2,a:2}], function(obj) { return obj.a == 2 }); /* [[{b:2,a:2}],[{a:1}]] */ | ||
``` | ||
------ | ||
<a name='bang'/> | ||
### bang : num -> [x] -> x | ||
------ | ||
**Description**: Variable returned by fetching the Variable at the given index (Number). | ||
**Signature Definition**: Give arg 1 a Number. Give arg 2 an Array of Variables. Get a Variable. | ||
**Example Usage**: | ||
```js | ||
lists.bang(1,[0,{a:2},1]); /* {a:2} */ | ||
lists.bang(0,[[1,2],4]); /* [1,2] */ | ||
lists.bang(3,[1,2]) /* -1 */ | ||
``` | ||
------ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53937
1078