[Pkg-javascript-commits] [science.js] 07/87: Add science.zeroes.
bhuvan krishna
bhuvan-guest at moszumanska.debian.org
Thu Dec 8 06:11:52 UTC 2016
This is an automated email from the git hooks/post-receive script.
bhuvan-guest pushed a commit to branch master
in repository science.js.
commit 9acaf4181938d6d1a04e71be916ada6cca6dbc04
Author: Jason Davies <jason at jasondavies.com>
Date: Sat Jul 16 12:12:19 2011 +0100
Add science.zeroes.
---
src/core/zeroes.js | 13 +++++++++++++
tests/test-zeroes.js | 10 ++++++++++
tests/test-zeroes.out | 15 +++++++++++++++
3 files changed, 38 insertions(+)
diff --git a/src/core/zeroes.js b/src/core/zeroes.js
new file mode 100644
index 0000000..806254d
--- /dev/null
+++ b/src/core/zeroes.js
@@ -0,0 +1,13 @@
+// Constructs a multi-dimensional array filled with zeroes.
+science.zeroes = function(n) {
+ var i = -1,
+ a = [];
+ if (arguments.length === 1)
+ while (++i < n)
+ a[i] = 0;
+ else
+ while (++i < n)
+ a[i] = science.zeroes.apply(
+ this, Array.prototype.slice.call(arguments, 1));
+ return a;
+};
diff --git a/tests/test-zeroes.js b/tests/test-zeroes.js
new file mode 100644
index 0000000..f9c654e
--- /dev/null
+++ b/tests/test-zeroes.js
@@ -0,0 +1,10 @@
+require("./../lib/env-js/envjs/node");
+require("./../science");
+
+console.log("zeroes 10");
+console.log(science.zeroes(10));
+console.log("");
+
+console.log("zeroes 10, 10");
+console.log(science.zeroes(10, 10));
+console.log("");
diff --git a/tests/test-zeroes.out b/tests/test-zeroes.out
new file mode 100644
index 0000000..c659e32
--- /dev/null
+++ b/tests/test-zeroes.out
@@ -0,0 +1,15 @@
+zeroes 10
+[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
+
+zeroes 10, 10
+[ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
+ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
+ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
+ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
+ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
+ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
+ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
+ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
+ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
+ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ]
+
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/science.js.git
More information about the Pkg-javascript-commits
mailing list