pad

Sequence/Iteration Support

This module provides powerful sequence generation capabilities for the PAD framework, supporting mathematical sequences, number theory sequences, random generation, and array operations.

Overview

The sequence module (internally prefixed with pq) enables templates to generate and manipulate numeric sequences like Fibonacci, primes, ranges, and many specialized mathematical sequences. It provides a comprehensive system for building sequences with customizable parameters (from/to, increment, limits), applying transformations (sort, reverse, dedup), and extracting results (sum, average, count).

Directory Structure

Core Components

Sequence Types (types/)

Over 70 mathematical and number theory sequences including:

Arithmetic Sequences

Number Properties

Famous Sequences

Polygonal Numbers

3D Figurate Numbers

Other Sequences

Utilities

Logical Operations

Actions (actions/)

Transform and analyze sequences:

Aggregation

Selection

Transformation

Combination

Ordering

Structure

Options (options/types/)

Configure sequence generation:

Range Control

Limit Control

Behavior

Ordering

Duplicates

Actions & Storage

Special

Key Features

Flexible Sequence Generation

Powerful Transformations

Advanced Parameters

Storage and Reuse

Integration with PAD Framework

The sequence module extends PAD’s template capabilities:

  1. Template Tags: Sequences accessible via template tags with parameters
  2. Data Generation: Generate data arrays for iteration
  3. Calculations: Perform mathematical operations in templates
  4. Random Data: Generate random datasets for testing/demos
  5. Number Theory: Access mathematical sequences for specialized applications

Usage Pattern

Sequences are invoked through PAD template tags:

{sequence type="fibonacci" from="1" to="10"}
{sequence type="prime" rows="20" action="sum"}
{sequence type="range" from="1" to="100" increment="5" action="average"}
{sequence type="random" from="1" to="100" rows="10" unique="true"}

Parameters control generation, actions transform results, and outputs can be stored for later use.

Example Workflows

  1. Generate Fibonacci sequence: Type=fibonacci, from=1, to=10
  2. Sum first 20 primes: Type=prime, rows=20, action=sum
  3. Random unique numbers: Type=random, from=1, to=100, rows=10, unique=true
  4. Even numbers descending: Type=even, from=2, to=20, negative=true
  5. Average of range: Type=range, from=1, to=100, action=average

This module demonstrates PAD’s extensibility, providing a complete mathematical sequence engine within the template system.