]> Repositorios git - scryer-prolog.git/commitdiff
add info to README, prepare for partial strings
authorMark Thom <[email protected]>
Sun, 2 Sep 2018 05:04:13 +0000 (23:04 -0600)
committerMark Thom <[email protected]>
Sun, 2 Sep 2018 05:04:13 +0000 (23:04 -0600)
README.md
src/prolog/string_list.rs

index 03f26aafcb5d0eb8e5b36849cc3367c10cb504f6..6bc255bc68ad22e91f6a7c8210fc0e6aac50a4d1 100644 (file)
--- a/README.md
+++ b/README.md
@@ -111,7 +111,7 @@ The following predicates are built-in to rusty-wam.
 
 * Arithmetic support:
     * `is/2` works for `(+)/2`, `(-)/{1,2}`, `(*)/2`, `(//)/2`, `(^)/2`, `(div)/2`, `(/)/2`, `(rdiv)/2`,
-      `(xor)/2`, `(rem)/2`, `(mod)/2`, `(/\)/2`, `(\/)/2`, `(>>)/2`, `(<<)/2`.
+      `(xor)/2`, `(rem)/2`, `(mod)/2`, `(/\)/2`, `(\/)/2`, `(>>)/2`, `(<<)/2`, `abs/1`.
     * Comparison operators: `>`, `<`, `=<`, `>=`, `=:=`, `=\=`.
 * `(:)/2`
 * `(@>)/2`
index 4a623ef350f7a0f32a4ab2686ee003730dbc8de5..cbf392832d0f6e0e93984a7e669e3d20e2ac88e6 100644 (file)
@@ -1,8 +1,9 @@
 use prolog::tabled_rc::*;
 
-use std::cell::{Ref, RefCell};
+use std::cell::{Cell, Ref, RefCell};
 use std::cmp::Ordering;
 use std::hash::{Hash, Hasher};
+use std::rc::Rc;
 
 #[derive(PartialOrd, PartialEq, Ord, Eq)]
 pub struct StringListWrapper(RefCell<String>);
@@ -19,33 +20,29 @@ pub struct StringList {
     body: TabledRc<StringListWrapper>,
     cursor: usize, // use this to generate a chars() iterator on the fly,
                    // and skip over the first cursor chars.
-    expandable: bool
+    expandable: Rc<Cell<bool>>
 }
 
 impl Hash for StringList {
     fn hash<H: Hasher>(&self, state: &mut H) {
-        let h = self.borrow().hash(state);
-        (h, self.cursor, self.expandable).hash(state);
+        (self.borrow().as_str(), self.cursor, self.expandable.get()).hash(state);
     }
 }
 
 impl PartialOrd for StringList {
-    fn partial_cmp(&self, other: &Self) -> Option<Ordering>
-    {
+    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
         Some(self.body.cmp(&other.body))
     }
 }
 
 impl Ord for StringList {
-    fn cmp(&self, other: &Self) -> Ordering
-    {
+    fn cmp(&self, other: &Self) -> Ordering {
         self.body.cmp(&other.body)
     }
 }
 
 impl PartialEq for StringList {
-    fn eq(&self, other: &Self) -> bool
-    {
+    fn eq(&self, other: &Self) -> bool {
         self.body == other.body && self.cursor == other.cursor && self.expandable == other.expandable
     }
 }
@@ -60,7 +57,7 @@ impl StringList {
         StringList {
             cursor: 0,
             body,
-            expandable
+            expandable: Rc::new(Cell::new(expandable))
         }
     }