diff --git a/base/Bits/show_reverse.kind b/base/Bits/show_reverse.kind new file mode 100644 index 00000000..90860ba6 --- /dev/null +++ b/base/Bits/show_reverse.kind @@ -0,0 +1,2 @@ +Bits.show_reverse(bits: Bits): String + Bits.show(Bits.reverse(bits)) \ No newline at end of file diff --git a/base/Bits/to_buf_string.kind b/base/Bits/to_buf_string.kind new file mode 100644 index 00000000..a94dfdd4 --- /dev/null +++ b/base/Bits/to_buf_string.kind @@ -0,0 +1,15 @@ +// Show pairs of hex values ignoring "00" +Bits.to_buf_string(x: Bits): String + let full = Bits.to_hex_string(x) + Bits.to_buf_string.clean(String.reverse(full), "") + +Bits.to_buf_string.clean(xs: String, str: String): String + case xs { + nil : str + cons: + let {val, res} = String.take_pair(2, xs) + let new = String.concat( + if String.eql(val, "00") then "" else " " | val, + str) + Bits.to_buf_string.clean(res, new) + } \ No newline at end of file diff --git a/base/Buffer32/show.kind b/base/Buffer32/show.kind index 5b1ff0d7..3cf4421c 100644 --- a/base/Buffer32/show.kind +++ b/base/Buffer32/show.kind @@ -1,8 +1,8 @@ Buffer32.show(buf: Buffer32): String - let str = "" + str | ">" \ No newline at end of file diff --git a/base/Buffer8/show.kind b/base/Buffer8/show.kind new file mode 100644 index 00000000..06902efe --- /dev/null +++ b/base/Buffer8/show.kind @@ -0,0 +1,7 @@ +Buffer8.show(buf: Buffer8): String + let str = "" diff --git a/base/String/take_pair.kind b/base/String/take_pair.kind new file mode 100644 index 00000000..0a740eb9 --- /dev/null +++ b/base/String/take_pair.kind @@ -0,0 +1,12 @@ +String.take_pair(n: Nat, xs: String): Pair + String.take_pair.go(n, xs, "") + +String.take_pair.go(n: Nat, xs: String, take_aux: String): Pair + case xs { + nil : {take_aux, xs} + cons: case n { + zero : {take_aux, xs} + succ: + String.take_pair.go(n.pred, xs.tail, String.cons(xs.head, take_aux)) + } + } \ No newline at end of file