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

post bits of code you like

Name: Anonymous 2005-08-02 1:52

i shall start:

open(F,"find -type f|");
while (<F>) {
 $_ = substr($_,2,-1);
 print "$_\n" if $v;
 push @{$dups{substr(`md5sum -b "$_"`,0,31)}}, $_;
}
close(F);

for every file in a directory it checksums the file, then adds the checksum as a key to a hash, the value being an array reference. the filename is then added to the array.

so basically the arrays have a list of files with the same checksum. i use this to find duplicates files.

Name: Anonymous 2005-12-16 9:59

>>78

for aChild in thisRoot ... end

class Node
  attr_accessor :left, :right, :data
  def traverse
    @left.traverse {|node| yield node } unless @left.nil?
    yield self
    @right.traverse {|node| yield node } unless @right.nil?
  end
end

def fibone(n)
  a, b = 0, 1
  (n-1).times do
    yield a if block_given?
    a, b = b, a+b
  end
  return b
end


fib(100) {|n| puts n}

$fibcache = Hash.new
def fib(n)
  $fibcache[0], $fibcache[1] = 0, 1
  return fib_re(n)
end

def fib_re(n)
  if !($fibcache[n].nil?)
    return $fibcache[n]
  elsif (n.modulo(2) == 0)
    fnn = fib_re((n/2.0).to_i)
    fnm = fib_re(((n/2.0)-1).to_i)
    ans = (((2 * fnm) + fnn)*fnn).to_i
  else
    fnn = fib_re((n/2.0).ceil)
    fnm = fib_re((n/2.0).floor)
    ans =  ((fnn**2)+ (fnm**2)).to_i
  end
  $fibcache[n]=ans
  return ans
end

Name: Anonymous 2005-12-16 14:42

>>77
Nice
Now gb2/IOCCC :P

Name: Anonymous 2005-12-27 11:48

>>52
The point is to demonstrate anonymous recursion, not "how to write an efficient fibonacci calculator".

Name: Anonymous 2005-12-30 7:27

if(checkifrename(actualfile,extlist.FindStringExact(System.IO.Path.GetExtension(filelist[lastfile]))) == true){
donothing();
}
else{
download_porn();
}

Name: Anonymous 2006-01-03 21:04

void life(){
for(;;)
grab_porn();
}

Name: Anonymous 2006-01-14 18:12

(Forth for teh win! ) : add-one 1 + ; 1 add-one . ( n1 -- n2 )

Name: Anonymous 2006-01-15 6:51

>>86
Bump for Forth. I recently bought a Sparcstation and was well amused when I found that the boot prom was a goddamn forth interpreter :D

Name: Anonymous 2006-01-16 17:39

It's too bad Forth is on the highway to irrelevance. Other than a tiny embedded niche, is it used anywhere anymore?

Name: Anonymous 2006-01-16 18:32

n=gets.to_i;a=(2..n).to_a;a.each{|m|puts m; (m*2).step(n,m){|j|a.delete j}}

Name: Anonymous 2006-01-16 18:52

// I can guarauntee that the following is a variation of the very first "program" you wrote:

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

Name: Anonymous 2006-01-16 20:26

10 ? "HELLO WORLD"

Name: Anonymous 2006-01-17 3:09

>>88
Truth. Still, how many people use a language doesn't have any bearing on how fun it is for you personally. And Forth is damn fun; it's like a low-level Lisp.

Name: Sakamura 2006-01-17 19:06

int total = 0;

for(int i=0; i < multiplier.itemCount(); i++)
{
   total = Interger.parseInt(multiplier[i]) / i;
}
return total;

Name: Anonymous 2006-01-18 8:50

a: CALL 01404E20h ;Reference to Kernel.GrabPorn
JMP a

Name: Anonymous 2006-01-23 23:20

umm, so you all know that there is a solution to the recurrence relation for the fibonacci numbers right?

Name: Anonymous 2006-01-24 3:17

>>95
Big words.

Name: Anonymous 2006-01-24 4:27

>>95
STFU AND DO YOUR OWN HOMEWORK FAGGOT

Name: Anonymous 2006-01-24 6:00

What is CS so obsessed with fibonacci numbers? It's used as an example everywhere.

Name: Anonymous 2006-01-24 6:45

Fib is a simple example of recursion, so all beginning textbooks like to cover it. Never mind the fact that there are much more useful examples of recursive functions, like recursive descent parsers.

Name: Anonymous 2006-01-24 8:36

>>99
Correction: fib is a great example of how it can be a disaster to define something recursively.

Name: Anonymous 2006-01-24 8:49

>>100
They like it because they can go

"First we define fib like this, recursively. Makes sense, right? But ZOMG, it is insanely inefficient!!!!111oneeleven! But look, all we have to do is use this accumulation variable and everything is all right!"

And then the student goes away thinking recursion is all about accumulation vars.

Name: Anonymous 2006-01-24 8:59

>>101
I went away thinking recursion sucked, and used iteration for everything for the next 5 years.

Name: Anonymous 2006-01-24 9:46

there are libraries nowadays that handle memoization of recursive functions for you, which helps take care of the inefficiency..

Name: Anonymous 2006-01-24 15:39

>>103
they are not as efficient as the iteration obviously

Name: Anonymous 2006-01-25 10:51

>>103
"memoize" is such a dumb sounding word
stop sucking MJD's dick

Name: Anonymous 2006-01-28 14:50

Computes arbitrarily large Fibonacci numbers in Brainfuck, I didnt write it:

>++++++++++>+>+[
    [+++++[>++++++++<-]>.<++++++[>--------<-]+<<<]>.>>[
        [-]<[>+<-]>>[<<+>+>-]<[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-
            [>+<-[>+<-[>+<-[>[-]>+>+<<<-[>+<-]]]]]]]]]]]+>>>
    ]<<<
]

This program doesn't terminate; you will have to kill it.
Daniel B Cristofani (cristofdathevanetdotcom)
http://www.hevanet.com/cristofd/brainfuck/

Name: Anonymous 2006-01-28 15:00

main = getLine >>= putStrLn >> main

cat in haskell

Name: Anonymous 2006-01-28 20:57

while (<>) { print }

cat in Perl

Name: Anonymous 2006-01-29 0:50

void cKillStats::vHandleSprees(void)
{
    char cKillStr[256];
    if(KillInfo.iTempKills == 2 && !KillInfo.bIsInSpree)
    {
        _beginthread(vDoubleKill, 0, NULL);
        KillInfo.cSprees = "DOUBLE KILL!";
        KillInfo.bIsInSpree = true;
        KillInfo.iLastSpree = 2;
    }
    else if(KillInfo.iTempKills == 3 && !KillInfo.bIsInSpree)
    {
        _beginthread(vTripleKill, 0, NULL);
        KillInfo.cSprees = "TRIPLE KILL!";
        KillInfo.bIsInSpree = true;
        KillInfo.iLastSpree = 3;
    }
    else if(KillInfo.iTempKills == 4 && !KillInfo.bIsInSpree)
    {
        _beginthread(vUltraKill, 0, NULL);
        KillInfo.cSprees = "ULTRA KILL!";
        KillInfo.bIsInSpree = true;
        KillInfo.iLastSpree = 4;
    }
    else if(KillInfo.iTempKills == 5 && !KillInfo.bIsInSpree)
    {
        _beginthread(vMonsterKill, 0, NULL);
        KillInfo.cSprees = "MONSTER KILL!";
        KillInfo.bIsInSpree = true;
        KillInfo.iLastSpree = 5;
    }
    else if(KillInfo.iTempKills == 10 && !KillInfo.bIsInSpree)
    {
        _beginthread(vKillingSpree, 0, NULL);
        KillInfo.cSprees = "KILLING SPREE!";
        KillInfo.bIsInSpree = true;
        KillInfo.iLastSpree = 10;
    }
    else if(KillInfo.iLastSpree != KillInfo.iTempKills)
    {
        KillInfo.bIsInSpree = false;
    }
    else if(KillInfo.iTempKills < KillInfo.iDeaths && !KillInfo.bIsInLead)
    {
        _beginthread(vLostLead, 0, NULL);
        KillInfo.cSprees = "YOU'VE LOST THE LEAD!";
        KillInfo.bIsInLead = true;
    }
    else if(KillInfo.iTempKills > KillInfo.iDeaths && !KillInfo.bIsInLead)
    {
        _beginthread(vGainedLead, 0, NULL);
        KillInfo.cSprees = "YOU'VE GAINED THE LEAD";
        KillInfo.bIsInLead = true;
    }
    else if(KillInfo.iTempKills == 0 && KillInfo.iDeaths == 0)
    {
        KillInfo.bIsInLead = false;
    }
    sprintf(cKillStr, "Total Kills:%i, Current Kills:%i %s", KillInfo.iKills, KillInfo.iTempKills, KillInfo.cSprees);
    Draw.vDrawText(20, 36, cKillStr, colorWhite, qtrue, qtrue, 6, 12, 256);
}

Quake 3 clienthook: kill stat feature (counter + sounds ftw)

Name: Anonymous 2006-01-29 0:51

Yes, I know creating a new thread for each of my sounds is ineffecient, but I can't wait until I load my own media into the game.

Name: Anonymous 2006-01-30 10:33

>>110

Fuck ineffecient, that's frankly ugly.

Name: Anonymous 2006-01-30 17:06

$$ \frac{1}{N} \sum_i d(x_i, \frac{1}{N} \sum_j d(x_i, x_j)) $$

Name: Anonymous 2006-01-30 19:54

>>112
Whatever it is, it's a sick language

Name: Anonymous 2006-01-30 21:16

>>113
It's not language. It's death rattle.

Name: Anonymous 2006-01-30 21:40

>>113
it's TeX

Name: Anonymous 2006-02-01 12:49

>>115

Wtf is it 1971 already?

Name: Anonymous 2006-02-01 17:31

People who can't read/write LaTeX natively are worthless human beings.

Name: Anonymous 2006-02-01 17:54

>>118 is a worthless human being?

Name: Anonymous 2006-02-01 19:24

I had a totaly brainfart when I first started coding..

bool & BooleanToTrue(bool &*value)
{
   if(value == 0)
       value = 1;
   return value;
}

D:

Name: Anonymous 2006-02-01 23:05

>>119
what the fuck is &*?

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