From: Mark Thom Date: Sun, 2 Sep 2018 05:04:13 +0000 (-0600) Subject: add info to README, prepare for partial strings X-Git-Tag: v0.8.110~406 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=2818e851a0a2acd39d7e04b0641d678b4561695d;p=scryer-prolog.git add info to README, prepare for partial strings --- diff --git a/README.md b/README.md index 03f26aaf..6bc255bc 100644 --- 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` diff --git a/src/prolog/string_list.rs b/src/prolog/string_list.rs index 4a623ef3..cbf39283 100644 --- a/src/prolog/string_list.rs +++ b/src/prolog/string_list.rs @@ -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); @@ -19,33 +20,29 @@ pub struct StringList { body: TabledRc, cursor: usize, // use this to generate a chars() iterator on the fly, // and skip over the first cursor chars. - expandable: bool + expandable: Rc> } impl Hash for StringList { fn hash(&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 - { + fn partial_cmp(&self, other: &Self) -> Option { 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)) } }