4 ms·
Functional javascript in one page
- tikhonj 15y ago"In one page" is pretty meaningless if you make the page arbitrarily long :P That said, it's a nice reference for a nice library.
- Detrus 15y agoI think this is one of the inspirations for underscore.js
- meric 15y agoSeems awesome. I wonder if there is performance penalty for compiling the string partial functions though. e.g. '>2'.
- raganwald 15y agoThey 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.
- josteink 15y agoThis 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. For those curious about my take on the same problem: http://code.kjonigsen.net/js/spicejs/test.html 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.
- tincholio 15y agoI haven't tried this yet, but it would seem like a good option: http://uu-computerscience.github.com/uhc-js/ http://uu-computerscience.github.com/uhc-js/