Created
June 20, 2014 20:34
-
-
Save c0ldlimit/837c9d4b547892a177e1 to your computer and use it in GitHub Desktop.
#python #ismember
This file contains 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
# http://stackoverflow.com/questions/15864082/python-equivalent-of-matlabs-ismember-function | |
def ismember(a, b): | |
bind = {} | |
for i, elt in enumerate(b): | |
if elt not in bind: | |
bind[elt] = i | |
return [bind.get(itm, None) for itm in a] # None can be replaced by any other "not in b" value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment