Returns a BinWord made from concatenating several BinWords,
        in LSB-first order.
501406
def concat(cls, *args):
        
        width = 0
        val = 0
        for arg in args:
            if not isinstance(arg, BinWord):
                raise TypeError('need BinWord in concat')
            val |= arg._val << width
            width += arg._width
        return cls(width, val)
151318
def get_index(binstr, end_index=160):
    
    res = -1
    try:
        res = binstr.index('1') + 1
    except ValueError:
        res = end_index
    return res
1310248
def _encode_binary(name, value, dummy0, dummy1):
    """"""
    subtype = value.subtype
    if subtype == 2:
        value = _PACK_INT(len(value)) + value
    return b"\x05" + name + _PACK_LENGTH_SUBTYPE(len(value), subtype) + value
731973
def BinaryOperator(self, string=None, **unused_kwargs):
    """"""
    self.stack.append(self.binary_expression_cls(string))
130020
def concatenate(*fsms):
		'''
			
		'''
		alphabet = set().union(*[fsm.alphabet for fsm in fsms])

		def connect_all(i, substate):
			'''
				Take a state in the numbered FSM and return a set containing it, plus
				(if it's final) the first state from the next FSM, plus (if that's
				final) the first state from the next but one FSM, plus...
			'''
			result = {(i, substate)}
			while i < len(fsms) - 1 and substate in fsms[i].finals:
				i += 1
				substate = fsms[i].initial
				result.add((i, substate))
			return result

		# Use a superset containing states from all FSMs at once.
		# We start at the start of the first FSM. If this state is final in the
		# first FSM, then we are also at the start of the second FSM. And so on.
		initial = set()
		if len(fsms) > 0:
			initial.update(connect_all(0, fsms[0].initial))
		initial = frozenset(initial)

		def final(state):
			'''If you're in a final state of the final FSM, it's final'''
			for (i, substate) in state:
				if i == len(fsms) - 1 and substate in fsms[i].finals:
					return True
			return False

		def follow(current, symbol):
			'''
				Follow the collection of states through all FSMs at once, jumping to the
				next FSM if we reach the end of the current one
				TODO: improve all follow() implementations to allow for dead metastates?
			'''
			next = set()
			for (i, substate) in current:
				fsm = fsms[i]
				if substate in fsm.map and symbol in fsm.map[substate]:
					next.update(connect_all(i, fsm.map[substate][symbol]))
			if len(next) == 0:
				raise OblivionError
			return frozenset(next)

		return crawl(alphabet, initial, final, follow).reduce()
84532
def lazy_binmap(f, xs):
    
    return (f(x, y) for x, y in zip(xs, xs[1:]))
738966
def invsubword(w):
    
    w = w.reshape(4, 8)
    return ISBOX[w[0]] + ISBOX[w[1]] + ISBOX[w[2]] + ISBOX[w[3]]
669042
def to_binary(decimal, length):
        
        b = bitstring.Bits(int=decimal, length=length)
        return b.bin
425920
def _get_bins(self, kind, order, reverse=False):
        

        if kind == "radius":
            start = self.max_radius * self.radius_inner
            end = self.max_radius

        elif kind == "angle":
            start = self.start_angle
            end = self.start_angle + 2 * np.pi

        bounds = np.linspace(start, end, len(order) + 1)
        bins = np.vstack([bounds[:-1], bounds[1:]]).T

        if reverse:
            bins = bins[::-1]

        return dict(zip(order, bins))
1138275
function bintohexoutput(bin){
  var len = bin.length;
  var hexoutput = String();
  for(var i=0; i<len; i+=4){
    if((i > 0) && !(i%8)){hexoutput = " " + hexoutput;}
    var value = 0;
    if(bin[len - 1 - i - 0]){value+=1;}
    if(bin[len - 1 - i - 1]){value+=2;}
    if(bin[len - 1 - i - 2]){value+=4;}
    if(bin[len - 1 - i - 3]){value+=8;}
    switch(value){
      case 0:  hexoutput = "0" + hexoutput; break;
      case 1:  hexoutput = "1" + hexoutput; break;
      case 2:  hexoutput = "2" + hexoutput; break;
      case 3:  hexoutput = "3" + hexoutput; break;
      case 4:  hexoutput = "4" + hexoutput; break;
      case 5:  hexoutput = "5" + hexoutput; break;
      case 6:  hexoutput = "6" + hexoutput; break;
      case 7:  hexoutput = "7" + hexoutput; break;
      case 8:  hexoutput = "8" + hexoutput; break;
      case 9:  hexoutput = "9" + hexoutput; break;
      case 10: hexoutput = "a" + hexoutput; break;
      case 11: hexoutput = "b" + hexoutput; break;
      case 12: hexoutput = "c" + hexoutput; break;
      case 13: hexoutput = "d" + hexoutput; break;
      case 14: hexoutput = "e" + hexoutput; break;
      case 15: hexoutput = "f" + hexoutput; break;
      default: break;
    }
  }
  // todo: make faster
  return hexoutput;
}
949238
public static BinaryString concat(Iterable<BinaryString> inputs) {
		// Compute the total length of the result.
		int totalLength = 0;
		for (BinaryString input : inputs) {
			if (input != null) {
				input.ensureMaterialized();
				totalLength += input.getSizeInBytes();
			}
		}

		// Allocate a new byte array, and copy the inputs one by one into it.
		final byte[] result = new byte[totalLength];
		int offset = 0;
		for (BinaryString input : inputs) {
			if (input != null) {
				int len = input.sizeInBytes;
				SegmentsUtil.copyToBytes(input.segments, input.offset, result, offset, len);
				offset += len;
			}
		}
		return fromBytes(result);
	}
1259986
def _bin_op(name, doc="binary operator"):
    
    def _(self, other):
        jc = other._jc if isinstance(other, Column) else other
        njc = getattr(self._jc, name)(jc)
        return Column(njc)
    _.__doc__ = doc
    return _
527085
def get_possible_splits(n):
    
    get_bin = lambda x, n: x >= 0 and str(bin(x))[2:].zfill(n) or "-" + str(bin(x))[3:].zfill(n)
    possible_splits = []
    for i in range(2**(n - 1)):
        possible_splits.append(get_bin(i, n - 1))
    return possible_splits
30656
function bintooctoutput(bin){
  var len = bin.length;
  var octoutput = String();
  for(var i=0; i<len; i+=3){
    if((i > 0) && !(i%24)){octoutput = " " + octoutput;}
    var value = 0;
    if(bin[len - 1 - i - 0]){value+=1;}
    if(bin[len - 1 - i - 1]){value+=2;}
    if(bin[len - 1 - i - 2]){value+=4;}
    switch(value){
      case 0: octoutput = "0" + octoutput; break;
      case 1: octoutput = "1" + octoutput; break;
      case 2: octoutput = "2" + octoutput; break;
      case 3: octoutput = "3" + octoutput; break;
      case 4: octoutput = "4" + octoutput; break;
      case 5: octoutput = "5" + octoutput; break;
      case 6: octoutput = "6" + octoutput; break;
      case 7: octoutput = "7" + octoutput; break;
      default: break;
    }
  }
  // todo: make faster
  return octoutput;
}
225449
def _guess_concat(data):
    
    return {
        type(u''): u''.join,
        type(b''): concat_bytes,
    }.get(type(data), list)
792683
function bininputtobin(bininput){
  var len = bininput.length;
  if(len == 0){return filledarray(false, 1);}
  var bin = new Array(len);
  var j = 0;
  for (var i = 0; i < len; i++){
    switch (bininput[i]){
    case '0': bin[j++] = false; break;
    case '1': bin[j++] = true; break;
    default: break;
    }
  }
  return removezeros(bin.slice(0, j));
}
74735
def extract(self, pos, width):
        
        pos = operator.index(pos)
        width = operator.index(width)
        if width < 0:
            raise ValueError('width must not be negative')
        if pos < 0:
            raise ValueError('extracting out of range')
        return BinWord(width, self >> pos, trunc=True)