Native reversal and binary slicing of framed lists #
Reversal and taking or dropping a binary-counted prefix use space linear in the actual encoded list and counter. Every intermediate list is a prefix, suffix or reversal of stored input data; large binary counts never cause a list of that length to be allocated.
Main results #
Turing.MultiTapeTM.ComputableInSpace.listReverse: reverse a framed list.Turing.MultiTapeTM.ComputableInSpace.listDrop,.listTake: slice with a binary counter.Turing.MultiTapeTM.ComputableInSpace.bitsDrop,.bitsGetD,.bitsReverse: the same for a plain bit word, and reading one of its bits.Turing.MultiTapeTM.ComputableInSpace.natShiftRight: right shift by a binary offset.Turing.MultiTapeTM.ComputableInSpace.budget_natModTwoPow: keep a binary-counted number of low bits.
Reverse a framed list in native space linear in its actual encoded storage.
Drop a binary-counted prefix without allocating storage according to its numeric length.
Take a binary-counted prefix using space linear in the actual framed list and counter.
Drop a binary-counted prefix of a bit word in space linear in the word and counter.
Right shift a binary natural in space linear in the value and the binary offset. The drop count is capped at the value's bit length. The suffix is already the canonical encoding, including the empty word for zero.
Keep the low d bits of a binary natural within the budget of the two arguments.
Capping d at the actual binary length of the value bounds the temporary modulus.
Read the bit of a bit word at a binary index, or fallback beyond its end, in space linear in
the word and index.
Reverse a bit word in space linear in its length.