aboutsummaryrefslogtreecommitdiff
path: root/src/sexp/step.rs
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-01 11:59:41 +0300
committerJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-01 11:59:41 +0300
commit992865e827cdfffa6451ca37e74f185c5228f894 (patch)
treebdf89ab4a26aed61ed429795edf192de90350efc /src/sexp/step.rs
parent61b985db80a15e230476af54b0ef8783fd8cbf63 (diff)
downloadmyslip-992865e827cdfffa6451ca37e74f185c5228f894.tar.gz
myslip-992865e827cdfffa6451ca37e74f185c5228f894.zip
Modified quote so the values of lists are evaluated
Diffstat (limited to 'src/sexp/step.rs')
-rw-r--r--src/sexp/step.rs21
1 files changed, 21 insertions, 0 deletions
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<Self, String> {
match self {