--- /dev/null
+#!/bin/bash
+java Example_CountingNumber_0
+import com.ReasoningTechnology.Ariadne.Ariadne_SRM;
import java.math.BigInteger;
public class Example_CountingNumber_0{
if( !n.can_read() ) return;
- if( n.state() == Ariadne_SRM.MachineState.SEGMENT ){
+ if( n.topology() == Ariadne_SRM.Topology.SEGMENT ){
do{
System.out.println("Current Number: " + n.read());
if( !n.can_step() ) break;
n.step();
}while( true );
- }else if( n.state() == Ariadne_SRM.MachineState.INFINITE ){
+ }else if( n.topology() == Ariadne_SRM.Topology.INFINITE ){
int count = 0;
do{
System.out.println("Current Number: " + n.read());
--- /dev/null
+#!/bin/bash
+java Example_IndexTree_4x4
import com.ReasoningTechnology.Ariadne.Ariadne_SRM;
import com.ReasoningTechnology.Ariadne.Ariadne_SRM_List;
+import com.ReasoningTechnology.Ariadne.Ariadne_IndexTree_Child_SRM;
+import com.ReasoningTechnology.Ariadne.Ariadne_IndexTree_Graph;
+import com.ReasoningTechnology.Ariadne.Ariadne_IndexTree_Node;
import java.math.BigInteger;
Ariadne_IndexTree_Graph graph = new Ariadne_IndexTree_Graph();
Ariadne_SRM<BigInteger[]> root = graph.start();
- Ariadne_IndexTree_Node label;
+ BigInteger label[];
Ariadne_IndexTree_Node node;
Ariadne_SRM<BigInteger[]> child_srm;
--- /dev/null
+#!/bin/bash
+java Example_IndexTree_Diagonal_SRM
--- /dev/null
+#!/bin/bash
+java Example_SRMI_Array
public class Example_SRMI_Array {
public static void main( String[] args ){
- // Create a list
- List<String> label_list = Arrays.asList( "A" ,"B" ,"C" ,"D" );
+ // Create an Array
+ List<String> label_array = Arrays.asList( "A", "B", "C", "D" );
- // Attach SRMI to the list
- Ariadne_SRMI_Array<String> srm = Ariadne_SRMI_Array.make( label_list );
-
- // Use the SRMI
- System.out.println( "Topology: " + srm.topology() );
- System.out.println( "Location: " + srm.location() );
-
- // Traverse the list
- while( srm.location() != Ariadne_SRM.Location.RIGHTMOST ){
- System.out.println( "Reading: " + srm.access() );
- srm.step();
+ // Attach SRMI to the array
+ Ariadne_SRMI_Array<String> srm = Ariadne_SRMI_Array.make( label_array );
+ if( srm.can_read() ){
+ do{
+ System.out.println( "Reading: " + srm.read() );
+ System.out.println( "Topology: " + srm.topology() );
+ if( !srm.can_step() ) break;
+ srm.step();
+ }while(true);
}
-
- // Final item
- System.out.println( "Reading: " + srm.access() );
- System.out.println( "Location: " + srm.location() );
}
}
--- /dev/null
+#!/bin/bash
+java Example_SRM_List
import java.util.LinkedList;
-public class Example_SRM_List{
- public static void main(String[] args){
+public class Example_SRM_List {
+ public static void main( String[] args ){
// Create a linked list
LinkedList<String> label_list = new LinkedList<>();
- label_list.add("A");
- label_list.add("B");
- label_list.add("C");
+ label_list.add( "A" );
+ label_list.add( "B" );
+ label_list.add( "C" );
- // Attach SRM to the linked list
+ // Attach SRM to the linked list and traverse
Ariadne_SRM_List<String> srm = Ariadne_SRM_List.make(label_list);
-
- // Use the SRM
- System.out.println( "Topology: " + srm.topology() );
- System.out.println( "Initial Location: " + srm.location() );
-
- // Traverse the list
- while( srm.location() != Ariadne_SRM.Location.RIGHTMOST ){
- System.out.println("Reading: " + srm.access());
- srm.step();
+ if( srm.can_read() ){
+ do{
+ System.out.println( "Reading: " + srm.read() );
+ System.out.println( "Topology: " + srm.topology() );
+ if( !srm.can_step() ) break;
+ srm.step();
+ }while(true);
}
-
- // Final item
- System.out.println(" Reading: " + srm.access() );
- System.out.println(" Final Location: " + srm.location() );
-
- // Rewind the SRM and traverse again
- srm.rewind();
- System.out.println( "After rewind: " + srm.access() );
}
}
import com.ReasoningTechnology.Ariadne.Ariadne_SRM;
import com.ReasoningTechnology.Ariadne.Ariadne_IndexTree_Node;
-public class IndexTree_Diagonal_SRM extends Ariadne_SRM<List<BigInteger[]>> {
+public class IndexTree_Diagonal_SRM extends Ariadne_SRM<List<BigInteger[]>>{
+ // Instance data
private final List<BigInteger[]> list_of__unopened_node;
private final List<List<BigInteger[]>> list_of__opened_incomplete_child_list;
private final List<BigInteger[]> read_list;
- private final Ariadne_Test tester;
- public static IndexTree_Diagonal_SRM make() {
- return new IndexTree_Diagonal_SRM();
- }
-
- protected IndexTree_Diagonal_SRM() {
+ // Constructor
+ protected IndexTree_Diagonal_SRM(){
this.list_of__unopened_node = new ArrayList<>();
this.list_of__opened_incomplete_child_list = new ArrayList<>();
this.read_list = new ArrayList<>();
- this.tester = Ariadne_Test.make("IndexTree_Diagonal_SRM: ");
enqueue_root();
}
+ // Static factory method
+ public static IndexTree_Diagonal_SRM make(){
+ return new IndexTree_Diagonal_SRM();
+ }
+
@Override
- public List<BigInteger[]> access() {
+ public List<BigInteger[]> read(){
return read_list;
}
@Override
- public void step() {
+ public void step(){
read_list.clear();
- while (!list_of__unopened_node.isEmpty()) {
+ // Process unopened nodes
+ while( !list_of__unopened_node.isEmpty() ){
BigInteger[] label = list_of__unopened_node.remove(0);
// Retrieve the node using lookup
// Descend by getting neighbors
List<BigInteger[]> child_labels = fetch_child_labels(node);
- if (!child_labels.isEmpty()) {
+ if( !child_labels.isEmpty() ){
list_of__opened_incomplete_child_list.add(child_labels);
}
}
- while (!list_of__opened_incomplete_child_list.isEmpty()) {
+ // Process incomplete child lists
+ while( !list_of__opened_incomplete_child_list.isEmpty() ){
List<BigInteger[]> child_labels = list_of__opened_incomplete_child_list.remove(0);
- if (!child_labels.isEmpty()) {
+ if( !child_labels.isEmpty() ){
BigInteger[] label = child_labels.remove(0);
read_list.add(label);
- tester.print("Queued label: " + format_label(label));
-
// Retrieve node and check its neighbors
Ariadne_IndexTree_Node node = lookup(label);
- if (!fetch_child_labels(node).isEmpty()) {
+ if( !fetch_child_labels(node).isEmpty() ){
list_of__unopened_node.add(label);
}
}
}
}
- private void enqueue_root() {
+ private void enqueue_root(){
BigInteger[] root_label = new BigInteger[0];
read_list.add(root_label);
- tester.print("Queued root label: " + format_label(root_label));
-
Ariadne_IndexTree_Node root_node = lookup(root_label);
- if (!fetch_child_labels(root_node).isEmpty()) {
+ if( !fetch_child_labels(root_node).isEmpty() ){
list_of__unopened_node.add(root_label);
}
}
- private Ariadne_IndexTree_Node lookup(BigInteger[] label) {
+ private Ariadne_IndexTree_Node lookup(BigInteger[] label){
// Perform a lookup to retrieve the node corresponding to the label
return Ariadne_IndexTree_Node.make(label);
}
- private List<BigInteger[]> fetch_child_labels(Ariadne_IndexTree_Node node) {
+ private List<BigInteger[]> fetch_child_labels(Ariadne_IndexTree_Node node){
List<BigInteger[]> child_labels = new ArrayList<>();
- if (node != null) {
+ if(node != null){
Ariadne_SRM<BigInteger[]> neighbor_srm = node.neighbor();
- while (neighbor_srm.can_step()) {
+ while( neighbor_srm.can_step() ){
child_labels.add(neighbor_srm.read());
neighbor_srm.step();
}
return child_labels;
}
-
- private String format_label(BigInteger[] label) {
- StringBuilder formatted = new StringBuilder("[");
- for (int i = 0; i < label.length; i++) {
- formatted.append(label[i].toString());
- if (i < label.length - 1) formatted.append(",");
- }
- formatted.append("]");
- return formatted.toString();
- }
}
return true;
}
@Override public void step(){
+ increment();
label[label.length - 1] = index();
}
@Override public Topology topology(){
return current_index;
}
- @Override
- public void step(){
- current_topology.step();
+ public void increment(){
current_index = current_index.add(BigInteger.ONE);
}
}
}
@Override
public void step(){
- Ariadne_SRMI_Array.super.step();
- if( index().compareTo(BigInteger.valueOf(array.size() - 1)) < 0 )
+ increment();
+ if( index().compareTo(BigInteger.valueOf(array.size() - 1)) == 0 )
set_topology(topo_rightmost);
}
@Override
*/
package com.ReasoningTechnology.Ariadne;
import java.util.List;
+import java.util.ListIterator;
public class Ariadne_SRM_List<T> extends Ariadne_SRM<T>{
- private final List<T> list;
- private int current_index;
+ // Static methods
+ public static <T> Ariadne_SRM_List<T> make(List<T> list){
+ return new Ariadne_SRM_List<>(list);
+ }
+
+ private List<T> list; // The attached linked list
+ private ListIterator<T> iterator; // Iterator for traversal
+ private T read_value; // Stores the current cell value
private final TopoIface<T> topo_null = new TopoNull();
private final TopoIface<T> topo_segment = new TopoSegment();
private final TopoIface<T> topo_rightmost = new TopoRightmost();
- public Ariadne_SRM_List(List<T> list){
+ protected Ariadne_SRM_List(List<T> list){
+ this.list = list;
if( list == null || list.isEmpty() ){
- this.list = null;
- set_topology( topo_null );
+ this.iterator = null;
+ set_topology(topo_null);
return;
}
- this.list = list;
- this.current_index = 0;
- set_topology( topo_segment );
+ this.iterator = list.listIterator();
+ read_value = iterator.next();
+
+ if( list.size() == 1 ){
+ set_topology(topo_rightmost);
+ return;
+ }
+
+ set_topology(topo_segment);
}
private class TopoNull implements TopoIface<T>{
- @Override
- public boolean can_read(){
+ @Override public boolean can_read(){
return false;
}
- @Override
- public T read(){
+ @Override public T read(){
throw new UnsupportedOperationException( "Cannot read from NULL topo." );
}
- @Override
- public boolean can_step(){
+ @Override public boolean can_step(){
return false;
}
- @Override
- public void step(){
- throw new UnsupportedOperationException( "Cannot step from NULL topo." );
+ @Override public void step(){
+ throw new UnsupportedOperationException( "Cannot step over NULL topo." );
}
- @Override
- public Topology topology(){
+ @Override public Topology topology(){
return Topology.NULL;
}
}
private class TopoSegment implements TopoIface<T>{
- @Override
- public boolean can_read(){
+ @Override public boolean can_read(){
return true;
}
- @Override
- public T read(){
- return list.get( current_index );
+ @Override public T read(){
+ return read_value;
}
- @Override
- public boolean can_step(){
- return current_index < list.size() - 1;
+ @Override public boolean can_step(){
+ return true;
}
- @Override
- public void step(){
- if( can_step() ){
- current_index++;
- }else{
- set_topology( topo_rightmost );
- }
+ @Override public void step(){
+ read_value = iterator.next();
+ if( !iterator.hasNext() ) set_topology(topo_rightmost);
}
- @Override
- public Topology topology(){
+ @Override public Topology topology(){
return Topology.SEGMENT;
}
}
private class TopoRightmost implements TopoIface<T>{
- @Override
- public boolean can_read(){
+ @Override public boolean can_read(){
return true;
}
- @Override
- public T read(){
- return list.get( current_index );
+ @Override public T read(){
+ return read_value;
}
- @Override
- public boolean can_step(){
+ @Override public boolean can_step(){
return false;
}
- @Override
- public void step(){
+ @Override public void step(){
throw new UnsupportedOperationException( "Cannot step from RIGHTMOST topo." );
}
- @Override
- public Topology topology(){
+ @Override public Topology topology(){
return Topology.RIGHTMOST;
}
}
rm_na jvm/*
rm_na bash/*
-
-# remove example class files
-
- cd example || exit 1
-
- for file in Example_*.class; do
- echo "file: " $file
- rm_na "$file"
- wrapper_name=$(basename "$file" .class)
- rm_na "$wrapper_name"
- done
-
-
set +x
echo "$(script_fn) done."
--- /dev/null
+#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
+
+# Removes all files found in the build directories. It asks no questions as to
+# how or why the files got there. Be especially careful with the 'bash'
+# directory if you have authored scripts for release, add a `bash🖉`
+# directory instead of putting them in `bash`.
+
+cd "$REPO_HOME"/developer || exit 1
+source tool🖉/env_script
+
+# remove example class files
+
+ cd example || exit 1
+
+ for file in Example_*.class; do
+ echo "file: " $file
+ rm_na "$file"
+ wrapper_name=$(basename "$file" .class)
+ rm_na "$wrapper_name"
+ done
+
+echo "$(script_fn) done."
+
echo "Creating bash wrappers..."
-set -x
-
-for file in Example_*.class; do
- echo "file: " $file
- wrapper_name=$(basename "$file" .class)
- cat > "$wrapper_name" << EOL
+ for file in Example_*.class; do
+ echo "file: " $file
+ wrapper_name=$(basename "$file" .class)
+ cat > "$wrapper_name" << EOL
#!/bin/bash
java $wrapper_name
EOL
-
- # Make the wrapper executable
- chmod +x "$wrapper_name"
- done
-
-set +x
+ # Make the wrapper executable
+ chmod +x "$wrapper_name"
+ done
echo "$(script_fp) done."