question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Matrix contains builtin

See original GitHub issue

I’d like a “is contiguous sublist/submatrix” builtin. Maybe Þc?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ghostcommented, Jul 18, 2022
def matrix_contains(lhs, rhs):
    for i in range(len(lhs)):
        for j in range(len(lhs[0])):
            flag = True
            try:
                for k in range(len(rhs)):
                    for l in range(len(rhs[0])):
                        flag = flag and (lhs[i+k][j+l] == rhs[k][l])
            except:
                continue
            if flag == True:
                return flag
    return False

matrix_contains([[1,2,3],[3,4,6]], [[1,2],[3,4]]) -> True

0reactions
cgccusercommented, Jul 18, 2022

@Coder-94 That matrix_contains function is a good start, we could add just that for now and work on generalizing to n dimensions later, because it’d probably be hard. Do you want to make a PR for a Matrix Contains builtin?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Symmetric Matrix Properties and Applications: A Guide - Built In
A symmetric matrix is a matrix that is equal to its transpose. They contain three properties, including: Real eigenvalues, ...
Read more >
Function for 'does matrix contain value X?' - Stack Overflow
Many ways to do this. ismember is the first that comes to mind, since it is a set membership action you wish to...
Read more >
Matrix Function in R - Master the apply() and sapply ...
A matrix is a two-dimensional rectangular data set. Thus it can be created using vector input into the matrix function. Also, a matrix...
Read more >
4. Vectors, Matrices, and Arrays - Learning R [Book] - O'Reilly
Vectors, Matrices, and Arrays In Chapters 1 and 2, we saw several types of ... R has a built-in constant, letters , that...
Read more >
Java: Check if Array Contains Value or Element - Stack Abuse
... of how to check if a Java array contains a certain element or value. ... Additionally, we can find a specific value...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found