Community Page
- osteele.com Jump to website »
-
Subscribe -
Community
-
Top Commenters
-
Popular Threads
-
Recent Comments
- NoTV service is not available in my area. Something about low demand :)
- I also read recently about Ethanol polluting more than gasoline. Not sure if its true coz I couldn’t keep up with all of the chemistry..but im very much interested with fuels becoz im a car...
- We got NOtv when we lost cross country wireless and moved to a new house. We found that DSL was a better item and we can actually limit what we see. The NOtv has been a shock to many folks who are...
- Absolutely beautiful post. Thirty minutes after reading it, my whole way of doing git business has changed.
- Wow, this is awesome! You should talk a little more about the code behind how this works, would be a great read.
Jump to original thread »
*Functional* is a JavaScript library for "functional programming":http://en.wikipedia.org/wiki/Functional_programming. It defines the standard higher-order functions (
map, reduce, filter) that you can r
... Continue reading »
1 year ago
Instead of this:
map('x*x', [1,2,3,4])
Why not this:
[1,2,3,4].map('x*x')
1 year ago
1 year ago
Regarding speed, you can improve performance by giving up your favourite idiom:
var args = [].slice.call(arguments, 0);
This is expensive because it creates a new Array object every time you slice an arguments object. Which is very often.
Mozilla provides a static slice method on the Array object. Or you can fake it yourself:
if (!Array.slice) { // Mozilla already supports this
Array.slice = function(array) {
// Slice an array-like object.
var slice = Array.prototype.slice;
return slice.apply(array, slice.call(arguments, 1));
};
}
And use it like this:
var args0 = Array.slice(arguments); // cast to Array
var args1 = Array.slice(arguments, 1); // a normal slice
I use it so often I make it global.
var slice = Array.slice;
var args = slice(arguments);
Hope that helps. Back to reading your source code for me. :)
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
JavaScript code in functional looks very elegant and readable
1 year ago
1 year ago
"map(guard('10+', not('%2')), [1,2,3,4])" in your Function-level programming section should probably produce
"-> [1,12,3,14]", or shouldn't it?!
1 year ago
I wrote the code that splices the output values into the "examples page":http://osteele.com/sources/javascript/functional exactly because I knew I wouldn't successfully keep them up to date with the expressions, but I couldn't (or didn't take the time to) do the same thing on this blog page :-(
1 year ago
1 year ago