Home /Modules/recursion/README.md

README.md

recursion/stanchion/README.md · 73 line(s) · markdown

SLeeLa Recursion Stanchion

The stanchion is a curated set of source-file-level recursion prototypes. Each file is a standalone C or C++ example with a focused responsibility, a visible base case, and a documented build command.

Pattern analysis

The original examples in /recursion fall into three input-handling families:

A recursion prototype should make four things explicit: its input contract, base case, progress measure, and failure/resource policy. Recursion is not automatically safer or faster than iteration; deep or untrusted input may require an explicit depth bound or iterative implementation.

Prototype catalogue

C

C++

Build examples

Run commands from this directory:

cc -std=c11 -Wall -Wextra -Wpedantic c_recursive_accumulate.c -o c_recursive_accumulate
c++ -std=c++17 -Wall -Wextra -Wpedantic cpp_recursive_fold.cpp -o cpp_recursive_fold

Each source file includes its own build command. These are portable C/C++ reference prototypes, not SLeeLa-language implementations. Compile and test them on each target platform before treating them as release-verified.

Coverage

The 26 stanchion prototypes cover primitive-specialized recursion, generic reuse, applied algorithms, scientific numerical work, and teaching/traceability. Together with the original eight examples, the directory has 34 focused source examples; the stanchion catalogue is the curated starting point when choosing a pattern for a new implementation.

Primitive-specialized recursion prototypes

The primitive suite adds a C typed module and a C++ typed class for each primitive contract listed in lib/CORE.BASE.md: Boolean, Byte, Character, Integer, Long, Float, and Double. Java-compatibility primitives (such as Java's short) are not silently treated as native SLeeLa primitive contracts.

Each type module demonstrates three applicable recursion patterns: linear sequence traversal, divide-and-conquer range traversal, and structural binary-tree traversal. C uses a typed alias/node structure and functions; C++ uses a dedicated type-specific class and managed tree nodes. These are teaching/reference prototypes, not VM ABI definitions.

PrimitiveC sourceC++ source/classImportant note
booleanc_primitive_boolean_recursion.ccpp_primitive_boolean_recursion.cpp / SLStanchionBooleanRecursorBoolean values support predicate/counting recursion, not numeric accumulation.
bytec_primitive_byte_recursion.ccpp_primitive_byte_recursion.cpp / SLStanchionByteRecursorByte is treated as unsigned 8-bit; do not assume arithmetic wraps unless SLeeLa specifies it.
characterc_primitive_character_recursion.ccpp_primitive_character_recursion.cpp / SLStanchionCharacterRecursorCharacter is modeled as a Unicode scalar/code point, not an arbitrary UTF-8 byte.
integerc_primitive_integer_recursion.ccpp_primitive_integer_recursion.cpp / SLStanchionIntegerRecursorThis prototype uses signed 32-bit values; confirm the canonical SLInteger width.
longc_primitive_long_recursion.ccpp_primitive_long_recursion.cpp / SLStanchionLongRecursorThis prototype uses signed 64-bit values; confirm canonical SLLong width and overflow rules.
floatc_primitive_float_recursion.ccpp_primitive_float_recursion.cpp / SLStanchionFloatRecursorExact equality is demonstration-only; scientific algorithms should use an explicit tolerance.
doublec_primitive_double_recursion.ccpp_primitive_double_recursion.cpp / SLStanchionDoubleRecursorExact equality is demonstration-only; scientific algorithms should use an explicit tolerance.

Pattern applicability

The C Character prototype uses uint32_t, while C++ uses char32_t; confirm the canonical SLeeLa character representation before integration. Confirm Byte, Integer, and Long widths against the runtime contracts. These prototypes have not yet been compiled or run as part of this update.