Fixing Freq, now main functions
This commit is contained in:
@ -15,11 +15,11 @@ fn main() -> std::io::Result<()> {
|
|||||||
|
|
||||||
examples::freq()?;
|
examples::freq()?;
|
||||||
|
|
||||||
// examples::hoop()?;
|
examples::hoop()?;
|
||||||
|
|
||||||
// examples::target()?;
|
examples::target()?;
|
||||||
|
|
||||||
// examples::run()?;
|
examples::run()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,6 +28,10 @@ impl Frequency {
|
|||||||
for &el in e.iter() {
|
for &el in e.iter() {
|
||||||
self.frequency_map.entry(el).or_insert(vec![0; run + 1])[run] += 1
|
self.frequency_map.entry(el).or_insert(vec![0; run + 1])[run] += 1
|
||||||
}
|
}
|
||||||
|
// TODO resize clones all prev values, replace with in place method
|
||||||
|
if self.totals.len() < run + 1 {
|
||||||
|
self.totals.resize(run + 1, 0);
|
||||||
|
}
|
||||||
self.totals[run] += 1
|
self.totals[run] += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -95,7 +95,7 @@ CTX_process: RSprocess = {
|
|||||||
RSprocess::WaitEntity{ repeat: n,
|
RSprocess::WaitEntity{ repeat: n,
|
||||||
repeated_process: Rc::new(k1),
|
repeated_process: Rc::new(k1),
|
||||||
next_process: Rc::new(k) },
|
next_process: Rc::new(k) },
|
||||||
"nil" => RSprocess::Nill,
|
"nill" => RSprocess::Nill,
|
||||||
<identifier: Literal> =>
|
<identifier: Literal> =>
|
||||||
RSprocess::RecursiveIdentifier{
|
RSprocess::RecursiveIdentifier{
|
||||||
identifier: translator.encode(identifier)
|
identifier: translator.encode(identifier)
|
||||||
|
|||||||
@ -186,7 +186,7 @@ impl Default for RSreaction {
|
|||||||
pub enum RSprocess {
|
pub enum RSprocess {
|
||||||
Nill,
|
Nill,
|
||||||
RecursiveIdentifier {
|
RecursiveIdentifier {
|
||||||
identifier: IdType,
|
identifier: IdType,
|
||||||
},
|
},
|
||||||
EntitySet {
|
EntitySet {
|
||||||
entities: RSset,
|
entities: RSset,
|
||||||
|
|||||||
@ -147,6 +147,7 @@ pub fn run_separated(
|
|||||||
let current = current.unwrap();
|
let current = current.unwrap();
|
||||||
res.push(current.0.get_context());
|
res.push(current.0.get_context());
|
||||||
let mut current = current.1;
|
let mut current = current.1;
|
||||||
|
|
||||||
while let Some((label, next)) = one_transition(¤t)? {
|
while let Some((label, next)) = one_transition(¤t)? {
|
||||||
current = next;
|
current = next;
|
||||||
res.push(label.get_context());
|
res.push(label.get_context());
|
||||||
|
|||||||
@ -37,12 +37,10 @@ impl Translator {
|
|||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decode(&self, el: IdType) -> String {
|
pub fn decode(&self, el: IdType) -> Option<String> {
|
||||||
// TODO maybe find more efficient method??
|
|
||||||
self.reverse
|
self.reverse
|
||||||
.get(&el)
|
.get(&el)
|
||||||
.map(|x| x.to_string())
|
.map(|x| x.to_string())
|
||||||
.unwrap_or(String::from("Not Found"))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,9 +159,13 @@ fn print_set(
|
|||||||
let mut it = set.iter().peekable();
|
let mut it = set.iter().peekable();
|
||||||
while let Some(el) = it.next() {
|
while let Some(el) = it.next() {
|
||||||
if it.peek().is_none() {
|
if it.peek().is_none() {
|
||||||
write!(f, "{}", translator.decode(*el))?;
|
write!(f,
|
||||||
|
"{}",
|
||||||
|
translator.decode(*el).unwrap_or("Missing".into()))?;
|
||||||
} else {
|
} else {
|
||||||
write!(f, "{}, ", translator.decode(*el))?;
|
write!(f,
|
||||||
|
"{}, ",
|
||||||
|
translator.decode(*el).unwrap_or("Missing".into()))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write!(f, "}}")
|
write!(f, "}}")
|
||||||
@ -194,7 +196,9 @@ fn print_process(
|
|||||||
write!(f, "[Nill]")
|
write!(f, "[Nill]")
|
||||||
}
|
}
|
||||||
RecursiveIdentifier { identifier } => {
|
RecursiveIdentifier { identifier } => {
|
||||||
write!(f, "[{}]", translator.decode(*identifier))
|
write!(f,
|
||||||
|
"[{}]",
|
||||||
|
translator.decode(*identifier).unwrap_or("Missing".into()))
|
||||||
}
|
}
|
||||||
EntitySet {
|
EntitySet {
|
||||||
entities,
|
entities,
|
||||||
@ -301,14 +305,14 @@ fn print_environment(
|
|||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"({} -> {})",
|
"({} -> {})",
|
||||||
translator.decode(*el.0),
|
translator.decode(*el.0).unwrap_or("Missing".into()),
|
||||||
WithTranslator::from_RSprocess(translator, el.1)
|
WithTranslator::from_RSprocess(translator, el.1)
|
||||||
)?;
|
)?;
|
||||||
} else {
|
} else {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"({} -> {}), ",
|
"({} -> {}), ",
|
||||||
translator.decode(*el.0),
|
translator.decode(*el.0).unwrap_or("Missing".into()),
|
||||||
WithTranslator::from_RSprocess(translator, el.1)
|
WithTranslator::from_RSprocess(translator, el.1)
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
@ -407,7 +411,7 @@ fn print_frequency(
|
|||||||
let mut freq_it = frequency.frequency_map.iter().peekable();
|
let mut freq_it = frequency.frequency_map.iter().peekable();
|
||||||
|
|
||||||
while let Some((e, freq)) = freq_it.next() {
|
while let Some((e, freq)) = freq_it.next() {
|
||||||
write!(f, "{} -> ", translator.decode(*e))?;
|
write!(f, "{} -> ", translator.decode(*e).unwrap_or("Missing".into()))?;
|
||||||
|
|
||||||
let mut iter = freq
|
let mut iter = freq
|
||||||
.iter()
|
.iter()
|
||||||
|
|||||||
Reference in New Issue
Block a user