I am experimenting with a more functional style in my JavaScript; therefore, I have replaced for loops with utility functions such as map and reduce.  However, I have not found a functional replacement for while loops since tail call optimization i...
Is there a javascript equivalent of Python's zip function?  That is, given multiple arrays of equal lengths create an array of pairs.  For instance, if I have three arrays that look like this:  var array1 = [1, 2, 3]; var array2 = ['a',...
How would you implement the Cartesian product of multiple arrays in JavaScript?  As an example,  cartesian([1, 2], [10, 20], [100, 200, 300])    should return  [   [1, 10, 100],   [1, 10, 200],   [1, 10, 300],   [2, 10, 100],   [2, 10, 200]   ... ]...
I need to split a JavaScript array into n sized chunks.  E.g.: Given this array  ["a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12&#...
I have looked at similar questions and answers and have not found an answer that directly addresses my question. I am struggling to understand how to use Maybe or Eitheror Monads in conjunction with piping functions. I want to pipe functions togeth...
In Javascript, how can one determine the number of formal parameters defined for a function?  Note, this is not the arguments parameter when the function is called, but the number of named arguments the function was defined with.  function zero() {...
I really like chaining Array.prototype.map,  filter and reduce to define a data transformation. Unfortunately, in a recent project that involved large log files, I could no longer get away with looping through my data multiple times...  My goal:  I w...
In short, this works:  [1, 2, 3].reduce(function (a, b) { return Math.max(a, b); }); => 3   But this doesn't:  [1, 2, 3].reduce(Math.max); => NaN   Pure puzzlement.  This is in Firefox 3.5.9, which I presume is using the mozilla standard im...
Just because functions are first class objects, there are closures, and higher order functions, does Javascript deserve to be called a Functional Programming language?  The main thing I think it lacks is Pure Functions, and it doesn't 'feel&#...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.