Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

★ /prog/ Challenge Vol. 5 ★

Name: Anonymous 2010-06-11 23:51

The challenge suggestion thread was too busy going nowhere, and I feel like writing some code, so here is a /prog/ challenge.

THE CHALLENGE:
Design a toy programming language. You may implement either a compiler or interpreter, and you may write the implementation in any language of your choosing.

Post the source code to your implementation as well as programs in your language to accomplish at least two of the following tasks, plus one ``wild card'' program not listed here.

    • Factorial calculator
    • Fibonacci sequence generator
    • Prime number sieve (e.g. Eratosthenes, Atkin, etc.)
    • fgrep (output lines of input containing a given string)
    • Caesar cipher
    • Simple interactive calculator
    • Tic-tac-toe (AI not required)
    • The game of Nim (http://en.wikipedia.org/wiki/Nim)

Entries must be submitted prior to 2010-06-21 00:00, which gives one full week and two weekends. Judgment will be in three categories: presentation and cleverness of designed language, clarity of implementation, and overall usefulness/entertainment/trolling value of the ``wild card'' program.

Winner will receive ten Susscoins, to be transferred via /prog/mail.

Name: Anonymous 2010-06-12 23:31

I've devised an esolang specifically designed to annoy people who can't figure out how to input Unicode. It's my first esolang, so nothing terribly adventurous. I've named it Codan.

It's pretty straightforward: there's an unspecified number of memory cells, each containing a (signed) integer (initialised to 0). Furthermore, there are three registers: Α, Β, and Λ. (Note that Α and Β are uppercase alpha and beta, not the Latin A and B.)
Α and Β just refer to memory cells (the contents of which can be easily accessed through special variables α and β, respectively), but Λ is a special I/O register: trying to fetch its contents will prompt the user for input (in the form of a number), trying to store a number in it will output that number to the screen.

Assigning to cells works like this:

Α ← 0
Β ← 1
10 → α
β ← α
β → Λ

(All whitespace is optional.)
This has Α refer to memory[0], Β to memory[1], then sets the value at memory[0] to 10, the value at memory[1] to the value at memory[0], and finally outputs the value at memory[1], being 10. x → y is completely equivalent to y ← x.
You can also just go 10 ← 1 (which assigns 1 directly to memory location 10) or 2 → Λ (which outputs 2 directly), if you like.

Next there are expressions, which are of the form function → target (or the other way around, of course). The functions are +, −, ×, ÷, and ↑, for addition, subtraction, multiplication, division, and exponentiation, respectively.
The functions operate on the values pointed to by Α and Β.

Α ← 0
Β ← 1
2 → 0
3 → 1
× → Λ

This would output 6.

Finally, there's the loop, which uses « to open and » to close.
By itself it just runs forever, so you can put assertions inside, which are of the form left-operand comparison-operator right-operand.
The operands can be anything you'd expect. The operator is one of =, ≠, <, ≤, >, ≥, ≮, ≯, ≰, or ≱, which should be self-explanatory. When the assertion is false, the innermost loop execution is currently in will be escaped from.

Α ← 0
Β ← Α
α ← 1
«
α < 10
+ → α
»
α → Λ

This will output 16.

Here's the factorial calculator:

1 ← Λ
1 → 2
1 → 3
Α ← 1
Β ← 2
«
α ≰ 0
× → 2
Β ← 3
− → α
Β ← 2
»
β → Λ


And the Fibonacci sequence generator (as far as signed ints will go):

Α ← 1
Β ← 2
α ← 0
β ← 1
«
α ≮ 0
α → Λ
+ → 3
α ← β
Α ← 3
β ← α
Α ← 1
»


And finally, the prime number sieve (up to 1000, but in principle it's only limited by the size of the memory):

Α ← 2
Β ← 2
«
    Α ≤ 1000
    «
        α = 0
        Α → Λ
        α ← Α
        Β ← Α
        «
            0 ← Β
            0 → Β
            + → Β
            Β ≤ 1000
            1 → β
        »
        0 = 1
    »
    α ← Α
    0 → Β
    1 → 0
    + → Α
»


The ``compiler'' I wrote for Codan is a Python script that outputs C and then calls gcc. Because this post is long enough as it is, I've put it on Sprunge:

http://sprunge.us/eOhB?py

Name: 36 2010-06-16 1:08

It just occurred to me that I didn't write a wild card program. Here's a fancy one.
I wish I'd remembered to include a modulo operation.

3 → Λ
0 ← 4000
381 ← 1000
«
    Α ← 0
    Β ← 382
    β ← 1
    − → α
    α ≠ 0
    380 ← 0
    379 ← 0
    Α ← 2
    Β ← 382
    β ← 2
    + → α
    Α ← 0
    382 ← 2
    383 ← 1
    Β ← 382
    × → β
    Α ← 383
    + → 1
    Α ← 380
    «
        α < 337
        Β ← 382
        β ← 2
        Α ← 380
        + → Β
        Α ← 0
        × → 382
        Α ← 379
        Β ← 1
        ÷ → 383
        Α ← 383
        × → 383
        Β ← 383
        Α ← 379
        − → 383
        Α ← 381
        × → β
        Α ← 382
        + → 379
        Α ← 379
        Β ← 1
        ÷ → 382
        383 ← 2
        Α ← 380
        Β ← 383
        + → Β
        Α ← 382
        β ← α
        α ← 1
        Β ← 380
        + → β
        Α ← 380
        Β ← 382
        β ← 2
        − → β
        383 ← 2
        Α ← 383
        + → Β
        383 ← β
        384 ← β
        Β ← 381
        ÷ → 383
        × → 383
        Α ← 384
        Β ← 383
        − → 382
        Α ← 379
        Β ← 1
        ÷ → 383
        Α ← 383
        Β ← 381
        ÷ → 383
        Β ← 382
        + → 382
        «
            Α ← 380
            α > 2
            Β ← 0
            β = 1
            Α ← 382
            Β ← 383
            β ← 100
            ÷ → Λ
            384 ← α
            ÷ → α
            × → α
            Α ← 384
            Β ← 382
            − → 382
            Β ← 383
            Α ← 382
            β ← 10
            ÷ → Λ
            384 ← α
            ÷ → α
            × → α
            Α ← 384
            Β ← 382
            − → Λ
            1 = 0
        »
        Α ← 380
    »
»

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List