# Thun 0.4.1 Documentation

Thun is dialect of Joy written in Python.

Joy is a programming language created by Manfred von Thun that is easy to use and understand and has many other nice properties. This Python package implements an interpreter for a dialect of Joy that attempts to stay very close to the spirit of Joy but does not precisely match the behaviour of the original version(s) written in C. The main difference between Thun and the originals, other than being written in Python, is that it works by the “Continuation-Passing Style”.

Joy is:

- Purely Functional

- Stack-based

- Concatinative ( See also concatenative.org)

- Categorical

I hope that this package is useful in the sense that it provides an additional joy interpreter (the binary in the archive from La Trobe seems to run just fine on my modern Linux machine!) But I also hope that you can read and understand the Python code and play with the implementation itself.

## Example Code

Here is an example of Joy code:

    [[[abs]ii <=][[<>][pop !-]||]&&][[!-][[++]][[--]]ifte dip][[pop !-][--][++]ifte]ifte

It might seem unreadable but with a little familiarity it becomes just as legible as any other notation. Some layout helps:

    [   [[abs] ii <=]
        [
            [<>] [pop !-] ||
        ] &&
    ]
    [[    !-] [[++]] [[--]] ifte dip]
    [[pop !-]  [--]   [++]  ifte    ]
    ifte

This function accepts two integers on the stack and increments or decrements one of them such that the new pair of numbers is the next coordinate pair in a square spiral (like the kind used to construct an Ulam Spiral). For more information see Square Spiral Example Joy Code

## Quick Start

Install from PyPI in the usual way:

    $ pip install Thun

To start the REPL:

    $ python -m joy

Continue with the introduction.

## Project Hosted on OSDN

- Source Repository (mirror)

- Bug tracker (old tracker)

- Forums

- Mailing list

## Information on the Joy language

See the Wikipedia article and Kevin Albrecht’s mirror of Manfred von Thun’s original website for the Joy Programming Language for more information on the Joy language.

The best source (no pun intended) for learning about Joy is the information made available at the website of La Trobe University (see the mirror link above) which contains source code for the original C interpreter, Joy language source code for various functions, and a great deal of fascinating material mostly written by Von Thun on Joy and its deeper facets as well as how to program in it and several interesting aspects. It’s quite a treasure trove.

## Documentation on Thun Dialect

The following is specific information for this dialect of Joy.

- Thun: Joy in Python
  - Read-Eval-Print Loop (REPL)
  - The Stack
  - Purely Functional Datastructures
  - The `joy()` function
  - Parser
  - Library
- Joy Interpreter
  - `joy.joy`
- Stack or Quote or Sequence or List…
  - `joy.utils.stack`
- Parsing Text into Joy Expressions
  - `joy.parser`
  - Parser Internals
- Tracing Joy Execution
  - `joy.utils.pretty_print`
- Function Reference
  - `joy.library`
  - Auto-generated Functions
- Functions Grouped by, er, Function with Examples
  - Stack Chatter
  - List words
  - Math words
  - Logic and Comparison
  - Miscellaneous
  - Combinators
  - `void`
- Type Inference of Joy Expressions
  - `joy.utils.types`
- Essays about Programming in Joy
  - Developing a Program in Joy
  - Quadratic formula
  - Replacing Functions in the Dictionary
  - Recursion Combinators
  - Treating Trees I: Ordered Binary Trees
  - Treating Trees II: `treestep`
  - Using `x` to Generate Values
  - Newton’s method
  - Square Spiral Example Joy Code
  - Traversing Datastructures with Zippers
  - The Blissful Elegance of Typing Joy
  - Type Checking
  - No Updates
  - Categorical Programming
  - The Four Fundamental Operations of Definite Action
  - ∂RE

# Indices and tables

- Index

- Module Index

- Search Page