add info to README, prepare for partial strings

This commit is contained in:
Mark Thom
2018-09-01 23:04:13 -06:00
parent 575955c7b3
commit 2818e851a0
2 changed files with 9 additions and 12 deletions

View File

@@ -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`

View 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))
}
}