aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dojox/lang/functional/fold.js
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-14 15:39:19 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-14 15:39:19 +0000
commit1c5685d68f1b73270fb814fe04cbb490eb90ba5f (patch)
tree3d3ada08a934b96fc31531f1327690d7edc6f766 /includes/js/dojox/lang/functional/fold.js
parent104d59099e048688c4dbac37d72137006e396558 (diff)
downloadsemanticscuttle-1c5685d68f1b73270fb814fe04cbb490eb90ba5f.tar.gz
semanticscuttle-1c5685d68f1b73270fb814fe04cbb490eb90ba5f.tar.bz2
Minor fix: Remove DOJO library (60Mo) replaced by link to Google CDN (online DOJO library)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@159 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dojox/lang/functional/fold.js')
-rw-r--r--includes/js/dojox/lang/functional/fold.js87
1 files changed, 0 insertions, 87 deletions
diff --git a/includes/js/dojox/lang/functional/fold.js b/includes/js/dojox/lang/functional/fold.js
deleted file mode 100644
index 90a9a3d..0000000
--- a/includes/js/dojox/lang/functional/fold.js
+++ /dev/null
@@ -1,87 +0,0 @@
-if(!dojo._hasResource["dojox.lang.functional.fold"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
-dojo._hasResource["dojox.lang.functional.fold"] = true;
-dojo.provide("dojox.lang.functional.fold");
-
-dojo.require("dojox.lang.functional.lambda");
-
-// This module adds high-level functions and related constructs:
-// - "fold" family of functions
-
-// Notes:
-// - missing high-level functions are provided with the compatible API:
-// foldl, foldl1, foldr, foldr1
-// - missing JS standard functions are provided with the compatible API:
-// reduce, reduceRight
-
-// Defined methods:
-// - take any valid lambda argument as the functional argument
-// - operate on dense arrays
-// - take a string as the array argument
-// - take an iterator objects as the array argument (only foldl, foldl1, and reduce)
-
-(function(){
- var d = dojo, df = dojox.lang.functional;
-
- d.mixin(df, {
- // classic reduce-class functions
- foldl: function(/*Array|String|Object*/ a, /*Function*/ f, /*Object*/ z, /*Object?*/ o){
- // summary: repeatedly applies a binary function to an array from left
- // to right using a seed value as a starting point; returns the final
- // value.
- if(typeof a == "string"){ a = a.split(""); }
- o = o || d.global; f = df.lambda(f);
- if(d.isArray(a)){
- for(var i = 0, n = a.length; i < n; z = f.call(o, z, a[i], i, a), ++i);
- }else{
- for(var i = 0; a.hasNext(); z = f.call(o, z, a.next(), i++));
- }
- return z; // Object
- },
- foldl1: function(/*Array|String|Object*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
- // summary: repeatedly applies a binary function to an array from left
- // to right; returns the final value.
- if(typeof a == "string"){ a = a.split(""); }
- o = o || d.global; f = df.lambda(f);
- var z;
- if(d.isArray(a)){
- z = a[0];
- for(var i = 1, n = a.length; i < n; z = f.call(o, z, a[i], i, a), ++i);
- }else if(a.hasNext()){
- z = a.next();
- for(var i = 1; a.hasNext(); z = f.call(o, z, a.next(), i++));
- }
- return z; // Object
- },
- foldr: function(/*Array|String*/ a, /*Function|String|Array*/ f, /*Object*/ z, /*Object?*/ o){
- // summary: repeatedly applies a binary function to an array from right
- // to left using a seed value as a starting point; returns the final
- // value.
- if(typeof a == "string"){ a = a.split(""); }
- o = o || d.global; f = df.lambda(f);
- for(var i = a.length; i > 0; --i, z = f.call(o, z, a[i], i, a));
- return z; // Object
- },
- foldr1: function(/*Array|String*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
- // summary: repeatedly applies a binary function to an array from right
- // to left; returns the final value.
- if(typeof a == "string"){ a = a.split(""); }
- o = o || d.global; f = df.lambda(f);
- var n = a.length, z = a[n - 1];
- for(var i = n - 1; i > 0; --i, z = f.call(o, z, a[i], i, a));
- return z; // Object
- },
- // JS 1.8 standard array functions, which can take a lambda as a parameter.
- reduce: function(/*Array|String|Object*/ a, /*Function*/ f, /*Object?*/ z){
- // summary: apply a function simultaneously against two values of the array
- // (from left-to-right) as to reduce it to a single value.
- return arguments.length < 3 ? df.foldl1(a, f) : df.foldl(a, f, z); // Object
- },
- reduceRight: function(/*Array|String*/ a, /*Function*/ f, /*Object?*/ z){
- // summary: apply a function simultaneously against two values of the array
- // (from right-to-left) as to reduce it to a single value.
- return arguments.length < 3 ? df.foldr1(a, f) : df.foldr(a, f, z); // Object
- }
- });
-})();
-
-}