# Path: pykit/utils/convenience.py
# def nestedmap(f, args):
#     """
#     Map `f` over `args`, which contains elements or nested lists
#     """
#     result = []
#     for arg in args:
#         if isinstance(arg, list):
#             result.append(list(map(f, arg)))
#         else:
#             result.append(f(arg))
# 
#     return result
# 
# def listify(f):
#     """Decorator to turn generator results into lists"""
#     @functools.wraps(f)
#     def wrapper(*args, **kwargs):
#         return list(f(*args, **kwargs))
#     return wrapper


import collections
import difflib
import contextlib
from pykit.utils import nestedmap, listify
    from . import GlobalValue, Const
    return indexed

# ______________________________________________________________________

def _getops(func_or_block_or_list):
    if isinstance(func_or_block_or_list, list):
        return func_or_block_or_list
    return func_or_block_or_list.ops

def findop(container, opcode):
    """Find the first Operation with the given opcode"""
    for op in _getops(container):
        if op.opcode == opcode:
            return op

def findallops(container, opcode):
    """Find all Operations with the given opcode"""
    found = []
    for op in _getops(container):
        if op.opcode == opcode:
            found.append(op)

    return found

@listify
def opcodes(container):
    """Returns [opcode] for all operations"""
    for op in _getops(container):
        yield op.opcode


# Path: pykit/utils/convenience.py
# def nestedmap(f, args):
#     """
#     Map `f` over `args`, which contains elements or nested lists
#     """
#     result = []
#     for arg in args:
#         if isinstance(arg, list):
#             result.append(list(map(f, arg)))
#         else:
#             result.append(f(arg))
# 
#     return result
# 
# def listify(f):
#     """Decorator to turn generator results into lists"""
#     @functools.wraps(f)
#     def wrapper(*args, **kwargs):
#         return list(f(*args, **kwargs))
#     return wrapper


# Path: pykit/ir/utils.py
import collections
import difflib
import contextlib
from pykit.utils import nestedmap, listify
    from . import GlobalValue, Const

    return indexed

# ______________________________________________________________________

def _getops(func_or_block_or_list):
    if isinstance(func_or_block_or_list, list):
        return func_or_block_or_list
    return func_or_block_or_list.ops

def findop(container, opcode):
    """Find the first Operation with the given opcode"""
    for op in _getops(container):
        if op.opcode == opcode:
            return op

def findallops(container, opcode):
    """Find all Operations with the given opcode"""
    found = []
    for op in _getops(container):
        if op.opcode == opcode:
            found.append(op)

    return found

@listify
def opcodes(container):
    """Returns [opcode] for all operations"""
    for op in _getops(container):
        yield op.opcode


@listify