Portal 2

From Esolang
Jump to: navigation, search

Portal 2 is a Portal with 2 portals. Portal and Portal 2 loosely implement Wang B-machine

Instructions

Portal 2 has ten instructions:

Command Description
+ Increment the referenced cell
- Decrement the referenced cell
. Output the character signified by the referenced cell
, Input a character and store it in the referenced cell
o If this is the second o portal, jump back to the instruction following the first o portal
[ Move the first o portal to the right
] Move the last o portal to the left
0 If this is the second 0 portal, jump back to the instruction following the first 0 portal
{ Move the last 0 portal to the left
} Move the last 0 portal to the right

Example

This following example prints an O with diaeresis(Ö): O++++++o----}}o]]O. and here is how this code executes, with * marking the current instruction pointer:

 *O++++++o----}}o]]O.
 O*++++++o----}}o]]O.
 O+*+++++o----}}o]]O.
 O++*++++o----}}o]]O.
 O+++*+++o----}}o]]O.
 O++++*++o----}}o]]O.
 O+++++*+o----}}o]]O.
 O++++++*o----}}o]]O.
 O++++++o*----}}o]]O.
 O++++++o-*---}}o]]O.
 O++++++o--*--}}o]]O.
 O++++++o---*-}}o]]O.
 O++++++o----*}}o]]O.
 +O+++++o----}*}o]]O.
 ++O++++o----}}*o]]O.
 ++O++++o*----}}o]]O.
 ++O++++o-*---}}o]]O.
 ++O++++o--*--}}o]]O.
 ++O++++o---*-}}o]]O.
 ++O++++o----*}}o]]O.
 +++O+++o----}*}o]]O.
 ++++O++o----}}*o]]O.
 ++++O++o*----}}o]]O.
 ++++O++o-*---}}o]]O.
 ++++O++o--*--}}o]]O.
 ++++O++o---*-}}o]]O.
 ++++O++o----*}}o]]O.
 +++++O+o----}*}o]]O.
 ++++++Oo----}}*o]]O.
 ++++++Oo*----}}o]]O.
 ++++++Oo-*---}}o]]O.
 ++++++Oo--*--}}o]]O.
 ++++++Oo---*-}}o]]O.
 ++++++Oo----*}}o]]O.
 ++++++oO----}*}o]]O.
 ++++++o-O---}}*o]]O.
 ++++++o-*O---}}o]]O.
 ++++++o-O---}}o]]O*.
 ++++++o-O---}}o]]O.*

Implementation

The only implementation so far is written in Python: https://github.com/greato/portal

See also