//>>built
define("dojox/lang/functional/scan",["dojo/_base/kernel","dojo/_base/lang","./lambda"],function(k,l,h){var m={};l.mixin(h,{scanl:function(a,f,e,b){"string"==typeof a&&(a=a.split(""));b=b||k.global;f=h.lambda(f);var g,c;if(l.isArray(a)){var d=Array((g=a.length)+1);d[0]=e;for(c=0;c<g;e=f.call(b,e,a[c],c,a),d[++c]=e);}else if("function"==typeof a.hasNext&&"function"==typeof a.next)for(d=[e],c=0;a.hasNext();d.push(e=f.call(b,e,a.next(),c++,a)));else for(c in d=[e],a)c in m||d.push(e=f.call(b,e,a[c],c,
a));return d},scanl1:function(a,f,e){"string"==typeof a&&(a=a.split(""));e=e||k.global;f=h.lambda(f);var b;var g=!0;if(l.isArray(a)){var c=Array(g=a.length);c[0]=b=a[0];for(var d=1;d<g;c[d]=b=f.call(e,b,a[d],d,a),++d);}else if("function"==typeof a.hasNext&&"function"==typeof a.next){if(a.hasNext())for(c=[b=a.next()],d=1;a.hasNext();c.push(b=f.call(e,b,a.next(),d++,a)));}else for(d in a)d in m||(g?(c=[b=a[d]],g=!1):c.push(b=f.call(e,b,a[d],d,a)));return c},scanr:function(a,f,e,b){"string"==typeof a&&
(a=a.split(""));b=b||k.global;f=h.lambda(f);var g=a.length,c=Array(g+1),d=g;for(c[g]=e;0<d;--d,e=f.call(b,e,a[d],d,a),c[d]=e);return c},scanr1:function(a,f,e){"string"==typeof a&&(a=a.split(""));e=e||k.global;f=h.lambda(f);var b=a.length,g=Array(b),c=a[b-1];--b;for(g[b]=c;0<b;--b,c=f.call(e,c,a[b],b,a),g[b]=c);return g}})});