Coder Social home page Coder Social logo

josephoziel / legend Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joes-esolangs/legend

0.0 0.0 0.0 17 KB

An esolang based on legendre symbols.

Home Page: https://esolangs.org/wiki/Legend

License: MIT License

Python 82.18% Prolog 17.82%

legend's Introduction

An esolang based on legendre symbols. This language is heavily based off of Kak.

Example

The file hello_world.leg contains a possibile hello world in Legend.

(Image to show the program with text wrapping) image

When compiled it produces a binary string:

$ legend.exe hello_world.leg
010010000110010101101100011011000110111100101100001000000101011101101111011100100110110001100100001000010

SIDE NOTE: The program hello_gen.py was used this generate this program randomly. It was not written by hand.

If you split this binary string into octals, it forms the ASCII text Hello, World!.

Proof:

image

Spec

Lexer

The lexer only accepts the following characters: (, /, ), 0-9.

No other characters such as whitespace or alphabetic letters are allowed.

Semantics

A Legend program consists of n legendre symbols of the form (a/p) where a is some positive number and p is an odd prime.

RULE: every legenrdre symbol must be different or else it will fail.

Each legendre symbol evaluates to 0, 1 or -1. Each value corresponds to some instructions:

Value Instruction
-1 Move the pointer to the right and flip the bit at the new location
1 Move the pointer to the left if the pointer index is greater than one (1)
0 Skip the next instruction if the current cell's bit is zero (0)

Thus, every program structure has infinitely many implementations.

In addition, once the interpreter reaches the last legendre symbol, it tests whether the current cell is 0. If it is, it stops execution, and if not, it executes the instructions again. (It also prints the current tape at the end of each iteration).

Use

The interpreter lies in i.pl (it's golfed by the way).

To run a program: legend.exe program.leg

Windows

Go into the directory and run this command: swipl -o legend.exe -c i.pl --goal=main. Now you will have a legend.exe which you can use like this: legend.exe program.leg.

legend's People

Contributors

crabbo-rave avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.