Nov. 9th, 2008

juan_gandhi: (Default)
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)

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.

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

August 2025

S M T W T F S
      12
3456789
10 11 12 13141516
171819 20212223
2425 2627282930
31      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 27th, 2025 04:21 am
Powered by Dreamwidth Studios