").text(e.label)).appendTo(t)},_move:function(t,e){if(this.menu.element.is(":visible"))return this.menu.isFirstItem()&&/^previous/.test(t)||this.menu.isLastItem()&&/^next/.test(t)?(this.isMultiLine||this._value(this.term),void this.menu.blur()):void this.menu[t](e);this.search(null,e)},widget:function(){return this.menu.element},_value:function(){return this.valueMethod.apply(this.element,arguments)},_keyEvent:function(t,e){this.isMultiLine&&!this.menu.element.is(":visible")||(this._move(t,e),e.preventDefault())},_isContentEditable:function(t){if(!t.length)return!1;var e=t.prop("contentEditable");return"inherit"===e?this._isContentEditable(t.parent()):"true"===e}}),x.extend(x.ui.autocomplete,{escapeRegex:function(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")},filter:function(t,e){var i=new RegExp(x.ui.autocomplete.escapeRegex(e),"i");return x.grep(t,function(t){return i.test(t.label||t.value||t)})}}),x.widget("ui.autocomplete",x.ui.autocomplete,{options:{messages:{noResults:"No search results.",results:function(t){return t+(1").text(e))},100))}});x.ui.autocomplete});
\ No newline at end of file
diff --git a/apidocs/serialized-form.html b/apidocs/serialized-form.html
index 2bce1b560..d5774ffa9 100644
--- a/apidocs/serialized-form.html
+++ b/apidocs/serialized-form.html
@@ -1,11 +1,11 @@
-
+
Serialized Form (Psylla 0.21.1)
-
+
diff --git a/examples/psylla/README.md b/examples/psylla/README.md
index 8decca9cf..dd2e4a4bc 100644
--- a/examples/psylla/README.md
+++ b/examples/psylla/README.md
@@ -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
@@ -17,13 +23,6 @@ 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
@@ -31,9 +30,49 @@ 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
@@ -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
@@ -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
@@ -70,14 +127,6 @@ 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
@@ -85,17 +134,6 @@ 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
@@ -110,26 +148,22 @@ 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
@@ -137,31 +171,6 @@ _n_ is passed in the command line.
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.
@@ -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)
@@ -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)
@@ -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
@@ -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)
diff --git a/examples/psylla/ackermann-iterative.psy b/examples/psylla/ackermann-iterative.psy
new file mode 100644
index 000000000..a99217895
--- /dev/null
+++ b/examples/psylla/ackermann-iterative.psy
@@ -0,0 +1,31 @@
+#!/usr/bin/psylla
+
+/ackermann
+{
+ mark 3 1 roll
+
+ {
+ counttomark 1 eq { exch pop exit } if
+
+ 1 index iszero
+ { exch pop 1 add }
+ {
+ dup iszero
+ { pop 1 sub 1 }
+ {
+ 1 sub
+ 1 index
+ 1 sub
+ 3 1 roll
+ }
+ ifelse
+ }
+ ifelse
+ }
+ loop
+}
+bind def
+
+arguments 0 get tointegral
+arguments 1 get tointegral
+ackermann toname say
diff --git a/examples/psylla/ackermann-recursive.psy b/examples/psylla/ackermann-recursive.psy
new file mode 100644
index 000000000..d4a267897
--- /dev/null
+++ b/examples/psylla/ackermann-recursive.psy
@@ -0,0 +1,23 @@
+#!/usr/bin/psylla
+
+/ackermann
+{
+ {
+ 1 index iszero
+ { 1 add exch pop exit } if
+
+ dup iszero
+ { pop 1 sub 1 ackermann exit } if
+
+ 1 sub 1 index 1 sub
+ 3 1 roll
+ ackermann ackermann
+ exit
+ }
+ loop
+}
+bind def
+
+arguments 0 get tointegral
+arguments 1 get tointegral
+ackermann toname say
diff --git a/examples/psylla/pollard-brent.psy b/examples/psylla/pollard-brent.psy
index 29c1f4fce..743cee871 100644
--- a/examples/psylla/pollard-brent.psy
+++ b/examples/psylla/pollard-brent.psy
@@ -13,7 +13,7 @@
{
n x y sub abs gcd dup 1 ne
- { exit } #{ dup n ne { exit } if }
+ { exit }
{ pop }
ifelse
i stage eq
@@ -22,7 +22,6 @@
/stage stage 2 mul def
}
if
- #x ? '>>>' ?
/x x dup mul 1 add n mod def
/i i 1 add def
}