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-16 4:12

>>77
I don't know how it works, but it works. That must have been a pain in the ass to write.

>>79
http://esolangs.org/wiki/Tubes

Name: Anonymous 2010-06-16 13:06

I'm not >>1, but...

ENTRIES SO FAR

Finished
>>20    Artificial Language, interpreted: fibs, fact, wild card
>>36,77 Codan, compiled: fibs, fact, Eratosthenes, wild card
>>59    Stack.pl interpreted fibs, fact, wild card

Work in progress
>>22,42 Turd, interpreted: fibs, fact, Eratosthenes Needs: wild card program
>>45    Jeme (nameless), interpreted: none Needs: programs
>>64    FRNPL, ?
>>80    Uzumaki (nameless), ?

(I hope I didn't miss anyone; I erred on the side of taking joke entries seriously.)

Name: Anonymous 2010-06-16 13:16

Hi, Turd author here. Been busy with actual work coding - A rather exciting windows Credential Provider that sucks you off and anaylzes your semen to authenticate you. Actually I made that bit up. But some exciting new features are being added to turd and I plan to implement some more programs from the list and a wild card

Name: Anonymous 2010-06-16 14:03

>>82
You forgot to note that Codan was designed by Xarn.

Name: Anonymous 2010-06-16 15:14

>>84
Obvious but irrelevant.

Name: Anonymous 2010-06-16 16:25

>>83
Port this to PAM, please.

Name: Anonymous 2010-06-16 18:17

I write it in Æ: http://dis.4chan.org/read/prog/1198205066

Factorial calculator:

!fact = %return $1 * !fact ($1-1)
%while ($line = !fgets)
    %print !fact $line

Fibs:

!fibs = (1,1) ++ (!zipWith f_+, !fibs, !tail !fibs)

fgrep:

%while ($line = !fgets)
    %if (!match $line, $1) %print $line


Wildcard program and interpreter: (Hey, it said I could write it in any language I wanted to!)

%eval !getContents

Name: Anonymous 2010-06-16 21:13

>>87
Great, now provide an actual implementation of your language.

Name: Anonymous 2010-06-16 21:59

>>88
He did, can't you read?

Name: Anonymous 2010-06-17 1:51

>>80
Whilst thinking about it further, I'm changing it slightly, so you can write it in any direction you want(as long as it fits the down right up left(and is surrounded by whitespace).

So you can write it like this:

n   
=                     .
_                     n
c                     }
=                     1
0i=1t=0n*{t           -
          =           n
          0t+it+ci=cc=t

Or in any darn order really, trying to work in a way. Also adding in so you can reuse operators and variables by crossing over paths. There's only five operators, = + - _ ., or equals, add, subtract, get input, output variable. Only support for integers, no strings or arrays. I have exams next week, I'll try to finish it, but at the moment, all there is is a simple interpreter for the base language.

Name: Anonymous 2010-06-17 1:55

>>90
Oh, and there's also the control operator *, which works like brainfuck's [ symbol with the preceding variable, on the next set of curly brackets.

Sage because I've already bumped it.

Name: Anonymous 2010-06-17 10:17

Bump. We need more languages. ah fuck, I'm going to create new one.

Name: Anonymous 2010-06-17 12:00

I'll get to creating my language tomorrow, after my exams.
Though I'm worried that it'll end up as a shitty clone of Haskell :\

Name: Anonymous 2010-06-17 12:25

>>93
put shit in, get shit out

Name: Anonymous 2010-06-17 12:56

A+ work

Name: Anonymous 2010-06-17 13:11

>>93
Yeah, I too need to finish some projects for university. If only I had more time.

Name: Anonymous 2010-06-17 13:26

I thought a little about a language that doesn't have branches, but allows you to copy around and modify code instead . . .

Name: Anonymous 2010-06-17 14:41

Name: Anonymous 2010-06-17 14:56

>>96
I said exams. Not studying in a university yet.

Name: Anonymous 2010-06-17 15:14

100 GET

Name: Anonymous 2010-06-17 15:25

>>98
Too bad it's not Touring complete.

Name: Anonymous 2010-06-17 15:26

>>101
Anal ram 3500

Name: Anonymous 2010-06-17 15:28

>>102
ANAL RAM MY ANUS

Name: Anonymous 2010-06-17 20:30

>>99
Get of my lawn kid

Name: Anonymous 2010-06-18 1:43

>>59 here, with a new implementation of the same language (with a few more words added)...
from __future__ import print_function
import re

def eval_stack(code, stack):
    words = code.split()
    int_re = re.compile('^\d+$')
    float_re = re.compile('^\d*\.\d+$')
    while len(stack) > 0:
        output = []
        for word in words:
            if int_re.match(word):
                stack = stack + [int(word)]
            elif float_re.match(word):
                stack = stack + [float(word)]
            else:
                output, stack = { '%': lambda s: (output, s[:-2] + [s[-2] % s[-1]]),
                                  '*': lambda s: (output, s[:-2] + [s[-2] * s[-1]]),
                                  '+': lambda s: (output, s[:-2] + [s[-2] + s[-1]]),
                                  '-': lambda s: (output, s[:-2] + [s[-2] - s[-1]]),
                                  '/': lambda s: (output, s[:-2] + [s[-2] / s[-1]]),
                                  '^': lambda s: (output, s[:-2] + [s[-2] ** s[-1]]),
                                  '.': lambda s: (output + [s[-1]], s[:-1]),
                                  'ndrop': lambda s: (output, s[:-(s[-1]+1)]),
                                  # drop = 1 ndrop
                                  'drop': lambda s: (output, s[:-1]),
                                  'ndup': lambda s: (output, s[:-1] + s[-(s[-1]+1):-1]),
                                  # dup = 1 ndup
                                  'dup': lambda s: (output, s + [s[-1]]),
                                  'npick': lambda s: (output, s[:-1] + [s[-(s[-1]+1)]]),
                                  # over = 2 npick
                                  'over': lambda s: (output, s + [s[-2]]),
                                  'nrot': lambda s: (output, s[:-(s[-1]+2)] + s[-(s[-1]+1):-1] + [s[-(s[-1]+2)]]),
                                  # swap = 1 nrot
                                  'swap': lambda s: (output, s[:-2] + s[:-3:-1]),
                                  # rot = 2 nrot
                                  'rot':  lambda s: (output, s[:-3] + s[-2:] + [s[-3]]) }[word](stack)
        yield output

def print_stack(code, stack):
    [[print(j) for j in i] for i in eval_stack(code, stack)]

Name: Anonymous 2010-06-18 16:14

Bampu let's not lose this thread.

Deadline in 56 hours and 46 minutes.

Name: Anonymous 2010-06-18 16:14

>>106
Right, because threads expire on dis. IHBT

Name: Anonymous 2010-06-18 16:15

>>106
Dammit, off by an hour. Time zones are hard.

Name: Anonymous 2010-06-18 16:16

>>107
You're a moron, kid.

Name: Anonymous 2010-06-18 16:16

>>107
They dont expire. They just get forgotten.

Name: Anonymous 2010-06-18 17:16

>>106
Deadline in 56 hours and 46 minutes.
I think that I won't be able to finish in time D:

Name: Anonymous 2010-06-18 17:22

I'm writing a programming language called Anuslandia.

Name: Anonymous 2010-06-18 18:42

>>112

Sounds like fun

Name: Anonymous 2010-06-18 21:14

>>111
Sure you can! I just started today, and I have a nice chunk of code working already. I might be able to get JIT compilation working before the deadline.

Though I'm working backwards, so I don't have the parser written yet.

Name: Anonymous 2010-06-18 22:00

>>114
Implement a prototype parser/compiler in another language, re-implement the parser/compiler in the language itself, then enjoy the pleasure of being boostrapped inside.

Name: Anonymous 2010-06-19 3:40

>>115
Or implement a hacky "throw-away" interpreter in one language, then write the actual compiler (and maybe a new interpreter) in the language you were designing. Less time spent.

Name: Anonymous 2010-06-19 10:28

>>116
isn't that bastically what >>115 said?

Name: Anonymous 2010-06-19 18:25

Deadline in 29 hours and 35 minutes.

Name: Anonymous 2010-06-19 18:32

>>118
Dead
U MENA HASKAL

Name: Anonymous 2010-06-19 18:54

>>116
Or just write a compiler/interpreter in whatever language, then write the compiler/interpreter for your designed language in your designed language and do it that way. Less time spent.

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