Overview

Examples Compendium

Practical, working examples of DWScript in action, organized by category.

Language & OOP

BigInteger

Arbitrary-precision math and number theory

Class Operators

Custom Class Operators Demo

Contracts Dbc

Design by Contract Demo

Enums Sets Flags

Enumerations - named constants

Interfaces Polymorphism

Interfaces and Polymorphism Demo

Json Demo

Example of Json Demo

Lambdas Closures

Lambdas and Functional Patterns

Metaclasses

treating classes as first-class values

Object Oriented Programming

Inheritance and Polymorphism

Records Advanced

Records in DWScript support default values and anonymous syntax

Rtti Attributes

RTTI and Custom Attributes Demo

RTTI

Inspecting types at runtime via Attributes

Text Processing

Pattern Matching

String pattern matching.

Roman Numerals

Converting integers to Roman Numerals.

String Ops

Common string manipulation tasks

Vigenere Cipher

Basic Vigenere Cipher implementation.

Data Structures

Advanced dynamic array operations

Managing a dynamic task list

Array Functional

Advanced functional operations on arrays

Array Multidimensional

Multi-dimensional dynamic arrays (Matrix)

Array Slicing

Array slicing and ranges

Array Sorting

Sorting and reversing arrays

Array Stacks Queues

Using arrays as Stacks (LIFO) and Queues (FIFO)

Array Statistics

Comprehensive statistics on an array of Floats

Assoc Basic

Basic associative array usage

Assoc Complex Keys

Using non-string keys in associative arrays

Assoc Complex Values

Storing records in associative arrays

Assoc Counting

Frequency counting using associative arrays

Assoc Grouping

Grouping data using associative arrays of arrays

Assoc Iteration

Iterating over associative arrays

Functional Arrays

Dynamic array operations with loops.

Math & Science

BigInteger

Arbitrary precision integers

BigInteger

Arbitrary-precision math and number theory

Fft Simple

Simple FFT Magnitude calculation.

Fibonacci Sequence

Generating numbers using recursion and memoization.

Haversine

Haversine formula to calculate the great-circle distance between two points

Matrix Mult

Matrix multiplication using 1D array.

Root Finding

Finding roots of f(x) = x^3 - 3x^2 + 2x using Secant method.

Classic Algorithms

Eratosthenes

The Sieve of Eratosthenes efficiently find all prime numbers up to a given limit.

Factorization

Simple algorithm to find the prime factors of a given integer.

Towers of Hanoi

Classic recursive puzzle solution.

Levenshtein

The Levenshtein distance is a string metric for measuring the difference

Maze

Recursive Backtracking Maze Generator

Sorting Algorithms

Implementation of Bubble Sort and Quick Sort.

Data & Databases

ByteBuffer

Binary data manipulation

Json Demo

Example of Json Demo

Sqlite Basics

SQLite Database Example

Sqlite Bulk Json

SQLite Bulk Insert via JSON

Sqlite Datasets

SQLite DataSet Navigation

Sqlite Json

SQLite JSON Export Demo

Sqlite Transactions

SQLite Transactions Demo

Web Applications

Etag Demo

Example of Etag Demo

Headers Cookies

Example of Headers Cookies

Rate Limiting

This example demonstrates how to implement a simple rate limiter

Redirect Demo

Example of Redirect Demo

Response Basic

Example of Response Basic

Server Info

Example of Server Info

Sse Demo

Example of Sse Demo

Graphics & Visuals

Mandelbrot

Mandelbrot Set - ASCII Rendering

Pixmap Formats

TPixmap image formats (PNG & JPEG)

Vectors 3d

This example demonstrates 3D Vector mathematics using the built-in TVector type.

On this page