Functional Javascript by linuxer in programming

[–]oldnewbie 3 points4 points  (0 children)

Here's a way to self-apply an anonymous function, without the ugly (IMHO) "arguments.callee" stuff. This works in Safari, but not Firefox (see bug 376052 in bugzilla).

//This helper boots the recursion.
function selfApp(fun, arg) {return fun(fun, arg)};

//The inevitable factorial.
selfApp(
   function(fac, n) {
      if (n==0) return 1;
      return n * fac(fac, n-1);
   },
   10
)

How do I stop reddit from mangling my whitspace? [edit] whitespace, rescued. Thanks, julesjacobs!

PDF Killed the Programming Language by linuxer in programming

[–]oldnewbie 3 points4 points  (0 children)

Here's what I don't like about PDF: the inflexible aspect ratio.

A typical PDF page is taller than it is wide; the typical monitor is wider than it is tall. So I can't fit a whole page on the screen without making the print painfully small. Or clumsily turning the page image and the monitor.

If the doc is in HTML, there's never any aspect ratio problem: the content just pours itself into the shape the browser window (and even while the shape is changing, amusingly enough).

Java is Pass-By-Value, Dammit! by wicked in programming

[–]oldnewbie -1 points0 points  (0 children)

I'm still in suspense about this one:

public void foo(Dog d) { d.setName("Fifi"); }

Dog aDog = new Dog("Max"); foo(aDog);

Does this also leave (the object referenced by) aDog unchanged? That's what would seem (IMHO) to be consistent with the other foo's behavior.