Print methods

This commit is contained in:
elvis
2025-06-18 11:28:04 +02:00
parent d074812179
commit bbff61f71a
7 changed files with 415 additions and 83 deletions

View File

@ -1,15 +1,15 @@
#![allow(dead_code)]
use super::structure::{RSChoices, RSenvironment, RSlabel, RSprocess, RSset, RSsystem};
use super::structure::{RSchoices, RSenvironment, RSlabel, RSprocess, RSset, RSsystem};
use super::support_structures::TransitionsIterator;
use std::rc::Rc;
pub fn unfold(
environment: &RSenvironment,
context_process: &RSprocess,
) -> Result<RSChoices, String> {
) -> Result<RSchoices, String> {
match context_process {
RSprocess::Nill => Ok(RSChoices::new()),
RSprocess::Nill => Ok(RSchoices::new()),
RSprocess::RecursiveIdentifier { identifier } => {
let newprocess = environment.get(*identifier);
if let Some(newprocess) = newprocess {
@ -21,7 +21,7 @@ pub fn unfold(
RSprocess::EntitySet {
entities,
next_process,
} => Ok(RSChoices::from(vec![(
} => Ok(RSchoices::from(vec![(
Rc::new(entities.clone()),
Rc::clone(next_process),
)])),
@ -54,7 +54,7 @@ pub fn unfold(
}
RSprocess::Summation { children } => {
// short-circuits with try_fold.
children.iter().try_fold(RSChoices::new(), |mut acc, x| {
children.iter().try_fold(RSchoices::new(), |mut acc, x| {
match unfold(environment, x) {
Ok(mut choices) => {
acc.append(&mut choices);
@ -67,12 +67,12 @@ pub fn unfold(
RSprocess::NondeterministicChoice { children } => {
// short-circuits with try_fold.
if children.is_empty() {
Ok(RSChoices::from(vec![(
Ok(RSchoices::from(vec![(
Rc::new(RSset::new()),
Rc::new(RSprocess::Nill),
)]))
} else {
children.iter().try_fold(RSChoices::new(), |mut acc, x| {
children.iter().try_fold(RSchoices::new(), |mut acc, x| {
acc.shuffle(unfold(environment, x)?);
Ok(acc)
})