File tree Expand file tree Collapse file tree 3 files changed +25
-18
lines changed
src5/lib/Perlito5/Javascript3 Expand file tree Collapse file tree 3 files changed +25
-18
lines changed Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -279,32 +279,19 @@ CORE.splice = function(List__, p5want) {
279
279
};
280
280
281
281
CORE.pop = function(List__) {
282
- var o = List__[0];
283
- if (o._array_.length == null) {
284
- return null;
285
- }
286
- return o._array_.pop();
282
+ return List__[0].POP();
287
283
};
288
284
289
285
CORE.shift = function(List__) {
290
- var o = List__[0];
291
- if (o._array_.length == null) {
292
- return null;
293
- }
294
- return o._array_.shift();
286
+ return List__[0].SHIFT();
295
287
};
296
288
297
289
CORE.push = function(List__) {
298
290
return List__[0].PUSH(List__[1]);
299
291
};
300
292
301
293
CORE.unshift = function(List__) {
302
- var o = List__[0];
303
- var v = List__[1];
304
- for(var i = v._array_.length-1; i >= 0; i--) {
305
- o._array_.unshift(v._array_[i]);
306
- }
307
- return o._array_.length;
294
+ return List__[0].UNSHIFT(List__[1]);
308
295
};
309
296
310
297
CORE.join = function(List__) {
Original file line number Diff line number Diff line change @@ -386,12 +386,32 @@ function p5Array(o) {
386
386
}
387
387
return this;
388
388
};
389
+
390
+ // operations that can be tie()
389
391
this.PUSH = function(v) {
390
392
for(var i = 0; i < v._array_.length; i++) {
391
393
this._array_.push(v._array_[i] instanceof p5Scalar ? v._array_[i]._v_ : v._array_[i]);
392
394
}
393
395
return this._array_.length;
394
396
};
397
+ this.UNSHIFT = function(v) {
398
+ for(var i = v._array_.length-1; i >= 0; i--) {
399
+ this._array_.unshift(v._array_[i] instanceof p5Scalar ? v._array_[i]._v_ : v._array_[i]);
400
+ }
401
+ return this._array_.length;
402
+ };
403
+ this.POP = function() {
404
+ if (this._array_.length == null) {
405
+ return null;
406
+ }
407
+ return this._array_.pop();
408
+ };
409
+ this.SHIFT = function(v) {
410
+ if (this._array_.length == null) {
411
+ return null;
412
+ }
413
+ return this._array_.shift();
414
+ };
395
415
}
396
416
397
417
function p5Hash(o) {
You can’t perform that action at this time.
0 commit comments