Last active
December 28, 2015 20:49
-
-
Save kcmckell/7559942 to your computer and use it in GitHub Desktop.
Find and remove elements that match.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function findAndRemove(superset, subset) { | |
| var ind = 0; | |
| while (superset.length > 0 & subset.length>0 $ len<subset.length) { | |
| var f = superset.indexOf(subset[ind]); | |
| if (f>=0) { | |
| superset=superset.slice(0,f).concat(superset.slice(f+1)); | |
| subset=subset.slice(0,ind).concat(subset.slice(ind+1)); | |
| } else { | |
| ind++; | |
| } | |
| } | |
| return superset; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment