Modifies the length of list a to match b. Returns a. 
    a can also not be a list (will convert it to one).
    a will not be modified.
338822
def equalize_list_lengths(a,b):
    
    if not _s.fun.is_iterable(a): a = [a]
    a = list(a)
    while len(a)>len(b): a.pop(-1)
    while len(a)<len(b): a.append(a[-1])
    return a
1134020
def lsummult (list1,list2):
    
    if len(list1) != len(list2):
        raise ValueError("Lists not equal length in summult.")
    s = 0
    for item1,item2 in pstat.abut(list1,list2):
        s = s + item1*item2
    return s
437741
def replace (inlst,oldval,newval):
    
    lst = inlst*1
    for i in range(len(lst)):
        if type(lst[i]) not in [ListType,TupleType]:
            if lst[i]==oldval: lst[i]=newval
        else:
            lst[i] = replace(lst[i],oldval,newval)
    return lst
1364663
def issubset(list1, list2):
    
    n = len(list1)
    for startpos in range(len(list2) - n + 1):
        if list2[startpos:startpos+n] == list1:
            return True
    return False
5148
def _trivial_mult(A, B):
    
    if len(B) == 1:
        A, B = B, A  # so that we can reuse the code below :)
    if len(A) == 1:
        a_vals = A.sign_extended(len(B))

        # keep the wirevector len consistent
        return pyrtl.concat_list([a_vals & B, pyrtl.Const(0)])
1266739
def index_lists_equal(a: List[Index], b: List[Index]) -> bool:
    
    n = len(a)
    if len(b) != n:
        return False
    for i in range(n):
        if not indexes_equal(a[i], b[i]):
            log.debug("Mismatch: {!r} != {!r}", a[i], b[i])
            return False
    return True
20179
def union(a: Iterable[Any], b: Iterable[Any]) -> List[Any]:
    
    u = []  # type: List[Any]
    for item in a:
        if item not in u:
            u.append(item)
    for item in b:
        if item not in u:
            u.append(item)
    return u
587021
def diff(a, b):
    
    a, b = list(a), list(b)
    opcodes = SM(None, a, b).get_opcodes()
    return parse_opcodes(opcodes)
435674
def _check_list_len(row, length):
        
        if len(row) != length:
            raise Exception(
                "row length does not match expected length of " +
                str(length) + "\nrow: " + str(row))
632616
def list_diff(list_a, list_b):
    
    result = []
    for item in list_b:
        if not item in list_a:
            result.append(item)
    return result
667756
def _check_split_list_validity(self):
        
        # FIXME: Currently very primitive, but needs to be fast
        if not (hasattr(self,"_splitListsSet") and (self._splitListsSet)):
            return False
        elif len(self) != self._splitListsLength:
            return False
        else:
            return True
1209877
def _lscmp(a, b):
    '''  '''
    return not sum(0 if x==y else 1 for x, y in zip(a, b)) and len(a) == len(b)
930324
def inverable_unique_two_lists(item1_list, item2_list):
    
    import utool as ut
    unique_list1, inverse1 = np.unique(item1_list, return_inverse=True)
    unique_list2, inverse2 = np.unique(item2_list, return_inverse=True)

    flat_stacked, cumsum = ut.invertible_flatten2((unique_list1, unique_list2))
    flat_unique, inverse3 = np.unique(flat_stacked, return_inverse=True)
    reconstruct_tup = (inverse3, cumsum, inverse2, inverse1)
    return flat_unique, reconstruct_tup
142118
function mergedCompilerMsgLists(list1, list2) {
  var list = [];

  list1 = list1 || [];
  list2 = list2 || [];

  function lessThan(e1, e2) {
    if (e1.lineno < e2.lineno)
      return true;
    return e1.lineno === e2.lineno && e1.charno < e2.charno;
  }

  var i1 = 0, i2 = 0;
  while (true) {
    if (i1 >= list1.length)
      return list.concat(list2.slice(i2));
    if (i2 >= list2.length)
      return list.concat(list1.slice(i1));
    if (lessThan(list1[i1], list2[i2]))
      list.push(list1[i1++]);
    else
      list.push(list2[i2++]);
  }
}
1353761
def remove_gaps(A, B):
    
    a_seq, b_seq = [], []
    for a, b in zip(list(A), list(B)):
        if a == '-' or a == '.' or b == '-' or b == '.':
            continue
        a_seq.append(a)
        b_seq.append(b)
    return ''.join(a_seq), ''.join(b_seq)
526668
def _basic_mult(A, B):
    
    if len(B) == 1:
        A, B = B, A  # so that we can reuse the code below :)
    if len(A) == 1:
        return concat_list(list(A & b for b in B) + [Const(0)])  # keep WireVector len consistent

    result_bitwidth = len(A) + len(B)
    bits = [[] for weight in range(result_bitwidth)]
    for i, a in enumerate(A):
        for j, b in enumerate(B):
            bits[i + j].append(a & b)

    while not all(len(i) <= 2 for i in bits):
        deferred = [[] for weight in range(result_bitwidth + 1)]
        for i, w_array in enumerate(bits):  # Start with low weights and start reducing
            while len(w_array) >= 3:  # build a new full adder
                a, b, cin = (w_array.pop(0) for j in range(3))
                deferred[i].append(a ^ b ^ cin)
                deferred[i + 1].append(a & b | a & cin | b & cin)
            if len(w_array) == 2:
                a, b = w_array
                deferred[i].append(a ^ b)
                deferred[i + 1].append(a & b)
            else:
                deferred[i].extend(w_array)
        bits = deferred[:result_bitwidth]

    import six
    add_wires = tuple(six.moves.zip_longest(*bits, fillvalue=Const(0)))
    adder_result = concat_list(add_wires[0]) + concat_list(add_wires[1])
    return adder_result[:result_bitwidth]
615956
function extend( a, b ) {
	for ( var p in b ) {
		a[ p ] = b[ p ];
	}

	return a;
}