OW-1
OW-1 is a two-dimensional programming language invented on 12 June 2022 by User:Potato Imaginator. It is inspired from Befunge and Assembly_language. OW abbreviates for "Old Woman".
Description
This is a Case Sensitive Language and works well with American Keyboard Layout.
Inputs are given as either numbers 0-9 , specific alphabets or special commands.
It has two cells A and B and a Buffer called C.
All three cells can only store numbers ( Positive , Negative , Decimal ) .
Operations Performed on A and B are stored in C.
There is a Pointer that is either at Position A or Position B. The Pointer is moved by calling " . " Command.
Current Pointer Position has Light Blue Background.
Commands
Hitting ' z ' key will Pause / Play the Program.
Press ' r ' to Reset.
Press ' o ' to Enable / Disable Output Display.
In edit mode , Press Arrow keys to move position and enter below commands.
Press " Delete " or " Backspace " Key to delete command at a position.
Command | Description |
---|---|
^ |
Changes Direction to Up. |
v |
Changes Direction to Down. |
< |
Changes Direction to Left. |
> |
Changes Direction to Right. |
. |
Changes Current Pointer Position. Switches between A and B |
? |
Changes Direction to Random Direction. ( Up / Down / Left / Right ) |
+ |
Stores A + B into C. |
- |
Stores A - B into C. |
* |
Stores A * B into C. |
/ |
Stores A / B into C. |
e |
Power Function : Stores A ^ B into C. |
% |
Modulo Function: Stores A % B into C. |
S |
Swaps value between Current Pointer and C. |
s |
Swaps A and B values. |
c |
Copies Current Pointer Value into C. |
p |
Pastes C Value into Current Pointer Variable. |
i |
Increment Current Pointer Value by 1. |
d |
Decrement Current Pointer Value by 1. |
# |
Prints C value to Output Display. |
x |
End Program. |
T |
If C = 0 then move in same Direction , else Rotate Direction by 90 ( Clockwise ). |
0-9 |
Assign value of 0-9 to Current Pointer. |
Examples
Sum of Natural Numbers
>i.p+#.v ^ <
Factorial
6.1>*p.dSTS#x S . ^ <
Change starting value of 6 to any number to get it's Factorial.
Fibonacci_sequence
1c.1c#.#>p+.#v ^ <
Another one:
1c>#+.pv ^ <
Prime_numbers_generator
2c#i.2>%T.i.v i - ^ T 2 c # . i . ^ < <
Factors of a Number
1c#6.8*2.p.>%TS#S-Tx i i ^ < <
Above prints Factors of 48
Square Root
>5.p+.p.5d-p/.p#v ^ <
Change all values of 5 to any number to get it's Square Root.
Another one is:
1c>p.p*pi/p.7i*#v ^ <
Change all values of 7 to any number to get it's Square Root.
Random_number_generator
v >+v . 1 . > >?<>p.2/.p.9i*.p.9i*.v 0 . p >+^ . 1 ^ .p./i9.p./i9.#p.-p%<
Absolute Difference of Two Numbers
5.8.>c T.c#x d . c ^.dT . i c # x
Here A = 5 and B = 8
Prints Absolute Difference of A and B .i.e; | A - B |
Minimum of Two Numbers
9.6.>d.dSiS.STS#x S . S ^ ST S # x
Maximum of Two Numbers
7.4.>d.dSiS.STSp+#x S . S ^ ST S p + # x
Mathematical Constants
Golden Ratio
1.1>/p.1+.p#v ^ <
Golden Ratio φ = 1.618033988749....
Computational class
OW-1 can be proven Turing Complete by compiling Minsky Swap to it.
inc(): <i
swap(): <.
decnz(n):
>cTv>d > ^
Put a >
or <
below the v
and a ^
at the destination >
.
Make sure no jump paths collide.
At the end add an >x
to halt the program.
Here's an example:
The Minsky Swap code ++*~(0)+
or inc();inc();swap();decnz(0);inc();
turns into
>i>i>.>cTv>d>i>x > ^ ^ <
Which ends with both registers at 2, the expected result.