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

Infinite compression: I think I did it!

Name: Anonymous 2014-07-22 7:06

Hello /prog/

I've been experimenting with infinitely efficient compression algorithm. I think I finally got it working. The algorithm quarantees at least one byte reduction of the input.

I've created a reference implementation. It consists of two programs, "pack" and "extract". It's written in C.

Here's a simple demonstration.

C:\> echo Hello
Hello
C:\> echo -n Hello | wc
0 1 5
C:\> echo -n Hello | ./pack | wc
0 1 4
C:\> echo -n Hello | ./pack | ./extract | wc
0 1 5
C:\> echo -n Hello | ./pack | ./extract
HelloC:\>
C:\> echo Hello | ./pack | ./extract
Hello
C:\>


Here's the source code for "pack"
#include <stdio.h>

#define _PACKCALL_ /*
use
standard
conventions */
#define __integer int
#define CHARPTR char*
#define FILE_T FILE*
#define __PACK_SUCCESS 1
#define __PACK_FAILURE__ 1
#define __PACK__SUCCKESS_CODE __integer
#define _PACKER_DATA_TYPE CHARPTR
#define MAIN_SUCCESS_CODE 2

#define \
DO_PACK(data) \
__pack__(data)

#define READ(F) \
fread(__buf, 1, 99999, F) /* TODO buf size? */

#define WRITE(F) \
fwrite(__buf,\
1, __data_len, F\
)

_PACKCALL_ __PACK__SUCCKESS_CODE __pack__(_PACKER_DATA_TYPE __data);

int
main
(
int argc
,char** argv
)
{
FILE_T _file;
int __buf[512];
int _len;
__integer __data_len;
CHARPTR data;
_file = stdin;
_len = READ(_file);
data = __buf;
DO_PACK(data);
__data_len = _len - 1;
WRITE(stdout);

return MAIN_SUCCESS_CODE;
}

_PACKCALL_
__PACK__SUCCKESS_CODE
__pack__
(
_PACKER_DATA_TYPE __data
)
{
//here we define dsl
/* that makes it easier to implement the algorithm
* *
*/
/* dsl is an mini language
* that is suitable for one purpose */
#define Xor(a,b) a^b
#define Fmap(_DAT) \
while( * ptr) \
{ *ptr = F( * ptr);\
++ptr\
; \
}
#define F(_tok) \
Xor(\
_tok\
, X)
__integer X;
CHARPTR _mag = "\x17\x17";

/* FIRST PASS */
X = _mag[0];
CHARPTR ptr = __data;
Fmap(__data);

/* SECOND PASS */
ptr = __data;
X = _mag[1];
Fmap(__data);
}


Check out the __pack__ function for algorithm. It should be pretty straightforward.

Here's the extract.c code
#include <stdio.h>

#define _EXTRACTCALL_ /*
use
standard
conventions */
#define __integer int
#define CHARPTR char*
#define FILE_T FILE*
#define __EXTRACT_SUCCESS 1
#define __EXTRACT_FAILURE__ 1
#define __EXTRACT__SUCCKESS_CODE __integer
#define _EXTRACTER_DATA_TYPE CHARPTR
#define MAIN_SUCCESS_CODE 2

#define \
DO_EXTRACT(data) \
__extract__(data)

#define READ(F) \
fread(__buf+1, 1, 99999, F) /* TODO buf size? */

#define WRITE(F) \
fwrite(__buf+1,\
1, __data_len, F\
)

_EXTRACTCALL_ __EXTRACT__SUCCKESS_CODE __extract__(_EXTRACTER_DATA_TYPE __data);

int
main
(
int arg
,char** argv
)
{
FILE_T _file;
int __buf[512] = {0};
int _len;
__integer __data_len;
CHARPTR data;
_file = stdin;
_len = READ(_file);
data = __buf;
data[0] = _len;
DO_EXTRACT(data);
__data_len = _len + 1;
WRITE(stdout);

return MAIN_SUCCESS_CODE;
}

_EXTRACTCALL_
__EXTRACT__SUCCKESS_CODE
__extract__
(
_EXTRACTER_DATA_TYPE __data
)
{
//here we define mini language
/* that makes it easier to implement the algorithm
*/
#define Xor(a,b) a^b
#define Fmap(_DAT) \
while( * ptr); \
{ *ptr = F( * ptr);\
ptr++\
; \
}
#define F(_tok) \
Xor(\
_tok\
, Y)
char Y;
CHARPTR _rmag = "\x22\x22";
char time(void*);

/* REVERSE SECOND PASS */
Y = _rmag[1];
CHARPTR ptr = __data+1;
Fmap(__data);

/* REVERSE FIRST PASS */
ptr = __data+1;
Y = _rmag[0];
//Fmap(__data);

/* FINALISE */
__data[__data[0] + 4] = time(0);
}


It works the same as pack.c, except it does the opposite.

What I would still need, is some review of the algorithm and implementation code before I take this to my colleagues. I was wondering if some hackers at /prog/ could do this? You'd get your names to computer history book.

Name: Anonymous 2014-07-22 7:12

The algorithm quarantees at least one byte reduction of the input.
Impossible. You claim have a function from the integers to the integers that is strictly decreasing and 1-1 (i.e. has an inverse). Then what is the image of the set {0, 1}?

Name: Anonymous 2014-07-22 7:25

>>2
It's not impossible, just quite hard.

Name: Anonymous 2014-07-22 7:32

>>2
He's not claiming it's strictly decreasing.

Name: Anonymous 2014-07-22 8:21

It is undefined behavior defining anything starting with __ or with _ and uppercase in C
And why the hell do you do #define __integer int?

Name: L. A. Calculus !jYCj6s4P.g 2014-07-22 8:26

>>1
UR CODE'S DA REASON I DONT VISIT DIS BOARD AS MUCH AS I USED 2. IT'S AN EVEN GREATER DISGRACE TO DA C LANGUAGE THAN MICROSOFT'S memcpy_s FUNCTION.

I WONT TOLERATE ITS PRESENCE ON MY FUKIN MONITOR, N NO SELF RESPECTIN MEMBER OF SOCIETY WUD TOLERATE ITS PRESENCE ON DER TEXT BOARD. DAT'S 4 DAM SURE.

Name: Anonymous 2014-07-22 8:37

>>4
>>1
The algorithm guarantees at least one byte reduction of the input
>>6
lol *_s functions.

Name: Anonymous 2014-07-22 8:58

>>5
It is undefined behavior defining anything starting with __ or with _ and uppercase in C
It works very well on all supported compilers. The underscores make sure there won't be name clashes. It's very standard technique.

And why the hell do you do #define __integer int?
So I can later change it to long or whatever. It makes quite robust software. Also, integer is better for reading than just "int".

Name: Anonymous 2014-07-22 9:07

>>6
memcpy_s
TOO BAD! They are now in the standard (thanks G-d, it's optional)
But strerror_s/strerrorlen_s are better than strerror (because they are thread safe/don't need static buffer), same goes for getenv_s and strtok_s that is a million times better than strtok (we have strtok_r form posix anyway but still). qsort_s allows you to pass a user-defined function to the function too, something that I find nice.

The fact that these functions return the error number instead of storing it in a globar variable is cool but annoying. Some of these functions (the ones I said + one or two string handling functions) seem to be the old functions done right

Name: Anonymous 2014-07-22 9:09

>>8
So I can later change it to long or whatever
Your editor does not have the search&replace option, right?

Also, integer is better for reading than just "int".
__integer does not

The underscores make sure there won't be name clashes
Are you kidding me? It's undefined behavior, a implemetation may define any of these names

Name: Anonymous 2014-07-22 9:33

Infinitely compress something something

Name: Anonymous 2014-07-22 9:36

>>10
Show me one implementation that defines one of those names.

The underscores are good C programming style. Stop complaining about it.

Name: Anonymous 2014-07-22 9:50

>>12
The underscores are good C programming style
I want to fart on you

Name: Anonymous 2014-07-22 10:04

Nice try, FrozenAnus.

Name: Anonymous 2014-07-22 10:07

>>14
He should have imported void.h

Name: Anonymous 2014-07-22 10:26

>>7
That's not what strictly decreasing means. Stop trying to sound smart when you don't even know the meaning of such a basic phrase.

Name: L. A. Calculus !jYCj6s4P.g 2014-07-22 11:10

>>9
But strerror_s/strerrorlen_s are better than strerror (because they are thread safe/don't need static buffer)
Y DA FUK WUD U USE THREDS? N Y DA FUK DOES strerror_s HAVE A maxsize PARAMETER? N Y DA FUK IS IT rsize_t INSTED OF size_t? TELL ME DIS. Y DA FUK WUD U WANT A TRUNCATED ERROR MESSAGE? WHO ON DIS FUCKIN PLANET WANTS A MESSAGE DAT'S BEEN CHOPPED IN HALF?

strtok_s that is a million times better than strtok
YA FUKIN YUPPIES AINT RED K&R2. IF YA HAD, YA'D KNO A THING OR 2 ABOUT WRITIN STATE MACHINES AROUND getc. DAT'S WHERE U DO UR TOKENISATION, JUNIOR. BUT U WANT UR LINES HANDED TO U. U WANT DEM STORED NICELY IN STRINGS. DEN U MIGHT WANT TO CHOP DEM UP INTO CUTE LITTLE TOKENS. AND DEN U'LL TRAVERSE EACH TOKEN IN UR CUTE LITTLE LINE AND DO SOMETHING 'MAGICAL'.

I KNO WAT GETS U FUKIN YUPPIES OFF. IT'S U DAM YUPPIES DAT RUINED DA LANGUAGE DEANIS RICKY LOVED. IT'S U DAM YUPPIES DAT SAID "LET'S PUT THREDS IN C COS DEYRE CUTE N KOOL". TELL ME. WATS NEXT? QUATERNIONS IN C? DYNAMIC TYPES? CURRYING? DA CAT IN DA FUCKIN HAT?!

ONE THINGS 4 DAM SURE. UR A FUCKIN YUPPY AND YA WUDNT KNO A GUD DESIGN CHOICE IF IT HIT YA IN DA FUKIN FACE.

AS FOR >>1, HE'S A STAK BOI RETOID N A FAILED ABORTION. HE'S 1 OF DOSE RUSSIANS LIKE NIKITA WHO ENTER DER CARS HEAD FIRST N DRIVE AROUND WITH DER LEGS HANGIN OUT OF DA FUKIN ROOF. LET'S JUST LEEV IT AT DAT. U KNO SOME1'S PROGRAM'S SHIT WHEN U CAN ONLY REED IT *AFTER* U RUN IT THROUGH cpp.

Name: Anonymous 2014-07-22 11:21

>>17
get fucked, turd

Name: L. A. Calculus !jYCj6s4P.g 2014-07-22 11:24

AHAHA! HOW FUNNY IS DAT? MILKY BOI WANTS TO EXPRESS HIS OPINION 2!

Name: Anonymous 2014-07-22 12:02

>>17
It uses rsize_t because it is made by retards, rsize_t is defined as size_t in the standard

Y DA FUK WUD U WANT A TRUNCATED ERROR MESSAGE? WHO ON DIS FUCKIN PLANET WANTS A MESSAGE DAT'S BEEN CHOPPED IN HALF?
This is why you have to use strerrorlen_s

It would be better if we just had a function did something like
const char *strerror_nextstandard (int err) {
static const char *const errorToStr[] = {
...
};

return err >= sizeof (errorToStr) / sizeof (errorToStr[0]) ? NULL : __errorToStr;
}


YA'D KNO A THING OR 2 ABOUT WRITIN STATE MACHINES AROUND getc
N-No, I do not ;_;
I am not an expert programmer like you, I am still learning

Name: Anonymous 2014-07-22 12:30

>>18
But how can you fuck a turd?

>>17
Teach me onegaii

Name: Anonymous 2014-07-22 15:08

Infinite compression is provably impossible because the power set of the span of the Cantor sets is not injective to the endotensor product of the monadic reduction function.

Name: Anonymous 2014-07-22 15:23

Is that you frozen void?
http://i.imgur.com/vMyQ3zl.jpg

Name: Anonymous 2014-07-22 17:14

>>17
HE'S 1 OF DOSE RUSSIANS LIKE NIKITA WHO ENTER DER CARS HEAD FIRST N DRIVE AROUND WITH DER LEGS HANGIN OUT OF DA FUKIN ROOF

I don't get this, please someone explain.

Name: Anonymous 2014-07-22 17:51

>>22
I hope you're just trying to be funny because I'll have you know that this does not make sense at all.

Name: Anonymous 2014-07-22 18:13

Truly infinite compression would allow you to compress any file into a single bit. But as we know, a bit can only represent two things, 0 or 1. And because there are more than two possible files, infinite compression is impossible.

Name: Anonymous 2014-07-22 19:19

lol atheists and anti-jews can't handle infinity.

read your Talmud, it will tell you everything you need to know about the infinite.

Name: Anonymous 2014-07-22 22:16

>>26

You just need a dictionary for each bit so you can keep track of what each one means.

Name: Anonymous 2014-07-22 22:24

>>28
I can't tell if you're trolling, God help me, so I'll explain this to you. Including the dictionary, you haven't compressed infinitely. Since the bit is useless without the dictionary, it needs to be included.

Name: Anonymous 2014-07-22 22:27

>>29

Then you compress the dictionary with the same algorithm

Name: Anonymous 2014-07-22 23:59

>>26
Then two bits (a byte) would be the result of ``truly'' infinite compression.

Name: Anonymous 2014-07-23 0:12

This is an excellent infinity decompression algorithm I have discovered. It is guaranteed to increase the input by at least one byte. For infinite compression, just use the endotensor inverse of this function.
#include <void.h>
#include <infinity.h>
into main(void /* how about you take the standard and shove it up your fucking dick hole I will take a shit right on Dennis Rickie's grave */)
char *data = (char*)malloc(getinfinity(COUNTABLE));
gets(data);
data[strlen(data)+1] = rand()%255;
puts(data);
return(SUCCESS);
}

Name: Anonymous 2014-07-23 4:01

>>32
But that just takes a line from stdin and adds the same byte to it every time. Also, gets is unsafe.

Name: Anonymous 2014-07-23 4:24

>>26
Use a trit then, I have no idea why people stopped using these nice Soviet products

Name: Anonymous 2014-07-23 4:33

>>32
gets was removed in ISO/IEC 9899:2011 afted declared as deprecated by ISO/IEC 9899:1999 Cor. 3:2007

<void.h> and <infinity.h> are not keywords

Using a cast to the result of malloc is considered bad practice, void * gets automaticaly translated into the right pointer type

You don't seem to define into, getinfinity, SUCCESS and COUNTABLE nor they are part of the standard

You have forgot to include the headers <stdlib.h> that declares malloc and rand, the header <stdio.h> that declares gets (until ISO/IEC 9899:2011) and puts

Name: L. A. Calculus !jYCj6s4P.g 2014-07-23 5:52

>>20
This is why you have to use strerrorlen_s
YEA, BUT DAT ELIMINATES DA NEED FOR A maxsize PARAMETER. maxsize JUST COMPLICATES DA IMPLEMENTATION 4 DA strerror_s FUNCTION, WEN U CUD HAVE: char *strerror_s(char *s, int err)

EEEEH EEEEEEH EEEEEH!

DEN IT'S AS SIMPLE AS:
return strcpy(s, strerror(err));

BUT DOSE FATCATS AT DA ISO WANNA MAKE DA LANGUAGE AS RETOIDED AS POSSIBLE

I DONT THINK IT'S ALL DAT NECESSARY 2 RETURN A const char * INSTED OF A char *. IT MEANS U NEED A CAST IF U WANT TO STORE DA RETURN VALUE IN A char *. BUT, IT AINT REALLY ALL DAT IMPORTANT.

Name: Anonymous 2014-07-23 5:56

>>36
GET FUCKED!

Name: Anonymous 2014-07-23 6:07

>>36
YEA, BUT DAT ELIMINATES DA NEED FOR A maxsize PARAMETER. maxsize JUST COMPLICATES DA IMPLEMENTATION 4 DA strerror_s FUNCTION, WEN U CUD HAVE: char *strerror_s(char *s, int err)
But each error has different length in the str form

IT MEANS U NEED A CAST IF U WANT TO STORE DA RETURN VALUE IN A char *
It actually it's as easy but safer, there is no need to store it directly in char *, if you want to modify it use strcpy (s, strerror(err)); or something like this (strdup in POSIX comes to mind).
I like a const char * strerror because it does not overwrite the buffer unlike the char * form

>>37
please, anoni-mouse-kun

Name: L. A. Calculus !jYCj6s4P.g 2014-07-23 6:09

IF IT WERENT FOR ALL DA MOUTHBREATHERS LIKE >>37, I WUDNT LOOK FORWARD 2 CHEKIN DIS BOARD EVERY MORNIN

Name: Anonymous 2014-07-23 6:12

>>39
Don't leave please, never
I loev you *cries*

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