MCPcopy Create free account
hub / github.com/BitVM/BitVM / u32_copy_zip

Function u32_copy_zip

bitvm/src/u32/u32_zip.rs:28–34  ·  view source on GitHub ↗

Zips the a-th and b-th u32 elements from the top and keep the one chosen (given as the first parameter) in the stack (without preserving order) Assuming a is smaller than b and x_i denoting the i-th part of the x-th number: Input: ... (a u32 elements) a_0 a_1 a_2 a_3 ... (b - a - 1 u32 elements) b_0 b_1 b_2 b_3 Output: b_0 a_0 b_1 a_1 b_2 a_2 b_3 a_3 ... (b u32 elements including the element that

(a: u32, b: u32)

Source from the content-addressed store, hash-verified

26/// Input: ... (a u32 elements) a_0 a_1 a_2 a_3 ... (b - a - 1 u32 elements) b_0 b_1 b_2 b_3
27/// Output: b_0 a_0 b_1 a_1 b_2 a_2 b_3 a_3 ... (b u32 elements including the element that is chosen to stay and rest of the stack)
28pub fn u32_copy_zip(a: u32, b: u32) -> Script {
29 if a < b {
30 _u32_copy_zip(a, b)
31 } else {
32 _u32_zip_copy(b, a)
33 }
34}
35
36/// Helper for u32_copy_zip
37pub fn _u32_copy_zip(mut a: u32, mut b: u32) -> Script {

Callers

nothing calls this directly

Calls 2

_u32_copy_zipFunction · 0.85
_u32_zip_copyFunction · 0.85

Tested by

no test coverage detected