LANGREITER.COM plain, simple
      START     INDEX
 
flash-mx-notes-functionalVisualize Context (requires Java Plug-in)
CREATED BY chris • LAST EDITED BY chris 8003 days AGO
Functional programming experiments with ActionScript:

(chl, 2002-05-01)

Array.prototype.map = function (f) {
var n = [];
for (var i = 0; i < this.length; i++) {
n[i] = f(this[i])
}
return n
}

trace([1, 3, 7].map(Math.sin));

function isEven(x) {return 1 - (x % 2)};
function isOdd(x) {return not isEven(x)};

trace([1, 2, 3, 7, 10].map(isEven));
trace([1, 2, 3, 7, 10].map(isOdd));

Array.prototype.over = function (f) {
var r;
for (var i = 0; i < this.length; i++) {
r = f(r, this[i])
}
return r
}

trace([1, 2, 3].over(function (total, x) {return total + x}));

function sum(a, b) {return a + b};
trace([1, 2, 3].over(sum));

Array.prototype.sum = function() {return this.over(sum)}

// k: +/1 2 3
trace([1,2,3].sum());
trace(["joe", " ", "mckenzie"].sum());

Array.prototype.select = function(f) {
var n = [];
this.map(function (x) {if (f(x)) {n[n.length] = x}});
return n
}

trace([1, 2, 3, 4].select(function(x) {return x > 2}));

// >> 3, 4

Array.prototype.scan = function(f) {
var n = [];
this.map(function(x) {n[n.length] = f(n[n.length-1], x)});
return n
}

// k: +\2 4 6
trace([2,4,6].scan(sum));
// >> 2, 6, 12


  SEARCH

GET YOUR MOVE ON

  ALMOST ALL ABOUT YOU
So log in, fella — or finally get your langreiter.com account. You always wanted one.
Nearby in the temporal dimension:
Nobody.
... and 58 of the anonymous kind.
Click on Join us in the chatterbox dimension! for a moderate dose of lcom-talk. This will probably not work in Lynx and other browser exotica.


BACKLINKS
  2002-05-01-asFP

RECENT EDITS (MORE)
  films-seen
  Blood Stone
  y!kes
  wet towel
  B Studio
  Pilcrow News
  Nastassja Kinski
  2011-10-06-steve
  2011-10-06
  comment-2011-08-04-1

POWERED BY
Special Entanglement Forces provided by Vanilla

&c.
GeoURL RSS 0.92

FRIENDLY SHOPS
Uncut Games bei Gameware

OFFEN!
Offenlegung gem. §25 MedienG:
Christian Langreiter, Langkampfen
See also: Privacy policy.



 
EDIT