spec: format — CL-style string formatting (~a ~s ~d ~x ~o ~b ~f ~% ~& ~~ ~t)
28 tests, passes on both JS and OCaml. - spec/stdlib.sx: pure SX format function - spec/primitives.sx: format primitive declaration - lib/r7rs.sx: fix number->string to support optional radix arg - hosts/ocaml: add format-decimal primitive, load stdlib.sx in test runner - hosts/javascript: load stdlib.sx in test runner Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1326,3 +1326,9 @@
|
||||
:params ((lst :as list))
|
||||
:returns "bytevector"
|
||||
:doc "Build a bytevector from a list of byte integers 0-255.")
|
||||
|
||||
(define-primitive
|
||||
"format"
|
||||
:params ((template :as string) &rest args)
|
||||
:returns "string"
|
||||
:doc "CL-style format string. Directives: ~a display, ~s write, ~d decimal, ~x hex, ~o octal, ~b binary, ~f fixed-point, ~e scientific, ~% newline, ~& fresh-line, ~~ tilde, ~t tab. Optional first arg: output-port.")
|
||||
|
||||
Reference in New Issue
Block a user