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

ITT the ABC Programming Language

Name: Anonymous 2008-07-29 19:29

#include <stdio.h>

int main(int argc,char argv*[]){
  int i = 0;
  int BUFFA;

  while(argv[i]!='\0'){
    if(argv[i]='a')
      BUFFA++;
    else if(argv[i]='b')
      BUFFA--;
    else if(argv[i]='c')
      printf("%i\n",BUFFA);
    else printf("%s","Error.\n");
  }
}

Name: Anonymous 2008-07-31 15:32

>>38
Yes, you fail at equality versus assignment and you don't know how to increment a loop variable, but those are the least of your problems.

Name: Anonymous 2008-07-31 15:56

>>41
I am never telling you jokes again.

Name: Anonymous 2008-07-31 16:29

>>42
There was no joke.
You are a joke.

Name: Anonymous 2008-07-31 18:27

>>43
You are a yoke.

Name: 2008-07-31 20:17

Name: Anonymous 2008-08-01 9:56


#include "stdafx.h"
#include "stdio.h"
#include "iostream"
#include <string>

int _tmain(int argc, _TCHAR* argv[])
{
    int i = 0;
    int buffer = 0;

    std::string input ="";

    std::cout << "Please enter ABC String: ";
    std::cin >> input;
    std::string::iterator theIterator;
    theIterator = input.begin();
    while(theIterator != input.end()){
        if(*theIterator == 'a')
            buffer++;
        else if(*theIterator == 'b')
            buffer--;
        else if(*theIterator == 'c')
            printf("%i\n",buffer);
        else printf("%s","Error.\n");
            theIterator++;
    }
    return 0;
}

Name: Anonymous 2008-08-01 9:57

>>46
Ups. int i = 0; not needed. Copy&Paste error.

Name: Anonymous 2008-08-01 10:13


#include "stdafx.h"
#include "iostream"
#include <string>

int _tmain(int argc, _TCHAR* argv[])
{
    int buffer = 0;

    std::string input ="";

    std::cout << "Please enter ABC String: ";
    std::cin >> input;
    std::string::iterator theIterator;
    theIterator = input.begin();
    while(theIterator != input.end()){
        if(*theIterator == 'a')
            buffer++;
        else if(*theIterator == 'b')
            buffer--;
        else if(*theIterator == 'c')
            std::cout << buffer << std::endl;
        else std::cout << "Error.\n";
            theIterator++;
    }
    return 0;
}


Fixed.

Name: Anonymous 2008-08-01 10:14

>>46 has successfully upgraded >>1 to C++.

Name: Anonymous 2008-08-01 10:48

&:!vv-1:_$>\:v       
@.1_>:  ^ ^ *_$.@

Name: Anonymous 2008-08-01 11:22

>>50
0&:!v>:1-:v v*\_$.@
@.1 _^    _$>\:^

Name: Anonymous 2008-08-01 11:27

>>51
Why did you post a longer version? That makes no sense.

Name: Anonymous 2008-08-01 11:36

ABC has nine commands, people, not three.

public class ABCInterpreter {
    public static void main (String[] args) {
        for (int i = 0; i < args.length; i++) {
            boolean ascii = false;
            int BUFFA = 0;

            for (int j = 0; j < args[i].length(); j++) {
                switch (args[i].charAt(j)) {
                    case 'a':
                        BUFFA++;
                        break;
                    case 'b':
                        BUFFA--;
                        break;
                    case 'c':
                        System.out.print(ascii ? (char) BUFFA
                                               : BUFFA);
                        break;
                    case 'd':
                        System.err.println("I have no idea what 'invert' means");
                        break;
                    case 'r':
                        BUFFA = new java.util.Random().nextInt(BUFFA);
                        break;
                    case 'n':
                        BUFFA = 0;
                        break;
                    case '$':
                        ascii = !ascii;
                        break;
                    case 'l':
                        i = 0;
                        break;
                    case ';':
                        System.out.println("\n" + (char) BUFFA
                                           + " " + BUFFA);
                        break;
                    default:
                        System.err.println("Unknown command: " +
                                           args[i].charAt(j));
                }
            }
        }
        System.out.println("");
    }
}

Name: Anonymous 2008-08-01 11:57

>>53
System.err.println("I have no idea what 'invert' means");

BUFFA *= -1;

Name: Anonymous 2008-08-01 12:08

>>53

GOD
  DAMN
    JAVA;

Name: !WokonZwxw2 2008-08-01 12:20

I am Wokon and I support The ABC Programming Language.

Name: Anonymous 2008-08-01 12:39

>>54
System.err.println("I have no idea what 'invert' means");
> BUFFA *= -1;
BUFFA = 1 / BUFFA;

Name: Anonymous 2008-08-01 12:50

>>52
It's /prog/, people prefer HASKELL over C here. Don't talk to me about sense.

Name: Anonymous 2008-08-01 13:21

A FULL implementation of The ABC Programming Language in the Algorithmic Language:
(define (abc source)
  (define accumulator 0)
  (define ascii #f)
  (define (interpret i)
    (cond ((char-ci=? i #\a) (set! accumulator (+ 1 accumulator)))
          ((char-ci=? i #\b) (set! accumulator (- 1 accumulator)))
          ((char-ci=? i #\c) (display (if (eq? #t ascii)
                                          (integer->char accumulator)
                                          accumulator)))
          ((char-ci=? i #\d) (set! accumulator (* (- 1) accumulator)))
          ((char-ci=? i #\r) (set! accumulator (random accumulator)))
          ((char-ci=? i #\n) (set! accumulator 0))
          ((char-ci=? i #\$) (set! ascii (not ascii)))
          ((char-ci=? i #\l) (run))
          ((char-ci=? i #\;) (display accumulator)
                             (display (integer->char accumulator)))))
  (define (run)
    (for-each interpret (string->list source))
    (newline))
  (run))

Name: Anonymous 2008-08-01 13:32

>>53
>System.err.println("I have no idea what 'invert' means");
That's because you're a JAVAIDS programmer.

Name: Anonymous 2008-08-01 13:32

>>59
(- 1 accumulator)
You may want to check that.

Name: Anonymous 2008-08-01 13:33

>>60
That's because ``invert'' can have a million meanings.

Name: Anonymous 2008-08-01 13:34

>>62
You should have checked the esolang wiki and looked at the reference implementation, then.  JAVAIDS has bloated your mind!

Name: Anonymous 2008-08-01 13:38


#include "stdafx.h"
#include "iostream"
#include <string>
#include "stdlib.h"
#include "time.h"

int _tmain(int argc, _TCHAR* argv[])
{
    int buffer = 0;
    bool ascii = false;

    std::string input ="";

    std::cout << "Please enter ABC String: ";
    std::cin >> input;
    std::string::iterator theIterator;
    theIterator = input.begin();
    srand( (unsigned) time(NULL) );
    while(theIterator != input.end()){
        if(*theIterator == 'a')
            buffer++;
        else if(*theIterator == 'b')
            buffer--;
        else if(*theIterator == 'c'){
            if(ascii)
                std::cout << (char)buffer << std::endl;
            else
                std::cout << buffer << std::endl;}
        else if(*theIterator == 'd')
            buffer=-1*buffer;//Or whatever it means.
        else if(*theIterator == 'r'){
            buffer = 0 + (rand() % (buffer+1));}
        else if(*theIterator == 'n')
            buffer=0;
        else if(*theIterator == 'l')
            theIterator = input.begin();
        else if(*theIterator == '$'){
            if (ascii)
                ascii=false;
            else
                ascii=true;}
        else if(*theIterator == ';'){
                std::cout << (char)buffer << std::endl;
                std::cout << buffer << std::endl;}
        else
            std::cout << "Error.\n";
        if(*theIterator != 'l')
            theIterator++;
    }
    return 0;
}

Name: Anonymous 2008-08-01 13:39

>>61
Good catch!  Introducing the Revised Algorithmic Implementation of The ABC Programming Language.  Also added to the test suite: (abc "bbc")
(define (abc source)
  (define accumulator 0)
  (define ascii #f)
  (define (interpret i)
    (cond ((char-ci=? i #\a) (set! accumulator (+ 1 accumulator)))
          ((char-ci=? i #\b) (set! accumulator (- accumulator 1)))
          ((char-ci=? i #\c) (display (if (eq? #t ascii)
                                          (integer->char accumulator)
                                          accumulator)))
          ((char-ci=? i #\d) (set! accumulator (* (- 1) accumulator)))
          ((char-ci=? i #\r) (set! accumulator (random accumulator)))
          ((char-ci=? i #\n) (set! accumulator 0))
          ((char-ci=? i #\$) (set! ascii (not ascii)))
          ((char-ci=? i #\l) (run))
          ((char-ci=? i #\;) (display accumulator)
                             (display (integer->char accumulator)))))
  (define (run)
    (for-each interpret (string->list source))
    (newline))
  (run))

Name: Anonymous 2008-08-01 13:41


1 REM THE ABC PROGRAMMING LANGUAGE
10 INPUT">";P$
20 FOR I=0 TO LEN(P$)
30 I$=MID$(P$,1,I)
40 IF I$="A" THEN A=A+1
50 IF I$="B" THEN A=A-1
60 IF I$="C" THEN PRINT A;
70 NEXT I
80 PRINT:PRINT"END.":PRINT

Name: Anonymous 2008-08-01 13:42

>>63
The ``reference implementation'' is a 404'd PHP script.
I did test all the examples listed in the article, though, and they all checked out. None of them used d, though.

Name: Anonymous 2008-08-01 13:45

>>67

Random phone number generator:

ac
naaaaaaaaradc
naaaaaaaaarc
naaaaaaaaarc

naaaaaaaaradc
naaaaaaaaarc
naaaaaaaaarc

naaaaaaaaradc
naaaaaaaaarc
naaaaaaaaarc
naaaaaaaaarc



AHEM.

Name: Anonymous 2008-08-01 13:50

>>67
It's not a 404 for me (or wasn't earlier - it seems /prog/ is bogging down their server)...  Way to go guys!

Name: Anonymous 2008-08-01 13:58

>>68
That's hardly unambiguous!

Name: Anonymous 2008-08-01 14:10

>>70
Until you actually run the program...
> (abc (string-append "ac"
                    "naaaaaaaaradc"
                    "naaaaaaaaarc"
                    "naaaaaaaaarc"                   
                    "naaaaaaaaradc"
                    "naaaaaaaaarc"
                    "naaaaaaaaarc"
                    "naaaaaaaaradc"
                    "naaaaaaaaarc"
                    "naaaaaaaaarc"
                    "naaaaaaaaarc"))
1-327-261-6454

Name: Anonymous 2008-08-01 14:54

Lets roll some dice!

aaaaaracnl

Name: Anonymous 2008-08-01 14:55

abc n (x:xs) = case x of { 'a' -> abc (n+1) xs ; 'b' -> abc (n-1) xs ; 'c' -> ((putChar.toEnum) n >> abc n xs) ; _ -> abc n xs } ; abc _ _ = putStrLn ""

Name: Anonymous 2008-08-01 14:57

>>73
Please use the indentation and code tags.

Name: Anonymous 2008-08-01 15:00

>>74
I won't allow the indentation to be forced on me !!

Name: Anonymous 2008-08-01 15:02

>>73

abc n (x:xs) =
    case x of
      'a' -> abc (n+1) xs
      'b' -> abc (n-1) xs
      'c' -> ((putChar.toEnum) n >> abc n xs)
      _ -> abc n xs }
abc _ _ = putStrLn ""

Name: Anonymous 2008-08-01 15:16


abc :: [Char] -> IO ()
abc = abc' 0

abc' :: Int -> [Char] -> IO ()
abc' n (x:xs) =
    case x of
      'a' -> abc' (n+1) xs
      'b' -> abc' (n-1) xs
      'c' -> ((putChar.toEnum) n >> abc' n xs)
      _ -> abc' n xs
abc' _ _ = putStrLn ""

gen :: [Char] -> [Char]
gen = gen' 0

gen' :: Int -> [Char] -> [Char]
gen' n (x:xs) =
    let
        c = fromEnum x
        abc | (c > n) = take (c-n) $ repeat 'a'
            | (c < n) = take (n-c) $ repeat 'b'
            | c == n  = ""
    in
      abc ++ ('c' : gen' c xs)
gen' _ _ = ""


It looks like fucking sepples, but I'm too tired to improve it

Name: Anonymous 2008-08-01 15:18

I haven't seen many ABC programs yet.  Only implementations.

Name: Anonymous 2008-08-01 16:03

>>78
[obvious]
That's because ABC isn't Touring complete.
It can only output letters.
[/obvious]

Name: Anonymous 2008-08-01 16:32

>>79
Also numbers.

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