implement builtin function is-bracketed

This commit is contained in:
ConnorSkees 2020-03-23 23:08:01 -04:00
parent d88342fd9b
commit c1ee84b6fc

View File

@ -179,4 +179,17 @@ pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
Ok(Value::List(list1, sep, brackets))
}),
);
f.insert(
"is-bracketed".to_owned(),
Box::new(|args, _| {
max_args!(args, 1);
Ok(Value::bool(match arg!(args, 0, "list") {
Value::List(.., brackets) => match brackets {
Brackets::Bracketed => true,
Brackets::None => false,
},
_ => false,
}))
}),
);
}