2008-11-09

juan_gandhi: (Default)
2008-11-09 06:09 pm

Categories. Colimits. Just posted.

here

Comments, questions, complaints welcome.

My plans now are:
- post the last part with Java code: natural transformations. Then I'll switch to another language or two (Scala and maybe JavaScript); Java does not have type declarations, and dealing with complex structures is virtually impossible. Too ugly.
juan_gandhi: (Default)
2008-11-09 06:44 pm

more javascript


for (var idx in ['uno', 'dos', 'tres']) {
  println (typeof idx + " " + idx);
}


string 0
string 1
string 2



Explanation
JavaScript does not have arrays. Period. What it has is an imitation of arrays. Namely, objects that have keys (all keys in objects are strings) that represent numbers.

var x = ['uno', 'dos', 'tres'];
x[3.999] = 'casi cuatro';
x[-1] = 'minus uno';
println(x.length);
for (var idx in x) {
  println(idx + "->" + x[idx]);
}

(try it on testbed)

You can pass anything as an index; it is converted to a string.

So, I guess, iterables or streams or continuations should be implemented in JavaScript without using arrays.