- #1
SlurrerOfSpeech
- 141
- 11
I can't find this exact algorithm anywhere on the internet. What I'm trying to implement is the following function
in a larger program I'm writing. (I know how to do it easily if the subarrays are contiguous sequences of the original array)
Also, if this makes things easier, in the single use case of my program the original array has unique items.
Code:
// Returns all subarrays of the given array, not including the empty array
// ex. [a,b,c].subarrays() = [ [a], [b], [c], [a,b], [a,c], [b,c], [a,b,c] ]
Array.prototype.subarrays = function(...)
{
// ..
}
in a larger program I'm writing. (I know how to do it easily if the subarrays are contiguous sequences of the original array)
Also, if this makes things easier, in the single use case of my program the original array has unique items.