1
0
Fork 0
forked from 0x2620/oxjs

add Function.js, some updates in OxJS

This commit is contained in:
rolux 2012-01-07 12:50:02 +05:30
commit 1db649bd61
6 changed files with 123 additions and 90 deletions

View file

@ -48,6 +48,41 @@ Ox.merge = function(arr) {
return arr;
};
/*@
Ox.range <f> Python-style range
(stop) -> <[n]> range
Returns an array of integers from <code>0</code> (inclusive) to
<code>stop</code> (exclusive).
(start, stop) -> <[n]> range
Returns an array of integers from <code>start</code> (inclusive) to
<code>stop</code> (exclusive).
(start, stop, step) -> <[n]> range
Returns an array of numbers from <code>start</code> (inclusive) to
<code>stop</code> (exclusive), incrementing by <code>step</step>.
start <n> Start value
stop <n> Stop value
step <n> Step value
> Ox.range(3)
[0, 1, 2]
> Ox.range(1, 4)
[1, 2, 3]
> Ox.range(3, 0)
[3, 2, 1]
> Ox.range(1, 2, 0.5)
[1, 1.5]
> Ox.range(-1, -2, -0.5)
[-1, -1.5]
@*/
Ox.range = function() {
var args = Ox.makeArray(arguments),
arr = [];
args.push(function(i) {
arr.push(i);
});
Ox.loop.apply(null, args);
return arr;
};
/*@
Ox.sort <f> Sorts an array, handling leading digits and ignoring capitalization
arr <a> Array