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

Pages: 1-4041-

Let's make some simple programs!

Name: Anonymous 2010-05-08 4:03

Because I know that half of /prog/ can't program, let's make simple ones!

---------------------- MySavings.java ----------------------

/**
 * @(#)MySavings.java
 *
 * MySavings application
 *
 * @author Tim H
 * @version 1.00 2010/5/7
 */
 
import java.util.Scanner;

public class MySavings {
   
    public static void printInterface() {
        System.out.print(
            "1. Show total in bank.\n" +
            "2. Add a penny.\n" +
            "3. Add a nickel.\n" +
            "4. Add a dime.\n" +
            "5. Add a quarter.\n" +
            "6. Take money of out bank.\n" +
            "Enter 0 to quit.\n" +
            "Enter your choice: "
            );
    }
   
    public static void main(String[] args) {
       
        Scanner input = new Scanner(System.in);
        int choice = 1;
        int moneyChoice = 0;
        double amount = 0;
       
        PiggyBank bank = new PiggyBank();
       
        while(choice > 0){
            printInterface();
            choice = input.nextInt();
           
            switch(choice){
                case 0: System.out.println("(c)Tim H 2010\nHave a nice day!"); break;
                case 1: System.out.println("Your current total is: " + bank.GetTotal()); break;
                case 2:
                case 3:
                case 4:
                case 5: moneyChoice = choice - 2; bank.AddMoney(moneyChoice); break;
                case 6:
                    System.out.print("Enter the amount you wish to withdraw: ");
                    amount = input.nextDouble();
                    bank.SubtractTotal(amount);
                    break;
                default:
                    System.out.println("Please enter a choice between 1-6!");
                    break;
            }
               
        }

---------------------- PiggyBank.java ----------------------


class PiggyBank {
    double total;
   
   
    public PiggyBank(){
        total = 100;
    }
   
    public void AddMoney(int choice){
        switch (choice) {
            case 0:
                total += 0.01;
                System.out.println("One penny added to total!\nYour total is now: " + total);
                break;
            case 1:
                total += 0.05;
                System.out.println("One nickel added to total!\nYour total is now: " + total);
                break;
            case 2:
                total += 0.10;
                System.out.println("One dime added to total!\nYour total is now: " + total);
                break;
            case 3:
                total += 0.25;
                System.out.println("One quarter added to total!\nYour total is now: " + total);
                break;
           
        }
    }
   
    public double GetTotal(){
        return total;
    }
   
    public void SubtractTotal(double amount){
        total -= amount;
        System.out.println(amount + " has been subtracted from your total!\nYour total is now: " + total);
    }
}

    }
   
}

Name: Anonymous 2010-05-08 4:37

My attempt at a Game of Life simulator for Python 2.x
#!/usr/bin/env python
# -*- coding: utf-8 -*-


#Game of Life

#Written by Faggot, 29 April 2010

#>> Modules
import sys
import time
import random

#> Constants
_boardsize_x = 80#40 # Cells Across
_boardsize_y = 40#20 # Cells Vertically
_populate_chance = 0.12#0.135 # 0-1 Chance of Cell Population

#>>
#>> GoL Class
#>> Contains all the boards, functions, etc
#>>
class golBoard:
   #> Board Creation
   def __init__(self):
      #Board-Current
      self.boardCurr = [[0 for board_x in range(_boardsize_x)]
                           for board_y in range(_boardsize_y)]
      #Board-Next
      self.boardNext = [[0 for board_x in range(_boardsize_x)]
                           for board_y in range(_boardsize_y)]
  
   #> Board Population - Random
   def populate(self):
      for board_y in range(_boardsize_y):
         for board_x in range(_boardsize_x):
            if random.random() <= _populate_chance:
               self.boardCurr[board_y][board_x] = 1
  
   #> Board Display
   def display(self):
      for board_y in range(_boardsize_y):
         for board_x in range(_boardsize_x):
            if self.boardCurr[board_y][board_x] == 1:
               sys.stdout.write('\xe2') #Unicode Block - u2588
            else:
               sys.stdout.write(' ') #write() is required because
                                     #print inserts space after chars
         print '\n',
      print '\n',
  
   #> Board Neighbors
   def _neighbors(self, board_y, board_x):
      neighbors = 0
      for y in range(-1, 2):
         for x in range(-1, 2):
        
            #> Error Checking
            # The -1 at edges is so that peices don't
            # stick to the edges of the board,
            # I haven't properly tested the edge neighbor
            # calculations, so I'm just doing this to be safe
            if board_x+x == -1:
               neighbors -= 1
            elif board_y+y == -1:
               neighbors -= 1
            elif board_x+x >= _boardsize_x:
               neighbors -= 1
            elif board_y+y >= _boardsize_y:
               neighbors -= 1
           
            #Correct Values!
            else:
               if self.boardCurr[board_y+y][board_x+x] == 1:
                  if x == 0 and y == 0:
                     pass #So it doesn't count itself
                  else:
                     neighbors += 1
      return neighbors
  
   #> Board Updating
   def update(self):
      for board_y in range(_boardsize_y):
         for board_x in range(_boardsize_x):
        
            #Dead, Underpopulation
            if self._neighbors(board_y,board_x) < 2:
               self.boardNext[board_y][board_x] = 0
              
            #Live... Probably
            elif self._neighbors(board_y,board_x) == 2:
               if self.boardCurr[board_y][board_x]:
                  self.boardNext[board_y][board_x] = 1
               else:
                  self.boardNext[board_y][board_x] = 0
                 
            #Live!
            elif self._neighbors(board_y,board_x) == 3:
               self.boardNext[board_y][board_x] = 1
              
            #Dead, Overpopulation
            else: #neighbors > 3
               self.boardNext[board_y][board_x] = 0
              
      self.boardCurr = self.boardNext

#>>
#>> GoL Program - Display, Iterate, Display, Iter...
#>> The usual method
#>>
while True: #Board-Spawner
   #boardStore = [[0 for board_x in range(_boardsize_x)]
   #                 for board_y in range(_boardsize_y)]
   gol = golBoard()
   gol.populate()
   gol.update() # To kill all the extras that spawn
                # when a random board is created

   #while True:
   for num in range(51):
      print "Game of Life, Iteration", num
      print _boardsize_x, "by", _boardsize_y, "board"
      gol.display()
     
      #if (num+5 % 10) == 0:
      #   boardStore = copy(gol.boardCurr)
      #boardStore = copy(gol.boardCurr)
        
      gol.update()
     
      #if gol.boardCurr == boardStore:
      #   break
        
      time.sleep(0.04)

#>>
#>> GoL Program - Iterate to fin, Display
#>> The batch-calculation method
#>>
if False: #Poor-Man's Block Comment
   print "\n\n\n"
   gol = golBoard()
   gol.populate()
   i = 1

   for num in range(49):
      gol.update()
      i += 1

   print "Game of Life, Iteration", i
   print _boardsize_x, "by", _boardsize_y, "board"
   gol.display()

Name: Anonymous 2010-05-08 10:22

Also, a simple binary tree that you can only add values to
#!/usr/bin/env python

# Binary Tree
# Written by Faggot, 8 May 2010

class node:
   linkL = None
   linkR = None
   data = None

   def __init__(self, data):
      self.linkL = None
      self.linkR = None
      self.data = data


class tree:
   def __init__(self):
      self.root = None

   #> Node Search
   def find_node(self, data):
      node_temp = self.root
      while True:
         if data == node_temp.data:
            return node_temp

         elif data < node_temp.data:
            if node_temp.linkL != None:
               node_temp = node_temp.linkL
            else:
               return None

         elif data > node_temp.data:
            if node_temp.linkR != None:
               node_temp = node_temp.linkR
            else:
               return None

   #> List Tree
   def tree(self, data, ordered=True):
      #data is string
      if str(data) == data:
         return self._tree(self.find_node(data), ordered)

      #data is node
      else:
         return self._tree(data, ordered)
  
   def _tree(self, node, ordered=True, t_list=None, level=1):
      if t_list == None:
         t_list = list()
        
      if node == None:
         pass
      else:
         if ordered:
            self._tree(node.linkL, ordered, t_list, level+1)
            t_list.append(node.data)
            self._tree(node.linkR, ordered, t_list, level+1)
         else:
            t_list.append(('-'*level)+str(node.data))
            self._tree(node.linkL, ordered, t_list, level+1)
            self._tree(node.linkR, ordered, t_list, level+1)
      return t_list
  
   # Node Addition
   def add(self, data):
      if self.root == None:
         self.root = node(data)

      else:
         node_temp = self.root
         while True:
            if data == node_temp.data:
               print(data, "- Node Already Exists")
               break

            elif data < node_temp.data:
               if node_temp.linkL == None:
                  node_temp.linkL = node(data)
                  break
               else:
                  node_temp = node_temp.linkL

            elif data > node_temp.data:
               if node_temp.linkR == None:
                  node_temp.linkR = node(data)
                  break
               else:
                  node_temp = node_temp.linkR
                 
#>
#> Number Tree
#> String Trees work as well
#>
import random
nums = tree()
for i in range(10):
   nums.add(random.randint(4, 30))
print('\n')

# Ordered Node Listing
for num in nums.tree(nums.root):
   print(num)
print('\n')

# Tree Structure Listing
for num in nums.tree(nums.root, False):
   print(num)
print('\n')

Name: Anonymous 2010-05-08 12:30

>>1
I realize you are one of those who "can't program", please find attached a corrected version of your program. In future, please refrain from posting on /prog/ until you have achieved satori.

import java.util.*;
public class Savings {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        Account account = new Account();
        SortedMap<Integer, AccountChoice> choices = new TreeMap<Integer, AccountChoice>();
       
        choices.put(0, new AccountChoice() {
            public String toString() { return "Close account and exit."; }
            public void invoke(Account ac) { System.exit(0); }
        });
        choices.put(1, new AccountChoice() {
            public String toString() { return "Show balance."; }
            public void invoke(Account ac) {
                System.out.println(new java.text.DecimalFormat("#0.00").format(ac.getBalance()/100.0));
            }
        });
        choices.put(2, new AccountChoice() {
            public String toString() { return "Add a "+ Currency.PENNY + "."; }
            public void invoke(Account ac) {
                try { ac.deposit(Currency.PENNY.toCents()); }
                catch(IllegalArgumentException e) { System.out.println(e.getMessage()); }
            }
        });
        choices.put(3, new AccountChoice() {
            public String toString() { return "Add a "+ Currency.NICKEL + "."; }
            public void invoke(Account ac) {
                try { ac.deposit(Currency.NICKEL.toCents()); }
                catch(IllegalArgumentException e) { System.out.println(e.getMessage()); }
            }
        });
        choices.put(4, new AccountChoice() {
            public String toString() { return "Add a "+ Currency.DIME + "."; }
            public void invoke(Account ac) {
                try { ac.deposit(Currency.DIME.toCents()); }
                catch(IllegalArgumentException e) { System.out.println(e.getMessage()); }
            }
        });
        choices.put(5, new AccountChoice() {
            public String toString() { return "Add a "+ Currency.QUARTER + "."; }
            public void invoke(Account ac) {
                try { ac.deposit(Currency.QUARTER.toCents()); }
                catch(IllegalArgumentException e) { System.out.println(e.getMessage()); }
            }
        });
        choices.put(6, new AccountChoice() {
            public String toString() { return "Make a withdrawl."; }
            public void invoke(Account ac) {
                System.out.print("Enter the amount you wish to withdraw (cents): ");
                int amount = sc.nextInt();
                try { ac.withdraw(amount); System.out.println("Withdrawl successful."); }
                catch(Exception e) { System.out.println(e.getMessage()); }
            }
        });
       
        while(true) {
            for(Map.Entry<Integer, AccountChoice> choice : choices.entrySet())
                System.out.println(choice.getKey() + ". " + choice.getValue());
            System.out.print("Enter your choice: ");
            int option = sc.nextInt();
            if(!choices.containsKey(option)) System.out.println("Please enter a valid choice.");
            else choices.get(option).invoke(account);
        }
    }
}
abstract class AccountChoice {
    public abstract void invoke(Account ac);
}
enum Currency {
    PENNY(1, "penny"),
    NICKEL(5, "nickel"),
    DIME(10, "dime"),
    QUARTER(25, "quarter");
   
    private long cents;
    private String name;
   
    private Currency(long cents, String name) {
        this.cents = cents;
        this.name = name;
    }
    public long toCents() {
        return cents;
    }
    public String toString() {
        return name;
    }
}   
class Account {
    private long savings;
    public Account() {
        savings = 0;
    }
    public void deposit(long cents) {
        if(cents < 0) throw new IllegalArgumentException("Cannot deposit negative cents.");
        savings += cents;
    }
    public long getBalance() {
        return savings;
    }
    public void withdraw(long cents) throws InsufficientFundsException {
        if(cents > savings) throw new InsufficientFundsException("Insufficient funds for withdrawl.");
        if(cents < 0) throw new IllegalArgumentException("Cannot withdraw negative cents.");
        savings -= cents;
    }
}
class InsufficientFundsException extends IllegalArgumentException {
    public InsufficientFundsException(String message) {
        super(message);
    }
}

Name: Anonymous 2010-05-08 12:38

I have a feeling someone from /prog/ wrote this:
http://wiibrew.org/wiki/WiiRecipe

Name: Anonymous 2010-05-08 12:55

>>5
WRITE MYANUS

Name: Anonymous 2010-05-08 14:30

>>4
one of those who "can't program"
a corrected version
achieved satori
corrected version still in java


HIBT?

Name: Anonymous 2010-05-08 19:44

>>7
HIBT?
Yes.

Name: Anonymous 2010-05-08 20:24

Here's something I wrote yesterday:

primes = 1 : 2 : filter isPrime [3 ..]
isPrime = uncurry ($) . (all . ((/= 0) .) . mod &&& flip takeWhile (tail primes) . (>=) . floor . sqrt . fromIntegral)

Name: Anonymous 2010-05-08 20:55

>>1,4

#!/usr/bin/python

def _print(a): print a
coins = "penny", "nickel", "dime", "quarter"

prntrfc = lambda: map(_print,                                                \
                      map(lambda (i, j): str(i) + j,                         \
                          enumerate(["", ". Show total in bank."] +          \
                                    map(lambda n: ". Add a %s." % n, coins) +\
                                    [". Take money of out bank. [sic]"]))[1:])

class Pig():
    def __init__(s):
        s.t = 100.

    def __add__(s, n):
        a = .01, .05, .1, .25
        s.t += a[n]
        print "One %s added to total!\nYour total is now:" % coins[n], s.t

    def __sub__(s, n):
        s.t -= n
        print n, "has been subtracted from your total!\nYour total is now:", s.t

    def __str__(s):
        return str(s.t)

pig = Pig()

while True:
    p = lambda n: pig + n
    cl = (lambda: _print("(c) Xarn 2012\nHave a nice day!"),
          lambda: _print("Your current total is: " + str(pig)),
          lambda: p(0),
          lambda: p(1),
          lambda: p(2),
          lambda: p(3),
          lambda: pig - float(raw_input("Enter the amount you wish to withdr" +\
                                        "aw: ")))

    prntrfc()

    try:
        cl[int(raw_input(""))]()
    except IndexError:
        print "Please enter a choice between 1-6!"

Name: Anonymous 2010-05-08 21:27

>>10
Your post has been reported to Herr Guido's Personal Guard. You are strongly advised to cease all functional FIOC activity.

Name: Anonymous 2010-05-08 21:57

>>10
def _print(a): print a
shoulda used Py3k

Name: Anonymous 2010-05-08 22:00

>>12
Now you have 3K problems

Name: Anonymous 2010-05-08 23:14

>>11
Why the fuck does Guido hate functional programming anyway?

Name: Anonymous 2010-05-08 23:20

>>14
Because he grew up with Basic. That's more than enough to cause the brain damage.

Name: Anonymous 2010-05-08 23:28

>>15
Fine. Then why does his language have map() and all that? Isn't that a bit hypocrite?

Name: Anonymous 2010-05-08 23:29

>>16
Someone else added it when he wasn't looking, in the early '90s. It took him until Py3K to notice and have it moved to the functools module.

Name: Anonymous 2010-05-08 23:33

>>17
Wow. He just keeps crapping it up one release at a time.

Name: Anonymous 2010-05-08 23:37

>>18
There's a reason people say Python is good despite its creator.

Name: Anonymous 2010-05-09 2:56

>>19
This thread has been derail'd

Sorry, OP

Name: Anonymous 2010-05-09 3:50

Name: Anonymous 2010-05-09 3:59

im not even gonna read this.


#include <stdio.h>
#include <unistd.h>

int main(int dicksc, char** dicksv) {
  puts("hi");
  fuck_you(12);
}

void fuck_you (int ignored) {
  for(;;) {
    puts("HA");
    fork();
}

Name: Anonymous 2010-05-09 4:06

>>22
forgot a second } at the end.

Name: Anonymous 2010-05-09 5:00

>>9
1 is not a prime number.

Name: Anonymous 2010-05-09 5:28

>>24
That's a pretty slow primality test too.

Since we're writing toy programs, I'll just look up some toy code that I wrote last year when I was learning CL:

(defun seq (n m &optional (k 1))
  (loop for i from n to m by k collect i))

(define-modify-macro set-differencef (&rest args) set-difference)

(defun prime-sieve (n)
  (let ((primes (seq 2 n)))
    (loop for i from 2 to n
          do (set-differencef primes (rest (seq i n i))))
    (sort primes #'<)))

Name: Anonymous 2010-05-09 5:50

primes = 2 : 3 : 5 : 7 : [k + r | k <- [0, 30..], r <- [11, 13, 17, 19, 23, 29, 31, 37], primeTest (k + r)]
    where primeTest n = all ((0 /=) . mod n) . takeWhile ((n >=) . join (*)) $ drop 3 primes

Name: Anonymous 2010-05-09 6:12

toy programs? look out, here comes some FOIC!
this code is actually faster than the factorial function in the math module (which is written in c!)... proof that guido can't code for shit.
from itertools import takewhile, dropwhile

def eratosthenes():
        D = {}
        q = 2
        while 1:
                if q not in D:
                        yield q
                        D[q*q] = [q]
                else:
                        for p in D[q]:
                                D.setdefault(p+q,[]).append(p)
                        del D[q]
                q += 1

def bitcount(n):
        r = 0;
        while n > 0:
                r += n & 1
                n >>=1
        return r

def take(n, g):
        for i in range(n): yield g.next()

def swing(n):
        primes = list(takewhile(lambda x: x <= n, eratosthenes()))
        smalloddswing = [1,1,1,3,3,15,5,35,35,315,63,693,231,3003,429,6435,6435,109395,12155,230945,46189,969969,88179,2028117,676039,16900975,1300075,35102025,5014575,145422675,9694845,300540195,300540195]
        if n < 33: return smalloddswing[n]
        primelist = []
        primesa = takewhile(lambda x: x * x <= n, dropwhile(lambda x: x < 3, primes))
        primesb = takewhile(lambda x: x * 3 <= n, dropwhile(lambda x: x * x <= n, primes))
        for prime in primesa:
                q = n // prime
                p = 1
                while q > 0:
                        if q & 1 == 1: p *= prime
                        q //= prime
                if p > 1: primelist.append(p)
        return reduce(lambda x, y: x * y, list(takewhile(lambda x: x <= n, dropwhile(lambda x: x << 1 <= n, primes))) + primelist + filter(lambda x: n // x & 1 == 1, primesb), 1)

def recfactorial(n):
        if n < 2: return 1
        return recfactorial(n >> 1) ** 2 * swing(n)

def factorial(x):
        if x < 0: raise ValueError('factorial() not defined for negative values')
        n = int(x)
        if n != x: raise ValueError('factorial() only accepts integral values')
        if n < 20: return reduce(lambda x, y: x * y, range(2,n + 1), 1)
        return recfactorial(n) << (n - bitcount(n))

Name: Anonymous 2010-05-09 9:53

I think we should fork Python, throw out the entire standard library, get rid of the idiotic GIL, fix lambda, and add shittons of functional stuff to it. Anyone with me to do this?

Name: Anonymous 2010-05-09 9:54

>>28
Incidentally, that was already my plan for the summer (assuming I don't find work).

Name: Anonymous 2010-05-09 10:43

>>29
call it gayPython

Name: Anonymous 2010-05-09 10:44

>>28

Call it Pynonix

Name: Anonymous 2010-05-09 10:52

>>28
throw out the entire standard library,
Let's not be too hasty. At least keep a few, for instance, I couldn't program without pyteledildonics

Name: Anonymous 2010-05-09 11:52

>>27
fact = lambda n: int(round(math.e**reduce(lambda a, b: a + math.log(b), range(1, n+1), 0)))

Mine's shorter.

Name: Anonymous 2010-05-09 11:59

>>32
You just cant get enough of those RemoteOrgasmAsyncExceptions.

Name: Anonymous 2010-05-09 12:41

>>33
Too bad that by the time you get to fact(100) the error of that approximation is up to about 6.9 x 10144.

(Exactly 6900274882930203761252337810247937431593403625973980018479912680937406453445938682543730846893682459286692158877000328163287360910292339254099968, actually)

Name: Anonymous 2010-05-09 14:36

>>35
But the nice part of it is that the error increases in a beautiful exponential curve, so you can get a good estimate of how big it's going to be and adjust the result based on that.
The only problem is knowing the sign of the error, though that problem apparently goes away when the number you're taking the factorial of is big enough. Here's a graph of the value of the approximate function minus the value of the actual factorial:

http://i.imgur.com/bjeoj.png

(Where the graph is broken the error is negative, except for x ≤ 17, where it's 0. The absolute values of the error form a pretty straight line.)

Name: Anonymous 2010-05-09 15:01

>>33
fact = PyGMP.GMPi.fac
not only is mine shorter, it actually works.

Name: Anonymous 2010-05-09 15:08

>>37
It's also slower.

Name: Anonymous 2010-05-09 15:10

>>38
Ah, the old time/space balance dilemma.

Name: Anonymous 2010-05-09 15:14

>>38
it gets correct results a lot faster than >>33's code does, so it's faster.

Name: Anonymous 2010-05-09 15:31

Close call! We almost had an interesting discussion here with >>33,35-36. Thanks for nipping that in the bud, >>37,40-kun.

Name: Anonymous 2010-05-09 16:08

Does anyone have anything on designing a better RNG?

Name: Anonymous 2010-05-09 16:17

>>42
TAoCP for PRNGs. RNG - use some really random data, like radiation measurements/atmospheric noise or whatever.

Name: Anonymous 2010-05-09 17:13

install python if you dont have it, then install pygame,
then save this image: http://img525.imageshack.us/img525/1223/balll.gif

copy this code and save it with the .py extention in the same place you saved the ball image and run it (I recommend using the pyscripter IDE over IDLE)

import sys, pygame
pygame.init()

size = width, height = 320, 240
speed = [1, 1]
black = 0, 0, 0

screen = pygame.display.set_mode(size)

ball = pygame.image.load("ball.gif")
ballrect = ball.get_rect()

while 1:
    for event in pygame.event.get():
        if event.type == pygame.QUIT: sys.exit()

    ballrect = ballrect.move(speed)
    if ballrect.left < 0 or ballrect.right > width:
        speed[0] = -speed[0]
    if ballrect.top < 0 or ballrect.bottom > height:
        speed[1] = -speed[1]

    screen.fill(black)
    screen.blit(ball, ballrect)
    pygame.display.flip()

Name: Anonymous 2010-05-09 19:51

Name: Anonymous 2010-11-17 20:14

OP is a flaming black homosexual.

Name: Anonymous 2010-11-17 23:03

>>46
your a fucking faggot

Name: Anonymous 2010-11-18 13:24

>>44
Rewrite that with pyglet and we'll talk.

Name: Anonymous 2010-11-18 15:19


#Another Version of the Sieve of Eratosthenes
l, n = [], 100
for i in range(n): l.append(True)
i = 2
while i * i <= n:   
    if l[i-1] == True:
        #if not i%2:
        for j in range(i*i, n+1, i): l[j-1] = False                   
    i += 1
i = 2
while i <= n:
    if l[i-1] == True : print(i, " ", end = "")
    i += 1

Name: VIPPER 2010-11-18 16:37

#!/bin/perl

my $JEWS = "";
print $JEWS .= "JEWS " while 1;
print "this message will never be printed, prepare your anus for VIPPER\n";

#JEWS

Name: Anonymous 2010-11-18 21:49

>>50
/bin/perl
Faggot.

Name: barbour mens classic duffle 2011-12-01 22:42

There are many brands of <a href="http://www.barbourjackets-uk.org/"><strong>barbour fusilier</strong></a> in the market today. Each of the brand promises to bring out something new to the customers.

Name: Anonymous 2011-12-02 13:29

>>55
wow amazing dubs bro

Name: Anonymous 2011-12-02 14:11

hehe thanks >>54

Name: Anonymous 2011-12-02 16:13

>>55
lol np ^^;

Name: Anonymous 2011-12-02 16:33

#!/bin/clojure
(assert (eq lisp shit))

Name: Anonymous 2011-12-02 18:16

[code]print "Hello World![\code]

Name: Anonymous 2011-12-02 22:59


10 LET A=0
20 LET A=A+1
30 IF A MOD 15=0 THEN 80
40 IF A MOD 3=0 THEN 100
50 IF A MOD 5=0 THEN 120
60 GOTO 140
80 PRINT"FIZZBUZZ"
90 GOTO 20
100 PRINT"FIZZ"
110 GOTO 20
120 PRINT"BUZZ"
130 IF A<100 THEN 20
131 SLEEP
132 END
140 PRINT A
150 GOTO 20

Name: Anonymous 2011-12-02 23:26

<?function f($x){return(!$x)?1:$x*f($x-1);}?>

Name: Anonymous 2011-12-03 7:56


#t ; Enjoy a Scheme/Python quine
'''() ;
(print "Hello from Scheme!")
; '''
(); print "Hello from Python!"


Try it at http://repl.it

Name: Anonymous 2011-12-03 8:04

The following is valid C, Sepples, Python, Ruby and Brainfuck program that prints out the name of the language it's run as:

#ifdef v 
'''>+++>"egnufeB":v<++++ 
+[<++++++++>-][v:,_@]<++ 
.>+++++++[<++++>  ^<+++> 
-]<-.>++++[<---->-]<-.>+ 
++[<+++>-]<-.>++[<++>-]< 
+.>+++[<--->-]<+.>++++[< 
++++>-]<-.>++++[<---->-] 
<--.>+++[<+++>-]<-> 
#endif 
#include <stdio.h> 
int main(){ 
    printf("C"); 
#ifdef __cplusplus 
    printf("++"); 
#endif 
    return 0; 

//'''"#{puts 'Ruby';exit}"; print 'Python'

Name: Anonymous 2011-12-03 8:06

>>62
*and Befunge

Name: Anonymous 2011-12-03 8:21

>>62
The following is valid C, Sepples
False. The first #ifdef block contains invalid preprocessing tokens.

Name: Anonymous 2011-12-03 8:27

>>64
Which will be promptly ignored.

Name: Anonymous 2011-12-03 8:29

>>65
The norm doesn't require the parser to skip unused blocks; undefined behaviourdesu.

Name: Anonymous 2011-12-03 8:32

>>66
Well, okay.
The following is a C, Sepples, Python, Ruby and Brainfuck program ...
If it doesn't work, your compiler is shit.

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