Skip to content

Commit

Permalink
Use math markup in README
Browse files Browse the repository at this point in the history
  • Loading branch information
urbic committed Dec 20, 2023
1 parent 2e54c20 commit dc57782
Showing 1 changed file with 88 additions and 76 deletions.
164 changes: 88 additions & 76 deletions src/examples/psylla/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# Example Psylla programs

## Hello, world
Prints greeting.
## Ackermann function

* [__`hello.psy`__](hello.psy)
Prints the value of the [Ackermann function
$A(n,m)$](https://en.wikipedia.org/wiki/Ackermann_function). The non-negative
integers $n$ and $m$ are passed in the command line.

* [__`ackermann-recursive.psy`__](ackermann-recursive.psy) — recursive
implementation
* [__`ackermann-iterative.psy`__](ackermann-recursive.psy) — iterative
implementation

## Asterisks

Prints _n_ × _n_ square filled with spaces and asterisks. The non-negative
integer _n_ is passed in the command line.
Prints $n\times n$ square filled with spaces and asterisks. The non-negative
integer $n$ is passed in the command line.

* [__`asterisks-chessboard.psy`__](asterisks-chessboard.psy) — spaces and
asterisks are arranged in the chessboard order
Expand All @@ -17,23 +23,56 @@ integer _n_ is passed in the command line.
* [__`asterisks-solid-square.psy`__](asterisks-solid-square.psy) — the whole
square is filled with asterisks

## Echo

Prints all the command-line arguments separated by spaces and finally line feed
character.

* [__`echo.psy`__](echo.psy)

## Cat

Prints the content of the file. The name of the file is passed in the command
line.

* [__`cat.psy`__](cat.psy)

## Compute $\pi$

Prints the value of $\pi$ calculated using the [Viète’s
formula](https://en.wikipedia.org/wiki/Vi%C3%A8te%27s_formula).

* [__`pi-viete.psy`__](pi-viete.psy)

## Conway’s Game of Life

Shows the evolution of the cellular automata controlled by the rules of
[Conway’s game of life](https://en.wikipedia.org/wiki/Game_of_Life). Runs in
ANSI terminal. Cursor positioning and color selection are made by issuing
escape sequences.

* [__`life.psy`__](life.psy)

## Count lines, words and characters in a file

The name of the file is passed in the command line.

* [__`wc.psy`__](wc.psy)

## Decimal fractions

Prints the decimal periodic representation of the vulgar fraction. The fraction
is passed in the command line in the form $p$`/`$q$.

* [__`fraction-floyd.psy`__](fraction-floyd.psy) — an implementation with the
cycle detection based on the [Floyd’s Tortoise and Hare
algorithm](https://en.wikipedia.org/wiki/Cycle_detection#Floyd.27s_Tortoise_and_Hare)
* [__`fraction-naïve.psy`__](fraction-naïve.psy) — naïve implementation _(very
slow!)_

## Echo

Prints all the command-line arguments separated by spaces and finally line feed
character.

* [__`echo.psy`__](echo.psy)

## Factorial

Prints the _n_!. The non-negative integer _n_ is passed in the command line.
Prints the $n!$. The non-negative integer $n$ is passed in the command line.

* [__`factorial-iterative.psy`__](factorial-iterative.psy) — iterative
implementation
Expand All @@ -42,6 +81,24 @@ Prints the _n_!. The non-negative integer _n_ is passed in the command line.
* [__`factorial-stream.psy`__](factorial-stream.psy) — stream-based
implementation

## Factorization

Print the prime factors of each integer passed in the command line.

* [__`factor-wheel.psy`__](factor-wheel.psy) — [wheel
factorization](https://en.wikipedia.org/wiki/Wheel_factorization)

## Fast power

Prints the $n$ raised to power of $k$ using the [fast exponentiation
algorithm](https://en.wikipedia.org/wiki/Exponentiation_by_squaring).
Non-negative integer $n$ and $k$ are passed in the command line.

* [__`power-fast-iterative.psy`__](power-fast-iterative.psy) — iterative
implementation
* [__`power-fast-recursive.psy`__](power-fast-recursive.psy) — recursive
implementation

## Fences balance

Checks if the standard input contains mutually balanced fences of three kinds
Expand All @@ -51,7 +108,7 @@ Checks if the standard input contains mutually balanced fences of three kinds

## Fibonacci numbers

Prints the first _n_ Fibonacci numbers. The non-negative integer _n_ is passed
Prints the first $n$ Fibonacci numbers. The non-negative integer $n$ is passed
in the command line.

* [__`fibonacci-binet.psy`__](fibonacci-binet.psy) — calculation using [Binet’s
Expand All @@ -70,32 +127,13 @@ in the command line.
* [__`fibonacci-matrix.psy`__](fibonacci-matrix.psy) — implementation based on
fast matrix exponentiation

## Tower of Hanoi

Solves the [Tower of Hanoi](https://en.wikipedia.org/wiki/Tower_of_Hanoi)
problem for _n_ discs. The non-negative integer _n_ is passed in the command
line.

* [__`hanoi-recursive.psy`__](hanoi-recursive.psy) — recursive implementation

## Find files

List files in a directory hierarchy. Files or directories are specified in the
command line. The current directory is assumed by default.

* [__`find.psy`__](find.psy)

## Decimal fractions

Prints the decimal periodic representation of the vulgar fraction. The fraction
is passed in the command line in the form _p_`/`_q_.

* [__`fraction-floyd.psy`__](fraction-floyd.psy) — an implementation with the
cycle detection based on the [Floyd’s Tortoise and Hare
algorithm](https://en.wikipedia.org/wiki/Cycle_detection#Floyd.27s_Tortoise_and_Hare)
* [__`fraction-naïve.psy`__](fraction-naïve.psy) — naïve implementation _(very
slow!)_

## Greatest common divisor

Prints the GCD calculated using [Euclid’s
Expand All @@ -110,58 +148,29 @@ passed in the command line.
* [__`head.psy`__](head.psy)
* [__`tail.psy`__](tail.psy)

## Conway’s Game of Life

Shows the evolution of the cellular automata controlled by the rules of
[Conway’s game of life](https://en.wikipedia.org/wiki/Game_of_Life). Runs in
ANSI terminal. Cursor positioning and color selection are made by issuing
escape sequences.
## Hello, world
Prints greeting.

* [__`life.psy`__](life.psy)
* [__`hello.psy`__](hello.psy)

## Pascal triangle

Prints the first _n_ rows of the Pascal triangle. Non-negative integer _n_ is
Prints the first $n$ rows of the Pascal triangle. Non-negative integer $n$ is
passed in the command line.

* [__`pascal-triangle.psy`__](pascal-triangle.psy)

## Permutations

Prints all the permutations of the numbers 1 thru _`n`_. Non-negative integer
_n_ is passed in the command line.
Prints all the permutations of the numbers 1 thru $n$. Non-negative integer $n$
is passed in the command line.

* [__`permutations-lexicographical.psy`__](permutations-lexicographical.psy) —
iterative implementation, generates permutations in lexicographical order
* [__`permutations-recursive.psy`__](permutations-recursive.psy) — recursive
implementation
* [__`permutations-shuffling.psy`__](permutations-shuffling.psy)

## Compute _π_

Prints the value of _π_ calculated using the [Viète’s
formula](https://en.wikipedia.org/wiki/Vi%C3%A8te%27s_formula).

* [__`pi-viete.psy`__](pi-viete.psy)

## Fast power

Prints the _n_ raised to power of _k_ using the [fast exponentiation
algorithm](https://en.wikipedia.org/wiki/Exponentiation_by_squaring).
Non-negative integer _n_ and _k_ are passed in the command line.

* [__`power-fast-iterative.psy`__](power-fast-iterative.psy) — iterative
implementation
* [__`power-fast-recursive.psy`__](power-fast-recursive.psy) — recursive
implementation

## Factorization

Print the prime factors of each integer passed in the command line.

* [__`factor-wheel.psy`__](factor-wheel.psy) — [wheel
factorization](https://en.wikipedia.org/wiki/Wheel_factorization)

## Pollard-Brent factorization

Print facor of an integer passed in the command line.
Expand All @@ -171,8 +180,8 @@ Print facor of an integer passed in the command line.

## Prime numbers

Prints the first prime numbers that do not exceed a given _n_. Non-negative
integer _n_ is passed in the command line.
Prints the first prime numbers that do not exceed a given $n$. Non-negative
integer $n$ is passed in the command line.

* [__`primes-array-optimized.psy`__](primes-array-optimized.psy)
* [__`primes-bitset-optimized.psy`__](primes-bitset-optimized.psy)
Expand All @@ -195,10 +204,10 @@ integer _n_ is passed in the command line.

## Russian multiplication

Prints the product of _m_ and _n_ calculated using the [Russian peasant
Prints the product of $m$ and $n$ calculated using the [Russian peasant
multiplication
algorithm](https://en.wikipedia.org/wiki/Ancient_Egyptian_multiplication#Russian_peasant_multiplication).
Non-negative integer _m_ and _n_ are passed in the command line.
Non-negative integer $m$ and $n$ are passed in the command line.

* [__`russianmul.psy`__](russianmul.psy)

Expand All @@ -220,7 +229,7 @@ Prints the lines from the given file sorted according certain criterion.

## Square root

Prints the square root of _x_. Non-negative _x_ is passed in the command line.
Prints the square root of $x$. Non-negative $x$ is passed in the command line.

* [__`sqrt-bisection-floyd.psy`__](sqrt-bisection-floyd.psy) — bisection method
with cycle detection using Floyd’s algorithm
Expand All @@ -229,8 +238,11 @@ Prints the square root of _x_. Non-negative _x_ is passed in the command line.
* [__`sqrt-hero-recursive.psy`__](sqrt-hero-recursive.psy) — recursive
implementation of the Newton’s method

## Count lines, words and characters in a file
## Tower of Hanoi

The name of the file is passed in the command line.
Solves the [Tower of Hanoi](https://en.wikipedia.org/wiki/Tower_of_Hanoi)
problem for $n$ discs. The non-negative integer $n$ is passed in the command
line.

* [__`hanoi-recursive.psy`__](hanoi-recursive.psy) — recursive implementation

* [__`wc.psy`__](wc.psy)

0 comments on commit dc57782

Please sign in to comment.