cl-interpret: Add format builtin

Might as well add some new features to play around with until I rip 'em all out
This commit is contained in:
John 2024-07-11 04:42:36 -05:00
parent fffc370380
commit aa7612926e

View File

@ -14,6 +14,16 @@ use std::{
builtins! { builtins! {
const MISC; const MISC;
/// Unstable variadic format function
pub fn format<_, args> () -> IResult<ConValue> {
use std::fmt::Write;
let mut out = String::new();
for arg in args {
write!(out, "{arg}").ok();
}
Ok(ConValue::String(out.into()))
}
/// Unstable variadic print function /// Unstable variadic print function
pub fn print<_, args> () -> IResult<ConValue> { pub fn print<_, args> () -> IResult<ConValue> {
let mut out = stdout().lock(); let mut out = stdout().lock();