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

Random cool shit you made thread.

Name: Anonymous 2008-06-04 10:39

GO!

Name: Anonymous 2008-06-04 19:49

>>40
So you tried to make it stupid and instead made it wrong?

>>36
Why do you ask the user for something that doesn't exist?

Name: Anonymous 2008-06-04 19:54

>>36

details, plzkthx

Name: Anonymous 2008-06-04 20:33

Why do you ask the user for something that doesn't exist?
http://developers.sun.com/sunstudio/documentation/ss12/mr/READMEs/c.html#about

also, gcc claims to support C99 (defines __STD_C_VERSION__ with the value 199901L) if you use the -std=c99 option, even though it's support of the standard is incomplete.

>>42
sorts an array of uintmax_t values in O(n) time.

Name: Anonymous 2008-06-04 22:15

Name: Anonymous 2008-06-04 23:52

>>38
Maybe he was writing a calc.exe replacement.

Name: Anonymous 2008-06-05 3:23

crash :: IO ()
crash = print $ reverse [1..]

Name: Anonymous 2008-06-05 4:55

>>43
sorts an array of uintmax_t values in O(n) time.
Does not.

Name: Anonymous 2008-06-05 5:23

Random gibberish generator:

from random import choice
def randsent(x,f):
        pbal='bcdfghjklmnpqrstvwxyz'
        bal='aeiou'
    l=['110','10']
    c=[]
    z=''
    for i in range(x):
        for y in range(randint(1,f)):
            q=choice(l)
            for i in q:
                if i=='0':
                    z+=choice(bal)
                else:
                    z+=choice(pbal)
        if i==0:
            z.capitalize()
        c.append(z)
        z=''
    r=' '.join(c)
    return r+'.'


Horrible,I know-I'm a beginner.

Name: Anonymous 2008-06-05 5:30

ITT, useless toy programs

Name: Anonymous 2008-06-05 5:31

>>47
Does too.

Name: Anonymous 2008-06-05 8:34

>>50
gb2/computational theory class.

You can't sort in O(n) time, but you can tune a filesystem.

Name: Anonymous 2008-06-05 9:06

Radix sort is O(nk), with k being the average key length. So with keys of a constant length, it's O(n). Of course, now you don't have a generic sorting algorithm anymore.

Name: Anonymous 2008-06-06 2:07

>>11
>>12
>>20
>>23

lern2gammafunction, faggots

>>52

That was >>51's point, php-for-brains

Name: Anonymous 2008-06-06 2:38

>>53
>>51's point in saying that you can't sort in O(n) time was that you can sort in O(n)?

Name: Anonymous 2008-06-06 4:33

>>54
good point.

Name: Anonymous 2008-06-06 11:36

>>55
It may surprise you to hear this, but that is actually my point.

Name: Anonymous 2008-06-06 15:51

>>52
I can sort a set of 5 elements in O(1) time, what's your point?

Name: Anonymous 2008-06-06 19:12

>>57
My point is no you can't.

Name: Anonymous 2008-06-06 19:13

somewhat functional generate random programs from a BNF grammar:


#!/usr/bin/perl -w

if(!defined($ARGV[0])) {
  print "usage gen.pl <grammar file>\n";
  exit 1;
}

open(GRAMMAR, "<", $ARGV[0])
or die "cant read from file: $ARGV[0]";

$startsymbol = <GRAMMAR>;
chomp($startsymbol);
print "ss: $startsymbol \n";

while(<GRAMMAR>) {
  $rule = $_;
  chomp($rule);

  # parse the rule
  @halves = split('::=', $rule);
  $nonterm = $halves[0];

  # ignore comments
  next if $nonterm =~ /^#.*/;
  @rules = split('\|', $halves[1]);

  # store nonterminal and possible
  # decendents in hash
  $cfg{$nonterm} = [@rules];
}

close(GRAMMAR);

# print rules
for $k (sort keys %cfg) {
  print "$k ::= ";
  for $r (@{$cfg{$k}}) {
    print "\t$r |";
  }
  print "\n";
}

for($l=0; $l<10; $l++) {
  print &randstring($startsymbol, 10) . "\n" ;
}

sub randstring {
  my ($s,$d) = (@_);
  my $c = "";
  my $r = "";
  my $done = 1;

  for($i=0; $i<length($s); $i++) {
    $c = substr($s, $i, 1);
    if(&inkeys($c)) {
      $done = 0;
      $r = &randrule($c);
      substr($s, $i, 1, $r);
    }
  }
  if($done or $d == 0) {
    return $s;
  } else {
    return &randstring($s, $d-1);
  }
}

sub inkeys {
  my $k = pop(@_);

  for $key (keys %cfg) {
    if($key eq $k) {
      return 1;
    }
  }
  return 0;
}

sub randrule {
  my $k = pop(@_);
  my @rules = @{$cfg{$k}};

  return $rules[&boundedrand(0, scalar @rules-1)];
}

sub boundedrand {
  my $final = pop(@_);
  my $init = pop(@_);
  return int((rand() * ($final - $init) + $init) + .5);
}

sub binrand {
  return int(rand() + .5)
}


an example grammar for brainfuck with start symbol first


E
E::=EF|F
F::=+|-|>|<|.|,|[E]

Name: Anonymous 2008-06-07 2:20

sub inkeys {
  my $k = pop(@_);

  for $key (keys %cfg) {
    if($key eq $k) {
      return 1;
    }
  }
  return 0;
}


HAHAHA, OH WOW

BECAUSE defined $cfg{$k} WOULD BE TOO SIMPLE

Name: Anonymous 2008-06-07 3:06

>>46
That is a surprisingly elegant way to eat up a shit load of memory.

Name: Anonymous 2008-06-07 3:06

>>52
>>54

I believe you mentioned something about "Generic" sorting algorithms. Faggot.

Name: Anonymous 2008-06-07 3:28

This is how I would have done it:
#!/usr/bin/perl

use strict;
use warnings;

my %cfg;
my @symbols;
my $startsymbol;

print "usage gen.pl <grammar file>\n" and exit 1
    unless defined $ARGV[0];

# read grammar file
open GRAMMAR,"<",$ARGV[0] or die "$ARGV[0] - $!";
while(<GRAMMAR>){
    next if /^#/ or /^\s*$/;
    chomp($_);
   
    # first line is startsymbol
    $startsymbol=$_ and next unless $startsymbol;

    # other lines are rules
    my($nonterm,$v)=/(.*?)::=(.*)/ or die "$ARGV[0]: line $.: expected ``::=''\n";
   
    # store in hash for lightning fast access!
    $cfg{$nonterm}=[split /\|/,$v];
   
    # but order is important too so store in array as well
    push @symbols,$nonterm;
}
close(GRAMMAR);

my $sym_reg=join "|",@symbols;

# print rules
print map{
    join "",$_,"::=",(join "|",@{$cfg{$_}}),"\n"
} @symbols;

# print 10 results
print join "%%\n","",map{
    randstring($startsymbol,100)."\n"
} 1..10;

sub randstring{
    my($str,$level)=@_;
   
    while(--$level>0){
        my $done=1;
       
        $str=join "",map{
            if(defined $cfg{$_}){
                $done=0;
               
                randrule($_)
            } else{
                $_
            }
        } $str=~/$sym_reg|./go;
       
        last if $done;
    }
   
    warn "deep recursion when parsing $str\n" unless $level;
   
    $str
}

sub randrule{
    my @rules=@{$cfg{+shift}};
   
    $rules[rand @rules]
}


And here is the new improved grammar for generating fabulous lisp code:
#first line can be comment too

LISP
LISP::=(car LIST)|(cdr LIST)
LIST::=SUBLIST LIST|SUBLIST|SUBLIST
SUBLIST::=LISP|<NUMBER>
<NUMBER>::=<SDIGIT><ZNUMBER>|<SDIGIT><DIGIT>|<DIGIT>
<ZNUMBER>::=<DIGIT><ZNUMBER>|<DIGIT><DIGIT>|<DIGIT>
<SDIGIT>::=1|2|3|4|5|6|7|8|9
<DIGIT>::=0|<SDIGIT>

Name: Anonymous 2008-06-07 8:11

#include <limits.h>
#define ISQRT(n)\
  ({ __typeof__(n) r = 0, _n = (n), i = 1;\
  i = i << ((sizeof(i) * CHAR_BIT - (0 > ~i ? 2 : 1)) / 2) * 2;\
  if(0 > _n) _n = -n;\
  for(; i; i >>= 2)\
    if(_n >= (i | r)) {\
      _n -= i | r;\
      r = r >> 1 | i;\
    } else r >>= 1;\
  r; })

Name: Anonymous 2008-06-07 8:22

>>62
Exactly. And >>43, who >>51 was arguing against, didn't claim that his was a generic sort algorithm.

Ergo, your wrong, bitch.

Name: Anonymous 2008-06-07 8:28

printf("hello world\n");

Name: Anonymous 2008-06-07 14:11

>>64
__typeof__
__FIOC__

Name: Anonymous 2008-06-07 14:16

"""__FIOC__"""

Name: Anonymous 2008-06-07 14:49

>>68
This may surprise you, but """__FIOC__""" is a valid c string.

Name: Anonymous 2008-06-07 15:01


10  INPUT">";P$
20  FOR I=1 TO LEN(P$)
30  I$=MID$(P$,I,1)
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  REMARKABLE

Name: Anonymous 2008-06-07 15:18

>>69
But '''__FIOC__''' is not.

>>70
PLEASE NEXT I

Name: Anonymous 2008-06-07 19:33

‷⚋ℱⅈℴℂ⚋‴
‷⚋ℱⅈℴℂ⚋‴
‷⚋ℱⅈℴℂ⚋‴
‷⚋ℱⅈℴℂ⚋‴

Name: Anonymous 2008-06-07 23:46

#define car cdr
#define cdr car

int main(void) {
  printf("%s", (car (1 2 3)));
  return 0;
}

Name: Anonymous 2008-06-07 23:55

>>7
>fact 0 = 1
>FACT: 0 EQUALS 1

Name: Anonymous 2008-06-08 11:59

>>74
go back to /jp/, please

Name: Anonymous 2008-06-09 21:16

pantsu~

Name: Anonymous 2009-09-17 15:19

Lain.

Name: Sgt.Kabukiman껤㨡 2012-05-23 15:06

All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy

Name: bampu pantsu 2012-05-29 3:42

bampu pantsu

Name: 2013-01-25 18:13

饐鉹䁣㙕ᅢጁ䅀锠䂖‵陡ᔘև䑴挹䉈㡡䈲昑㔱剩砷莑㡆֒熆鉀␶啴␇䚖犓ܥ䑹ᤵᤆⅢ䘲餈鐐葧㙆餓䖇ŐŤ戇唩␉ᔓ甙ᐄȠ䚃Ωᄅܳ㑤扆ࠣ虠楡摖偹脄℣ऑ螒兢ↀƐ㘓蘙գ㝁ु枔፶ᐤ䂄閂㈦ᆄ㠦ᔁ唸劓耩䁂ᔵ薘−䎙撃উ☘倔㑁蘗䂕ስ遐妁━顖茨ᆈ眐ㄲ㢕㡐鄣愉隆瑹傉™ህ吰鐂㞑آ牃战㕈㦘г林馅蠆㕘䑆ㅷ䙤偓椴⑴假䘐⡧塖㜁ᥣ⥣鎗✖蜕㍩䈂ᝇ撆妅မ灆饘᥶茄阅焲睰䥙䄀ƒ遑䕹Ő當٥牶莆ᐇ✠ᙡ⁒ၒ✔ѳ腈餈肃剦喙偣祂奱䤱銙堲癖颗隁㉕晡銓⠵霸Ѷ呀鈅㔑ƈ艳茲⡤堒ć獗㐐䝸荴艹ѳ℧㐄ĥ㈉㐴ᑲℰ㌠͆सॄ昱猲獶馘霘䠗㎓爤㤡䡖㉀ᄃ茧ᄙ兑圅㌃✦䘖傈‐鐡㔩虗蜗愕☩⍓䚆ȵ㑷ᥩ午㡉㥹ա❣匵ᝅ獶抑ޅ畨昐䉔࢐ᜨ⡕腧衒䁤唨莁癱摉搩晳睒礀物V剸鉇͖㚗昁࢑阣掐琩䁕ᠸ褩味⚃⥧匄┹ᒀ逅襘㚗逐ၐ栤ᠠ挒餆錑吘ख़肄冑❠ޓᝒᘁ॒㌨鐆P衰噇霈㦆┒㈓⍀呅㤧䝔荤褒㍒䎐≁圢唦呹蕷ᚔ錕遐ᔆ䘢ᄸQ⥆镢ᐐ鐩㔳၃撁襴܃捣⡂遈阄脇剩❘Δ搤兑䚂腃䡨ܹ䚔؄጗材项❉薐㌠虘煶㖆䜒࠰晵࠘照㙲邕⑉电塗摙⠉ၡ䁆է瀀戕瘳䎐㔙㕰备ᔨ锲夈瑲䍧閖ᖁ焃ᚖ㒀垖醖璗瞁㢑鉷䠦脥挃⍉堵㦀㘐炕⚔ނ⎄爸唷★㐐茇堣餵奲鑳邙舴聰剴脨㕠ᅰ䢔爹䘐ᝑ啅眶榙煐䌦朗ᙈ舩愡†电ဳ硸垉椦Ź儘儨匑䁰ℵ妈挖∈᝙⥲掐䔢昢⎆㑄逧⍅焐Յ⠤蜥興偙鐳唗攄蔣搙ᙆ

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