From: Thomas Walker Lynch Date: Sun, 12 Jan 2025 16:16:58 +0000 (+0000) Subject: taking a break.. X-Git-Url: https://git.reasoningtechnology.com/style/static/git-logo.png?a=commitdiff_plain;h=eb3c1b2686ee80bd077725f079f825f36e652efb;p=Ariadne taking a break.. --- diff --git "a/developer/document\360\237\226\211/precise_loop.html" "b/developer/document\360\237\226\211/precise_loop.html" new file mode 100644 index 0000000..8ca21b2 --- /dev/null +++ "b/developer/document\360\237\226\211/precise_loop.html" @@ -0,0 +1,131 @@ + + + + + + + Precise Loops in RT Code + + + +
+
+

Precise Loops in RT Code

+

© 2024 Thomas Walker Lynch - All Rights Reserved.

+
+ +

Introduction

+

In RT code, precise loops are an important construct designed to ensure that all iterations over a collection or sequence maintain clarity, correctness, and alignment with RT coding conventions. This document explains the characteristics, structure, and benefits of precise loops.

+ +

Definition of Precise Loops

+

A precise loop is a structured iteration pattern that ensures the following:

+ + +

Core Principles

+

Precise loops consist of the following:

+ + +

Structure of a Precise Loop

+

The following example demonstrates a typical precise loop for iterating over an SRTM:

+
if( srtm.can_read() ){
+  do{
+    // Process the current element
+    process( srtm.read() );
+
+    // Advance to the next element
+    if( !srtm.can_step() ) break;
+    srtm.step();
+  }while( true );
+}
+ +

Key Characteristics

+ + +

Advantages of Precise Loops

+

Using precise loops in RT code offers several benefits:

+ + +

Examples in Practice

+

Here is an example of a precise loop for formatting a Label:

+
StringBuilder formatted = new StringBuilder("Label(");
+Ariadne_SRTM_List value_srtm = Ariadne_SRTM_List.make(Arrays.asList(value));
+if( value_srtm.can_read() ){
+  do{
+    formatted.append(value_srtm.read().toString());
+    if( !value_srtm.can_step() ) break;
+    formatted.append(" ,");
+    value_srtm.step();
+  }while( true );
+}
+formatted.append(")");
+

This approach eliminates the need for special cases when inserting separators, ensuring consistent and concise code regardless of the collection size.

+ +

Conclusion

+

Precise loops represent a fundamental aspect of RT coding practices, providing a structured and reliable way to iterate over sequences. By adopting precise loops, developers can write code that is not only efficient and clear but also adheres to the highest standards of consistency and maintainability.

+

Their additional benefits, such as expressiveness, alignment with RT philosophy, optimization potential, and aesthetic discipline, further reinforce their value in creating high-quality, sustainable software.

+
+ + diff --git a/developer/example/IndexTree/Example_SRTM_Diagonal.java b/developer/example/IndexTree/Example_SRTM_Diagonal.java index 6473a04..9b69fee 100644 --- a/developer/example/IndexTree/Example_SRTM_Diagonal.java +++ b/developer/example/IndexTree/Example_SRTM_Diagonal.java @@ -1,39 +1,22 @@ import java.util.List; -import com.ReasoningTechnology.Ariadne.Ariadne_SRTM_List; -public class Example_SRTM_Diagonal { +public class Example_SRTM_Diagonal{ public static void main(String[] args){ System.out.println("Starting IndexTree SRTM Example"); // Instantiate the IndexTree Diagonal SRTM SRTM_Diagonal srtm = SRTM_Diagonal.make(); - int step_count = 0; - do{ - System.out.println("Diagonal " + step_count + ":"); - - // Read and print the current diagonal - List