I can't find this exact algorithm anywhere on the internet. What I'm trying to implement is the following function(adsbygoogle = window.adsbygoogle || []).push({});

in a larger program I'm writing. (I know how to do it easily if the subarrays are contiguous sequences of the original array)Code (Text):

// 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(...)

{

// ..

}

Also, if this makes things easier, in the single use case of my program the original array has unique items.

**Physics Forums - The Fusion of Science and Community**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# JavaScript Algorithm to return all subarrays of a given array

Have something to add?

Draft saved
Draft deleted

Loading...

Similar Threads - Algorithm return subarrays | Date |
---|---|

C/++/# Is there a flaw in my longest common subsequence algorithm? | Feb 24, 2018 |

C/++/# Finding duplicates algorithm | Jan 20, 2018 |

Perceptron algorithm initial vector | Dec 28, 2017 |

C/++/# What should I be most familiar w/for C++ Data Structs & Algorithms | Dec 1, 2017 |

Functions and Return statement in C | May 3, 2017 |

**Physics Forums - The Fusion of Science and Community**