This works, but it still looks dirty, mostly due to javascript's lack of concise lambda-syntax.
If you want to use a functional language, it would seem more fitting to create an actual functional language with actual list comprehension, something javascript is ridiculously weak at, and so on.
Ofcourse that would then have to be compiled into something which runs in the browser. Another argument for web-bytecode I guess.
Edit: To not just throw hot air around, I tried doing something similar (with typing on top!) during a weekend long long ago. I wasn't happy about the result, but I left the code online.
They are cached, so if you use one in a recursion or iteration, you only take one hit. For maximal faux-lispiness, consider building the strings, e.g. Using CoffeeScript's string interpolation to insert literals.
If you want to use a functional language, it would seem more fitting to create an actual functional language with actual list comprehension, something javascript is ridiculously weak at, and so on.
Ofcourse that would then have to be compiled into something which runs in the browser. Another argument for web-bytecode I guess.
Edit: To not just throw hot air around, I tried doing something similar (with typing on top!) during a weekend long long ago. I wasn't happy about the result, but I left the code online.
For those curious about my take on the same problem: http://code.kjonigsen.net/js/spicejs/test.html
You'll have to view the source to see how it works, and open the web-developer console to see the output.