moved lamm to it's own repository

This commit is contained in:
2024-10-14 18:01:34 -04:00
parent 9317c83dec
commit 053ec0ba67
7 changed files with 38 additions and 953 deletions

28
src/commands/eval.rs Normal file
View File

@@ -0,0 +1,28 @@
use crate::common::{Context, Error};
use std::io::Cursor;
/// Evaluates a Lamm program
#[poise::command(slash_command, prefix_command)]
pub async fn eval(ctx: Context<'_>,
#[rest]
expr: String) -> Result<(), Error>
{
let values = lamm::evaluate(Cursor::new(expr));
let output = values.fold(Ok(String::new()), |acc, v| {
if acc.is_err() {
return acc;
};
let x = acc.unwrap();
match v {
Ok(v) => Ok(format!("{x}\n{v}")),
Err(e) => Err(e),
}
});
ctx.reply(output?).await?;
Ok(())
}