Learn Larzscript

57 real, tested Larzscript programs - algorithms, data formats, CLI tools, web, data structures, and money-native tasks no other language treats as a language primitive. Every example is real code with real captured output, not pseudocode.

57tasks solved8categories100%real captured output
๐Ÿงฎ

Algorithms

11 real, tested examples.

algorithmsFizzBuzz in Larzscript

The classic interview warm-up: print 1 to N, but Fizz for multiples of 3, Buzz for multiples of 5, FizzBuzz for both.

algorithmsReverse a String in Larzscript

Flip a string end to end - one of the smallest real string algorithms, and a good first look at the str package.

algorithmsCheck if a String is a Palindrome in Larzscript

Detect whether a string reads the same forwards and backwards, ignoring case, spaces and punctuation.

algorithmsSort a List in Larzscript

Sort a list of numbers - and see exactly how many comparisons and swaps each algorithm actually costs.

algorithmsBinary Search in Larzscript

Find a value in a sorted list in O(log n) instead of scanning every element.

algorithmsFind the Greatest Common Divisor (GCD) in Larzscript

Compute the greatest common divisor of two numbers with the Euclidean algorithm - and see every step.

algorithmsCheck if a Number is Prime in Larzscript

Test primality, and generate a sieve of primes up to a limit.

algorithmsGenerate Fibonacci Numbers in Larzscript

Compute the Nth Fibonacci number - iteratively, so it stays fast even for large N.

algorithmsMatch a Regular Expression in Larzscript

Test, extract, and replace with a real (if deliberately small) regex engine - literals, classes, quantifiers, anchors.

algorithmsCompute the Edit Distance Between Two Strings in Larzscript

The Levenshtein distance: the minimum number of single-character insertions, deletions and substitutions to turn one string into another.

algorithmsFind the Shortest Path with A* Search in Larzscript

Search a 2D grid for the shortest route around obstacles - the real A* algorithm (an open set ordered by f = g + h), not a maze-solver toy.

๐Ÿ—‚๏ธ

Data formats

6 real, tested examples.

โŒจ๏ธ

CLI & text

6 real, tested examples.

๐ŸŒ

Web

10 real, tested examples.

webMake an HTTP GET Request in Larzscript

Fetch a URL and read its status code and body - or parse a JSON API response directly.

webSign and Verify a Webhook Payload in Larzscript

Sign an outgoing webhook payload with HMAC-SHA256, and verify an incoming one - the same shape real payment/webhook providers use.

webHash Data with SHA-256 in Larzscript

Compute a real SHA-256 hash and an HMAC-SHA256 message authentication code.

webGenerate a UUID in Larzscript

Generate random (v4) and time-sortable (v7, ULID, nanoid) unique identifiers.

webGenerate a One-Time Password (TOTP) in Larzscript

Generate and verify RFC 6238 time-based one-time codes - the same 6-digit codes an authenticator app shows.

webRender a Template in Larzscript

Fill a string template with dotted variables and a loop - no framework needed for a page, an email body, or a report.

webBuild a Minimal HTTP Server in Larzscript

Answer a real TCP connection with a real HTTP response - the raw socket_listen/accept/read/write builtins under the tcp package's serve() helper.

webValidate an Email Address in Larzscript

Check whether a string is a plausible email address - no regex of your own to get subtly wrong.

webValidate a Web Form Submission in Larzscript

Validate a whole submitted record against a schema at once - required fields, ranges, and an allowed-choices list - with automatic type coercion.

webGenerate a QR Code in Larzscript

Encode text into a real, spec-accurate QR code - Reed-Solomon error correction and all - rendered as ASCII art.

๐ŸŒณ

Data structures

4 real, tested examples.

๐Ÿ’ณ

Money-native

8 real, tested examples.

money-nativeSplit a Bill Fairly in Larzscript

Divide a bill among people so it reconciles exactly to the cent - no language other than Larzscript treats this as a stack primitive rather than app-level logic.

money-nativeHold Funds in Escrow in Larzscript

Hold a payer's funds, then release them to a payee or refund them back - using the language's own wallet and pay keywords, not a bolted-on library.

money-nativeRate-Limit API Requests in Larzscript

Token-bucket rate limiting in about 20 lines - cap a caller to N requests with a steady refill rate instead of a blunt fixed window.

money-nativeBuild a Subscription Paywall in Larzscript

Gate a feature behind a recurring charge - using paywall, subscribe, and require as real language keywords, not a bolted-on billing library.

money-nativeCalculate a Loan Amortization Schedule in Larzscript

Simple interest, compound interest, and a full monthly amortization schedule - with exact Money math, not float-drifted cents.

money-nativeConvert Currency in Larzscript

Convert an amount between currencies with a settable rate table - fully offline, no API call, no hidden currency-tagging assumptions.

money-nativeKeep a Double-Entry Ledger in Larzscript

Post debits and credits that always balance - the accounting equation holds after every single posting, not just at the end.

money-nativeProrate a Mid-Cycle Subscription Upgrade in Larzscript

A customer upgrades plans partway through a billing period - credit the unused days on the old plan, charge only the difference for the new one.

๐Ÿ“„

Date & time

1 real, tested examples.

๐Ÿ“„

App patterns

11 real, tested examples.

app patternsRetry with Exponential Backoff in Larzscript

Retry a flaky call a few times, waiting longer between each attempt, instead of failing on the first hiccup or hammering a struggling service.

app patternsMemoize a Function in Larzscript

Cache a function's results so calling it twice with the same input only does the real work once.

app patternsImplement a State Machine in Larzscript

Declare states and transitions, fire events, and let the machine reject anything that isn't a legal move - a document workflow (draft -> review -> published) in a few lines.

app patternsPaginate a List in Larzscript

Slice a list into pages with the has_next/has_prev/1-based-index bookkeeping every list-showing page needs, without hand-rolling the off-by-one math again.

app patternsCompare Semantic Versions in Larzscript

Parse major.minor.patch versions, compare them correctly (1.2.0 < 1.10.0, not a naive string compare), and check a version against a real range constraint.

app patternsCache Values with an LRU Cache in Larzscript

Cache expensive results with a bounded, least-recently-used eviction policy, plus one-line memoization for a whole function.

app patternsDebounce and Throttle a Function in Larzscript

Two different ways to rate-limit how often a function actually runs: debounce waits for a quiet gap, throttle guarantees a minimum spacing.

app patternsBuild a Persistent Key-Value Store in Larzscript

Insert, update and query records that survive the process exiting - a tiny document store backed by a plain JSON file.

app patternsRotate and Archive Log Files in Larzscript

Once a log file crosses a size threshold, shift it into numbered backups and start a fresh one - the same scheme logrotate uses.

app patternsBuild a Pub/Sub Event Bus in Larzscript

Decouple producers from consumers with dot-segmented topics and wildcard subscriptions.

app patternsImplement a Circuit Breaker in Larzscript

Stop hammering a failing dependency: after enough real failures, fail fast for a cooldown period instead of trying again.