Home

Awesome

RASEL (Random Access Stack Esoteric Language) v2

A programming language inspired by Befunge where instead of the program space random access you have the ability to swap with the Nth value in the stack.

This repository includes specification, examples, executables and library, its tests running as GitHub Action. There is also an IDE -- read more about it in the Esolang Wiki RASEL language article.

Usage

Install

gem install rasel

Run

To run a program you can either use the executable and pass a source file as argument:

$ echo '"olleh",,,,,A,@' > temp.rasel
$ rasel temp.rasel

Or pipe the source code directly:

$ echo '"olleh",,,,,A,@' | rasel

Or pass it as a String arg in Ruby runtime:

require "rasel"
puts RASEL('"olleh",,,,,@').stdout.string

To run a program and feed it some stdin you can either put it to a file:

$ rasel my_program.rasel < my_input.txt

Or pipe it too:

$ echo 5 | rasel examples/factorial.rasel
$ echo 5 | rasel examples/fibonacci.rasel

Reference specification

Not all but the main differences from Befunge-93/98

Examples (more here)

Factorial(n) (OEIS A000142)

1&\:?v:1-3\-/
1\/.@>-1

Fibonacci(n) (OEIS A000045)

1&-:?v1\:3\01\--1\
2\.@ >

Project Euler's Problem 1 "Multiples of 3 and 5"

&>:?v1-::3%1\5%/ ?v
 ^  >--.@j5\1--\3:<

Note that in the examples folder the PE solutions might assume the \n-terminated input, not the chomped one like AoC website gives it to you.

Prime numbers generator (OEIS A000040) (trial division by a growing list)

2:4v     >-       2-\:--:.>01--#
   >::\:?^:3\1\%?v2-\1\:2\ 01--
                 >2-\:--  v
$ rasel examples/prime.rasel
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 ... ^C

Advent of Code 2020 1 1 solution

Befunge-93 (by @fis):

1+:#v&\fp
   0>$1-:00p>:#v_00g
               >:fg00gfg+'-:*5--#v_fg00gfg*.@
            ^                  -1<

RASEL:

&v
 >2v         >///-
   >01--::\:?^:0:5\:6\---K/"e"-:/?v1\1-\
                                  >1:4\//.A,@

Here you can see that it's about the same size.

IDE and other executables

The "RASEL IDE" is for editing the .rasela "annotated" code. It is fully explained in the Esolang Wiki article.

Specification version history

Note that the gem version number isn't supposed to match the specification version number.

TODO

Development notes

TODO: add a tutorial how to debug with rasel-annotated