From 992865e827cdfffa6451ca37e74f185c5228f894 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Fri, 1 Aug 2025 11:59:41 +0300 Subject: Modified quote so the values of lists are evaluated --- src/sexp/step.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/sexp/step.rs') diff --git a/src/sexp/step.rs b/src/sexp/step.rs index 0989ee3..765e33c 100644 --- a/src/sexp/step.rs +++ b/src/sexp/step.rs @@ -83,6 +83,27 @@ impl SExp { /// } /// /// ``` + /// + /// **Quotes** + /// If an s-expression should not be evaluated + /// as a function, but it is instead to be treated + /// as a list, `quote` can be used. + /// With it as the operator, the rest of the list + /// is evaluated to values, but they are not passed + /// to the operator after that. + /// ```rust + /// use melisp::sexp::{SExp::*, SLeaf::*, util::*}; + /// assert_eq!( + /// scons(Quote, scons(1, scons(2, Nil))).step(), + /// Ok(scons(Quote, scons(1, scons(2, Nil)))) + /// ); + /// assert_eq!( + /// scons(Quote, scons( + /// scons(Sub, scons(2, scons(1, Nil))), + /// scons(2, Nil))).step(), + /// Ok(scons(Quote, scons(1, scons(2, Nil)))) + /// ); + /// ``` pub fn step(self) -> Result { match self { -- cgit v1.2.3