Skip to content

Commit

Permalink
Minor adaptations
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Jul 1, 2024
1 parent 25184c6 commit 8abc7d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions numbat/src/ffi/lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ pub fn head(mut args: Args) -> Result<Value> {
pub fn tail(mut args: Args) -> Result<Value> {
let mut list = list_arg!(args);

if list.is_empty() {
Err(RuntimeError::EmptyList)
} else {
list.remove(0);

if list.remove(0).is_some() {
return_list!(list)
} else {
Err(RuntimeError::EmptyList)
}
}

Expand Down
4 changes: 2 additions & 2 deletions numbat/src/ffi/procedures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ pub(crate) fn procedures() -> &'static HashMap<ProcedureKind, ForeignFunction> {
})
}

fn print(ctx: &mut ExecutionContext, args: Args) -> ControlFlow {
fn print(ctx: &mut ExecutionContext, mut args: Args) -> ControlFlow {
assert!(args.len() <= 1);

if args.is_empty() {
(ctx.print_fn)(&crate::markup::text(""))
} else {
match &args[0] {
match arg!(args) {
Value::String(string) => (ctx.print_fn)(&crate::markup::text(string)), // print string without quotes
arg => (ctx.print_fn)(&arg.pretty_print()),
}
Expand Down

0 comments on commit 8abc7d4

Please sign in to comment.