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

Pages: 1-

eerui

Name: Anonymous 2010-09-16 22:38

ITT:
We write different ways to produce 'hello world' in the shell
language : c++
no syntax errors, and no copying others work. I'll start with something simple

#include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}

Name: Anonymous 2010-09-16 22:40

Let's not.

Name: Anonymous 2010-09-16 23:02

Seems pretty boring.

#include <unistd.h>

int main()
{
    static const char message[] = "Hello World!\n";
    int err = write(0, message, sizeof(message));
    if (err < 0)
        return err;
}

Name: Anonymous 2010-09-16 23:08

#lang racket
(define-syntax c++-display
  (syntax-rules ()
    ((_ s) (string-append "std::cout << "
                          s
                          " << std::endl;"))))

(define-syntax main
  (syntax-rules ()
    ((_ exps ...)
     (string-append "#include <iostream>\n"
                     "int main () {\n"
                     (string-append*
                      (map (λ(s)
                             (string-append "\t" s "\n"))
                           (list exps ...)))
                     "\treturn 0;\n\t}\n"))))

(display
   (main
    (c++-display "Hello world!")))

Name: 2010-09-17 0:32

JACKSON 5 GET

Name: Anonymous 2010-09-17 0:52

>>5
nice

Name: Anonymous 2010-09-17 5:12

>>4
And this is why idiots shouldn't use macros

Name: Anonymous 2010-09-17 9:27

>>7
Oh, why are you making me cry?

Name: Anonymous 2010-09-17 9:39

TELL ME WHY
WHY MUST I CRY

Name: Anonymous 2010-09-17 11:57

__import__('os').system("""python -c 'print "hello world"'""")

Name: Anonymous 2010-09-17 12:48

Compile javac this and run it through a Java bytecode interpreter:
\u0063\u006c\u0061\u0073\u0073\u0020\u004d\u0061\u0069\u006e
\u007b
\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0076\u006f\u0069\u0064\u0020\u006d\u0061\u0069\u006e\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0061\u0072\u0067\u0073\u005b\u005d\u0029
\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007b
\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u002e\u006f\u0075\u0074\u002e\u0070\u0072\u0069\u006e\u0074\u006c\u006e\u0028\u0022\u0048\u0065\u006c\u006c\u006f\u0020\u0057\u006f\u0072\u006c\u0064\u0022\u0029\u003b
\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007d
\u007d

Name: Anonymous 2010-09-17 14:59

import sys

def null_ord(ch):
    if ch > 0:
        return ord(c)
    else:
        return 0

def brainfuck(code):
    indent = 0
    pycode = ''
    pt = 0
    ta = [0] * 32767
    for i in code:
        tab = indent * 4 * ' '
        if i == '>': # Move right
            pycode += tab + 'pt += 1'
        elif i == '<': # Move left
            pycode += tab + 'pt -= 1'
        elif i == '+': # Increment cell
            pycode += tab + 'ta[pt] += 1'
        elif i == '-': # Decrement cell
            pycode += tab + 'ta[pt] -= 1'
        elif i == '[': # Start loop
            pycode += tab + 'while ta[pt]:'
            indent += 1
        elif i == ']': # End loop
            indent -= 1
        elif i == ',': # Read STDIN
            pycode += tab + 'ta[pt] = null_ord(sys.stdin.read(1))'
        elif i == '.': # Write STDOUT
            pycode += tab + 'sys.stdout.write(chr(ta[pt]))'
        else: # Comment
            continue
        pycode += '\n'
    exec pycode
    print

brainfuck('>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.>>>++++++++[<++++>-]<.>>>++++++++++[<+++++++++>-]<---.<<<<.+++.------.--------.>>+.')

Name: Anonymous 2010-09-17 16:00

>>12
Don't forget to compile the generated code with -O3!!!

Name: Anonymous 2010-09-17 17:39

I remember once posting a Brainfuck program that outputted a Perl script that outputted a Brainfuck program that printed 'Hello, World' or some other combination of BF and Perl.

Name: Anonymous 2010-09-17 23:58

Plan 9's dialect of C

#include <libc.h>

void main(int, char **)
{
    print("hello world!\n");

    exits(nil);
}

Name: Anonymous 2010-09-18 0:03

Limbo

implement Hello;

include "sys.m";
    sys: Sys;
include "draw.m";

Hello: module
{
    init: fn(ctxt: ref Draw->Context, args: list of string);
}

init(ctxt: ref Draw->Context, args: list of string)
{
    sys = load Sys Sys->PATH;
    sys->print("hello world!\n");
}

Name: Anonymous 2010-09-18 0:18

<code>
#include <iostream>

using namespace std;

int main()
{
    char letter = 72;
    cout << letter;
    letter +=29;
    cout << letter;
    letter += 7;
    cout << letter << letter;
    letter += 3;
    cout << letter;
    letter -= 79;
    cout << letter;
    letter += 87;
    cout << letter;
    letter -= 8;
    cout << letter;
    letter += 3;
    cout << letter;
    letter -= 6;
    cout << letter;
    letter -= 8; 
    cout << letter;
    return 0x539;
}

Name: Anonymous 2010-09-18 1:21

These threads only encourage the high school ``programmers''.

Name: Anonymous 2010-09-18 3:56

>>18
You are this MAD.

Name: Anonymous 2010-09-18 5:18

from re import match, sub

# Get argument from statement regex
def get_arg(line, stmt):
    return sub(stmt, r'\1', line)

# BASIC statements
PRINT = r'[0-9]+ PRINT "(.*)"'
GOTO  = r'[0-9]+ GOTO ([0-9]+)'

# BASIC code
basic = '''
10 PRINT "HELLO, WORLD"
20 GOTO 10
'''

# Clear empty lines to keep it clean
basic = filter(None, basic.splitlines())

# Considered harmful
goto = {}
for pos, code in enumerate(basic): # pos is "real" line num, code.split()[0] is basic line num
    goto[code.split()[0]] = pos

# Interpret BASIC code
pos = 0
while pos < len(basic):
    line = basic[pos] # Get line
   
    if match(PRINT, line):
        print get_arg(line, PRINT) # Print argument
    elif match(GOTO, line):
        point = get_arg(line, GOTO)
        pos = goto[point] # Pass line number through goto table
        continue # Don't increment pos as usual
   
    pos += 1 # Next line

Name: Anonymous 2010-09-18 6:11

I call on the power of infinate monkeys to help me with this

#include <iostream>

using namespace std;

int main()
{
    char str[12];
    while(1)
    {
        for(int i = 0; i < 11; i++)
        {
            str[i] = rand() % 255;
        }
        string yeahimlazydontshootme = str;
        if(yeahimlazydontshootme == "Hello world")
        {
            cout << str;
        }
    }
}

Name: Anonymous 2010-09-18 6:43

echo hello world

Name: Anonymous 2010-09-18 6:50

>>21
bogohelloworld

Name: Anonymous 2010-09-18 7:21


#include <stdio.h>
int main() {
    int i,c=0150;
    for(i=0;i<12;i++) {
        switch(i) {
            case 2: c += 4;
            case 4:
            case 8: c += 3;
            case 0:
            case 3: break;
            case 5: c &= 176; break;
            case 6: c |= 87;  break;
            case 7:
            case 10:c -= 2;
            case 9: c -= 3;
            case 1: c -= 3; break;
            case 11: c ^= 'n'; break;
        }
        putchar(c);
    }
}

Name: Anonymous 2010-09-18 8:28

>>24
    int i, c=150;*

Name: Anonymous 2010-09-18 10:32

>>25
wat

Name: Anonymous 2010-09-18 11:52

>>24
Glorious.

Name: Anonymous 2010-09-18 11:57

>>27
y thank u (not same person)

Name: Anonymous 2010-09-18 14:20

>>26
octal don't ya know

Name: Anonymous 2010-09-18 15:28

In Java, the idea of a namespace is embodied in Java packages. All code belongs to a package, although that package need not be explicitly named. Code from other packages is accessed by prefixing the package name before the appropriate identifier, for example class String in package java.lang can be referred to as java.lang.String (this is known as the fully qualified class name). Like C++, Java offers a construct that makes it unnecessary to type the package name (import). However, certain features (such as reflection) require the programmer to use the fully qualified name.

Unlike C++, namespaces in Java are not hierarchical as far as the syntax of the language is concerned. However, packages are named in a hierarchical manner. For example, all packages beginning with java are a part of the Java platform—the package java.lang contains classes core to the language, and java.lang.reflect contains core classes specifically relating to reflection.

In Java (as well as Ada, C#, and others), namespaces/packages express semantic categories of code. For example, in C#, namespace System contains code provided by the system (the .NET framework). How specific these categories are and how deep the hierarchies go differ from language to language.

Function and class scopes can be viewed as implicit namespaces that are inextricably linked with visibility, accessibility, and object lifetime.

Name: Anonymous 2010-09-18 15:28

>>29
26 knows. 25 is the tard

Name: Anonymous 2010-09-18 15:35

>>30
lowercase package names
that's butt ugly.

Name: Anonymous 2010-09-18 19:29

>>32
Says someone who apparently lacks a shift key.

Name: Anonymous 2010-09-18 21:13


#     Bill Lindo Says Someone Is Hijacking The PUP‎

Name: Anonymous 2010-09-18 21:16

Fuck Bill Lindo.

Name: Anonymous 2011-02-03 2:57

Name: Anonymous 2011-02-04 19:48

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