Skip to content

Instantly share code, notes, and snippets.

@nebelgrau77
Last active September 2, 2020 12:44
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 nebelgrau77/1825e02f177303942df27259224cf51f to your computer and use it in GitHub Desktop.
Save nebelgrau77/1825e02f177303942df27259224cf51f to your computer and use it in GitHub Desktop.
def add(*args):
    
    if len(set([tuple([len(item) for item in arg]) for arg in args])) == 1:
    
        return [[sum(b) for *b, in zip(*item,)] for item in [b for *b, in zip(*args,)]]
        
    else:
    
        raise ValueError('Matrices of different shapes.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment