@@ -111,7 +111,47 @@ Elm.Signal = function() {
111 s1.kids.push(this);
111 s1.kids.push(this);
112 s2.kids.push(this);
112 s2.kids.push(this);
115+ function delay(t) { return function(s) {
116+ var delayed = new input(s.value);
117+ function update(v) {
118+ setTimeout(function() { Dispatcher.notify(delayed.id,v); },t*1000);
120+ function first(a) { return function(b) { return a; }; }
121+ return new lift(first, [delayed, new lift(update,[s])]);
125+ var merge = function(s1,s2) {
126+ this.id = Guid.guid();
127+ this.value = s1.value;
131+ this.changed = false;
133+ this.recv = function(timestep, changed, parentID) {
136+ this.changed = true;
137+ if (parentID == s2.id && this.next === null) { this.next = s2.value; }
138+ if (parentID == s1.id) { this.next = s1.value; }
141+ if (this.count == 2) {
143+ this.value = this.next;
146+ send(this, timestep, this.changed);
147+ this.changed = false;
116 constant : function(v) { return new input(v); },
156 constant : function(v) { return new input(v); },
117 lift : function(f){return function(e){return new lift(f,[e]);};},
157 lift : function(f){return function(e){return new lift(f,[e]);};},
@@ -128,9 +168,14 @@ Elm.Signal = function() {
128 return new fold(f,b,true,e); }; }; },
168 return new fold(f,b,true,e); }; }; },
129 foldp1 : function(f) { return function(e) {
169 foldp1 : function(f) { return function(e) {
130 return new fold(f,function(x){return x;},true,e); }; },
170 return new fold(f,function(x){return x;},true,e); }; },
172+ merge : function(s1) { return function(s2) { return new merge(s1,s2)}; },
131 count : function(sig) {
173 count : function(sig) {
132 var incr = function(_){return function(c){return c+1;};};
174 var incr = function(_){return function(c){return c+1;};};
133 return new fold(incr,0,false,sig) },
175 return new fold(incr,0,false,sig) },
176+ countIf : function(pred) { return function(sig) {
177+ var incr = function(x){return function(c){return pred(x) ? c+1 : c;};};
178+ return new fold(incr,0,false,sig) }; },
134 keepIf : function(pred) { return function(base) { return function(sig) {
179 keepIf : function(pred) { return function(base) { return function(sig) {
135 return new dropIf(function(x) { return !pred(x)},base,sig); }; }; },
180 return new dropIf(function(x) { return !pred(x)},base,sig); }; }; },
136 dropIf : function(pred) { return function(base) { return function(sig) {
181 dropIf : function(pred) { return function(base) { return function(sig) {