aboutsummaryrefslogtreecommitdiff
path: root/src/sexp/step.rs
diff options
context:
space:
mode:
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 {