Skip to content

Instantly share code, notes, and snippets.

@c0ldlimit
Created June 20, 2014 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c0ldlimit/837c9d4b547892a177e1 to your computer and use it in GitHub Desktop.
Save c0ldlimit/837c9d4b547892a177e1 to your computer and use it in GitHub Desktop.
#python #ismember
# 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