diff --git a/lispers-core/src/lisp/expression.rs b/lispers-core/src/lisp/expression.rs index e7dbce6..08dd417 100644 --- a/lispers-core/src/lisp/expression.rs +++ b/lispers-core/src/lisp/expression.rs @@ -192,6 +192,18 @@ impl From> for Expression { } } +impl From<[Expression; N]> for Expression { + fn from(mut value: [Expression; N]) -> Self { + let mut current = Expression::Nil; + + for e in value.iter_mut().rev() { + current = Expression::Cell(Box::new(e.to_owned()), Box::new(current)); + } + + current + } +} + impl From<(Expression, Expression)> for Expression { fn from(value: (Expression, Expression)) -> Self { Expression::Cell(Box::new(value.0), Box::new(value.1))