(defun rle (str) ;run length encoding (let ((i 0) c count out) (while (< i (length str)) (if (eq c (elt str i)) (setq count (1+ count)) (when c (setq out (append out (list (cons c count))))) (setq c (elt str i)) (setq count 1)) (setq i (1+ i))) (when c (setq out (append out (list (cons c count))))) out))
(defun pcx-rle-line (o s e) (while (< (cdr s) e) (let ((v (% s)) (c 1)) (while (and (< (cdr s) e) (= (% 0 s) v) (< c 63)) (% s) (incf c)) (unless (and (= c 1) (/= (logand #xC0 v) #xC0)) (ser o (Count 1 (logior #xC0 c)))) (ser o (Value 1 v)))))
(defun pcx-derle-line (o s e) (while (< (cdr o) e) (let ((c (% s))) (if (/= (logand c #xC0) #xC0) (% o c) (let ((c (logxor c #xC0)) (v (% s))) (while (plusp c) (% o v) (decf c)))))))
Name:
Anonymous2014-10-05 8:59
rle :: (Eq a, Num b) => [a] -> [(b,a)] rle [] = [] rle (x:xs) = encode' 1 x xs where encode' n x [] = [(n,x)] encode' n x (y:ys) | x == y = encode' (n+1) x ys | otherwise = (n,x) : encode' 1 y ys
>>2 how would you improve my code? for one, it is inefficient because it continually checks the boundary case where there is no previous (character . count).
Name:
Anonymous2014-10-05 14:59
>>4 Nobody understands me. Can't even find a girlfriend.
forgot code tag (defun rle (str) ;run length encoding (let ((i 0) c count out) (while (< i (length str)) (if (eq c (elt str i)) (setq count (1+ count)) (when c (setq out (append out (list (cons c count))))) (setq c (elt str i)) (setq count 1)) (setq i (1+ i))) (when c (setq out (append out (list (cons c count))))) out))
I just found a recursive sine(x) function and it seems really easy =)
Name:
Anonymous2014-10-06 23:17
And i think i found a new structure too =D Think i'll call it the Binary Mesh =)
Name:
Anonymous2014-10-06 23:47
binary tree search mode start with 0 / 90 degree vectors at radius 1 (0,1) / (1,0) find center (0.5, 0.5) and scale to radius 1.. z*(0.5, 0.5) where z = 1 / sqrt(2*0.5^2).. = 45 degree vector
Name:
Anonymous2014-10-07 0:07
mesh because it can start at any two angle vectors / nodes eg angle 30 + angle 45 -> angle 37.5
/* Run-length encodes data, returning the malloc-allocated buffer in ebytes and its size in esize. */ void rle(u8 *ubytes, size_t usize, u8 **ebytes, size_t *esize) { // rle can double the input size in the worst case u8 *eb = malloc(usize * 2); size_t ui = 0; size_t ei = 0; u8 byte, count;
/* Decompresses run-length encoded data, returning the data in ubytes and its size in usize */ void unrle(u8 *ebytes, size_t esize, u8 **ubytes, size_t *usize) { // unrle can expand the input 256-fold in the best case u8 *ub = malloc(esize * 256); size_t ei, ui; u8 count, byte; for (ei = 0, ui = 0; ei < esize;) { count = ebytes[ei++]; byte = ebytes[ei++]; for (int i = 0; i <= count; i++) ub[ui++] = byte; }
I'm not sure what you mean, but I was trying to mock _t typenames there.
Name:
Anonymous2014-10-09 22:10
>>58 Names that end with '_t' are reserved in POSIX.
Name:
L. A. Calculus!jYCj6s4P.g2014-10-11 20:22
>>50,54 SUM1 TAKE DA TEXT EDITOR OFF DIS STACK BOI RETOID ASA-FUCKIN-P, B4 HE WRITES MORE SHIT.
DID FUCKIN MOSKITO FIND HIS WAY ONTO DIS BORD OR SUMTHIN? ITS DA KIND OF SHIT ID EXPECT HIM 2 WRITE CONSIDERIN DEY'RE BOTH 2 RETOIDED 2 CHEK DA RETOIN VALUE OF malloc.
Name:
L. A. Calculus!jYCj6s4P.g2014-10-11 20:26
N LAST I CHEKKED COMPRESSION ALGORITHMS WERE SUPPOSED 2 MAKE THINGS SMALLER, NOT LARGER. DA OUTPUT OF UR PROGRAM IS NEARLY TWICE DA SIZE OF DA INPUT WEN RUN ON UR SOURCE FILE.
>>60 Why bother checking the return value of malloc? If you're out of virtual memory, you might as well crash anyway, which the proceeding null pointer dereference will do for you. Half the point of UNIX was that it crashed quickly on error instead of trying to handle every silly error condition and bloating the fuck out of the code for little gain.
>>61 No shit, run-length encoding doesn't perform well on text files. Doooo yoouuuuu seeeee annyyyyy runnns offf characterrrrsss in regularrrr text?
Half the point of UNIX was that it crashed quickly on error instead of trying to handle every silly error condition and bloating the fuck out of the code for little gain.
Stupid then, stupid now.
That's why they are called ``hackers'' and not Professional Engineers.
If you're out of virtual memory, you might as well crash anyway, which the proceeding null pointer dereference will do for you.
WAT DA FUK R U BABBLING ABOUT W/ UR VIRTUAL MEMORY SHIT? IF malloc CANT GIVE U MORE MEMORY IT'LL LET U KNO. HOW FUKIN HARD IS IT TO WRITE A WRAPPER AROUND malloc DAT PRINTS SOMETHING 2 stderr N EXITS PROPERLY?
UR LAZY, YAINT RED DA STANDARD, N IF YA WERENT A FUCKIN STAK BOI RETOID U WUDN'T EVEN NEED malloc IN UR PROGRAM.
No shit, run-length encoding doesn't perform well on text files.
EVEN DA BINARY PRODUCED BY MY COMPILER, FROM UR DISGUSTING SOURCE CODE, IS MORE BLOATED WEN 'COMPRESSED'. UR PROGRAM'S A FUCKIN DISGRACE. THROW UR FUCKIN TEXT EDITOR AWAY N DEAL WITH IT YA IRRESPONSIBLE DEESHBAG
Doooo yoouuuuu seeeee annyyyyy runnns offf characterrrrsss in regularrrr text?
UR SOURCE FILE SURE AS FUK HAS MULTIPLE COUNTS OF ' ' CHARACTERS DAT CUD HAV BEEN COMPRESSED PROPERLY.
IF U MANAGE TO GET UR PROGRAM TO COMPRESS A FILE U'D ACTUALLY WANT TO COMPRESS, LET ME KNO.
Name:
Anonymous2014-10-11 23:00
>>62 I love him more. He is my hero, not even kidding.
>>63 L.A. is one of the best (if not the best) programmers I know, just like R.. from stack overflow, if he does it then it must be right, I know it. R.. and L.A. are against the silent crashing of your programs, see http://stackoverflow.com/a/17448240 What you are doing is glib-gnome-redhat-dbus ENTERPRISE quality.
Half the point of UNIX was that it crashed quickly on error instead of trying to handle every silly error condition
But this is wrong you turd.
>>65 There are much better ways to write it, it's like you fucked it up on purpose also only a retard would exit if the allocation failed on a non-critical operation and without saving the data, anyway, cool seeing windows supporting your own allocators.
Name:
Anonymous2014-10-11 23:10
I remember a encoding that just used some kind of linked lists to show the next possition of compressed data, if it could not compress it good enough it would just ignore it. In the worst case you would have extra bytes equal to the size of the pointer used (no more than 2 bytes usualy, that's how much a DEFLATE chunk would need)
HOW FUKIN HARD IS IT TO WRITE A WRAPPER AROUND malloc DAT PRINTS SOMETHING 2 stderr N EXITS PROPERLY?
What's the point when you can just attach a debugger and see where it segfaults?
UR SOURCE FILE SURE AS FUK HAS MULTIPLE COUNTS OF ' ' CHARACTERS DAT CUD HAV BEEN COMPRESSED PROPERLY.
Please tell me you realize that this is a thread about toy run length encoding implementations. The algorithm is set in stone, no one cares about how efficient it is, we're just writing examples for shits and giggles.
I'm pretty sure you can dig up a Dennis Ritchie quote somewhere about how a big part of why UNIX succeeded was that it just crashed loudly and dumped on serious errors whereas MULTICS had a complicated error handling system that considerably slowed down development and didn't do much in practice.
also only a retard would exit if the allocation failed on a non-critical operation and without saving the data
That is fair but this is not an enterprise Windows desktop line of business visual basic GUI workstation application, it's a fucking toy dozen-liner RLE function for a /prog/ thread. I thought you retards could mentally insert the boilerplate malloc checking bullshit if it really bothers you that much but I guess that was too much to expect.
The CIA kinda misleads OSdev visitors. Some of it is "get these kids to fail fast and give-up, while having their fun". Brendan will tell them how important any real operating system must have a power-down feature. He talks about shit he, himself, hasn't actually done, but it's the right way to do it. You definitely have to plan for multiple display monitors. "Any modern operating system has to support multiple displays." He tells them how to do... NUMA? There's a long boring shallow fluff spec that tells actually multichip systems with multicores each. Brendan likes to set them straight giving them an overview how how to do that. They defineitly want mutli chips, not just mutlicores, for a respectable system.
He is starting to make sense. Independent OS is good due resistance to backdoors and couldn't be easily analyzed by law enforcement and CIA.