ocaml: phase 6 Printf %i/%u/%x/%X/%o + int_to_hex/octal host primitives (+5 tests, 533 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 41s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 41s
Three new host primitives in eval.sx: _int_to_hex_lower n -> string of hex digits (lowercase) _int_to_hex_upper n -> string of hex digits (uppercase) _int_to_octal n -> string of octal digits Each builds the digit string by repeated floor(n / base) + mod, prepending the digit at each step. Negative numbers prefix '-' so the output round-trips through int_of_string with a sign. Printf walker now fans out: %d, %i, %u -> _string_of_int %f -> _string_of_float %x -> _int_to_hex_lower %X -> _int_to_hex_upper %o -> _int_to_octal %s, %c, %b -> existing handling Printf.sprintf '%x' 255 = 'ff' Printf.sprintf '%X' 4096 = '1000' Printf.sprintf '%o' 8 = '10' Printf.sprintf '%x %X %o' 255 4096 8 = 'ff 1000 10'
This commit is contained in:
@@ -407,6 +407,13 @@ _Newest first._
|
||||
binary search tree (`type 'a tree = Leaf | Node of 'a * 'a tree *
|
||||
'a tree`) with insert + in-order traversal. Tests parametric ADT,
|
||||
recursive match, List.append, List.fold_left.
|
||||
- 2026-05-09 Phase 6 — Printf.sprintf adds %i, %u (aliases of %d),
|
||||
%x (lowercase hex), %X (uppercase hex), %o (octal) (+5 tests, 533
|
||||
total). New host primitives `_int_to_hex_lower`, `_int_to_hex_upper`,
|
||||
`_int_to_octal` build the digit string by repeated host
|
||||
`floor (/ n base)` + `mod`. The Printf walker fans out specs to the
|
||||
right host helper. Examples: `%x` 255 = "ff", `%X` 4096 = "1000",
|
||||
`%o` 8 = "10", multi: `%x %X %o` 255 4096 8 = "ff 1000 10".
|
||||
- 2026-05-09 Phase 6 — List.sort upgraded from O(n²) insertion sort
|
||||
to O(n log n) mergesort (+3 tests, 528 total). split + merge are
|
||||
inner functions of sort; tuple destructuring on the split result is
|
||||
|
||||
Reference in New Issue
Block a user