Giter Club home page Giter Club logo

simpfunk's Introduction

Simpfunk

Simpfunk is a simple and pretty useless esoteric programming language that prints out strings.

It was implemented in ALGO.

Dependencies

FR-ALGO

The language

Simpfunk has only 3 instructions: +, . and :

It has a 1-bit register and a buffer.

+ flips value in the register.

. appends current register's value to the buffer.

: prints

Example:

A program that prints character A followed by a new line.

Char ASCII Binary (8-bit)
A 65 01000001
\n 10 00001010

Thus:

'A' character
  Instructions: | . | + | . | + | . | . | . | . | . | + | . | : |
Register state: | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
        Buffer: | 0 |   | 1 |   | 0 | 0 | 0 | 0 | 0 |   | 1 | - |

New line character
  Instructions: | + | . | . | . | . | + | . | + | . | + | . | + | . | : |
Register state: | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 0 |
        Buffer: | - | 0 | 0 | 0 | 0 |   | 1 |   | 0 |   | 1 |   | 0 | - |

sf

Executing programs

sf is an interpreter that runs Simpfunk programs.

sf --run my_program.sf

Generating programs

sf can also generate a Simpfunk program out of a given string:

$ sf --gen 'Hello, world!'
Generating...
Generated 156 instructions in 0.13 seconds.
.+.+..+.+....+..+..+.+.+.+.+..+.+..+...+..+.+..+...+..+.+....+..+.+.+..+....+.+......+...+.+...+.+..+.+....+.+...+..+.+..+..+.+..+...+..+..+.+....+.+....+.:
$

To save the program in a file use:

sf --gen 'Hello, world!' > hello.sf

To add a : instruction for each character in the string use -1 option:

sf --gen 'Hello, world!' -1 > hello.sf

To run the program:

$ sf --run hello.sf
Hello, world!
$

Compression/Decompression

sf can compress a program:

$ sf --compress hello.sf
Compressing...
Compressed 44.23% in 0.06 seconds.
0.0+1+1.2.5.4+7.3.5+9+8+8.9.10.14.6+16.17.15.6.11.4.13.20.20+18+16+12.14+30.13+29.33.9:
$

sf uses the LZ78 algorithm.

To save a compressed program, same as above:

$ sf --compress hello.sf > hello.sfx
Compressing...
Compressed 44.23% in 0.06 seconds.
$

Of course, it is possible to directly generate a compressed program like so:

$ sf --gen-c 'Hello, world!' -1
Generating...
Generated 168 instructions in 0.16 seconds.
Compressing...
Compressed 36.90% in 0.29 seconds.
0.0+1+1.2.5.1:3.8.5+8:10.8+4+4:9+16.7.6+9.7+14.12.6:22+4.15.6.23.0:23+20.30+20+25.30.19.37.36+22.23:35.22:

You can also run a compressed program:

$ sf --run hello.sfx
Hello, world!
$

To decompress a program, use:

$ sf --decompress hello.sfx
Decompressing...
100%
Decompressed in 0.06 seconds.
.+.+..+.+...:.+..+..+.+.+.:+.+..+.+..+..:.+..+.+..+..:.+..+.+....:+..+.+.+..+..:..+.+.....:.+...+.+...:+.+..+.+....:+.+...+..+.+.:.+..+.+..+..:.+..+..+.+..:..+.+....+.:
$

simpfunk's People

Contributors

teegre avatar

Watchers

 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.