hexrec.utils.chop#
- hexrec.utils.chop(vector, window, align_base=0)[source]#
Chops a vector.
Iterates through the vector grouping its items into windows.
- Parameters:
vector (items) – Vector to chop.
window (int) – Window length.
align_base (int) – Offset of the first window.
- Yields:
list or items – vector slices of up to window elements.
Examples
>>> list(chop(b'ABCDEFG', 2)) ['AB', 'CD', 'EF', 'G']
>>> ':'.join(chop('ABCDEFG', 2)) 'AB:CD:EF:G'
>>> list(chop('ABCDEFG', 4, 3)) ['A', 'BCDE', 'FG']