A function to simulate a list
557113
def simulate_list(nwords=16, nrec=10, ncats=4):
    """"""

    # load wordpool
    wp = pd.read_csv('data/cut_wordpool.csv')

    # get one list
    wp = wp[wp['GROUP']==np.random.choice(list(range(16)), 1)[0]].sample(16)

    wp['COLOR'] = [[int(np.random.rand() * 255) for i in range(3)] for i in range(16)]
173453
def mget_list(item, index):
    ''
    if isinstance(index, (int, slice)):
        return item[index]
    else:
        return map(item.__getitem__, index)
450536
def _fill_array_from_list(the_list, the_array):
        """"""
        for i, val in enumerate(the_list):
            the_array[i] = val
        return the_array
320197
def p_realnamelist(self, p):
        ''
        p[0] = p[1] + (p[3],)
        p.set_lineno(0, p.lineno(1))
614646
def slice(l,num_slices=None,slice_length=None,runts=True,random=False):
	
	if random:
		import random
		random.shuffle(l)
	if not num_slices and not slice_length: return l
	if not slice_length: slice_length=int(len(l)/num_slices)
	newlist=[l[i:i+slice_length] for i in range(0, len(l), slice_length)]
	if runts: return newlist
	return [lx for lx in newlist if len(lx)==slice_length]
990819
def apply_filter_list(func, obj):
    """"""
    if isinstance(obj, (list, tuple)):
        return [func(item) for item in obj]
    return func(obj)
516081
function map (list, fn) {
  var i
  var len = list.length
  var result = []
  var idx

  if (typeof len === 'number') {
    for (i = 0; i < len; i++) {
      result.push(fn(list[i], i))
    }
  } else {
    idx = 0
    for (i in list) {
      if (list.hasOwnProperty(i)) {
        result.push(fn(list[i], i, idx++))
      }
    }
  }

  return result
}
274865
function each(list, fn) {
  var len = list ? list.length : 0;
  var i = 0;
  for (; i < len; ++i) {
    fn(list[i], i);
  }
  return list
}
861088
def filter(self, func):
        
        return TList([v for k, v in self.items() if func(k, v)])
630689
def mset_list(item, index, value):
    ''
    if isinstance(index, (int, slice)):
        item[index] = value
    else:
        map(item.__setitem__, index, value)
150435
def map(self, func):
        
        return TList([func(k, v) for k, v in self.items()])
293290
def pack_list(fmt, data):
    '''
    '''
    func = struct.Struct(fmt).pack
    return create_string_buffer(''.join([func(x) for x in data]))
1089614
def _duplicates(list_):
    """"""
    item_indices = {}
    for i, item in enumerate(list_):
        try:
            item_indices[item].append(i)
        except KeyError:  # First time seen
            item_indices[item] = [i]
    return item_indices
588571
def p_const_list(self, p):
        ''' '''
        p[0] = ast.ConstList(list(p[2]), p.lineno(1))
574164
function iter(list, func){
    for( var i = 0; i < list.length; i++ ){
	func(list[i], i);
    }
}
1219873
def simulate(self, nsites, transition_matrix, tree, ncat=1, alpha=1):
        
        sim = SequenceSimulator(transition_matrix, tree, ncat, alpha)
        return list(sim.simulate(nsites).items())
165784
def overlap(listA, listB):
    
    if (listA is None) or (listB is None):
        return []
    else:
        return list(set(listA) & set(listB))