int kod(int *cnts, int i, int *j, int *k, int nsyms) { int r; if(*k > nsyms || i > *j && cnts[*j] < cnts[*k]) { r = cnts[*j]; cnts[(*j)++] = i; } else r = cnts[(*k)++]; return r; }
int huff(int *cnts, int nsyms) { int i = 0, j = 0, k = 0; for(i=0;i<nsyms-1;i++) cnts[i] = kod(cnts, i, &j, &k, nsyms) + kod(cnts, i, &j, &k, nsyms); cnts[i] = 2; j = i-1; k = j; while(k) { while(j > 0 && cnts[j-1] >= k) j--; cnts[i--] -= k - j; cnts[i] = (k - j)*2; k = j; } return nsyms - i; }
Thank you new admin, now I can browse /prog/ again. I love you. What's with the code tags however not keeping the spaces? x (0 spaces) x (1 space) x (2 spaces) x (3 spaces)
...but apparently, not when you're a Java programmer. Look at BIT_POS_MASKS and readBit(). :facepalm:
Name:
Anonymous2017-07-14 6:27
>>1 why does your function take a pointer to cunts?
Name:
Anonymous2017-07-16 1:43
>>1 Why are your variable names so compressed? Also I thought you were joking when you said you use 1 space indentation... You know almost no one does this, right?
Name:
Anonymous2017-07-16 2:28
>>26 Frozenvoid does it too Or I think he just leaves it all on one line
Name:
Cudder !cXCudderUE2017-07-16 3:16
>>26 You're supposed to focus on the structure, not the names. This is meant to be the complete opposite of the ENTERPRISE BULLSHITE tiringly verbose tripe that gets churned out in bulk by clueless codemonkeys (like >>24) which says a lot without doing much.
One space is sufficient. No "partial" indents (a line is always in one indent level), all the size advantages of tabs combined with the fixed-width-ness of spaces, easy to see the level without multiplying or dividing.
Name:
Anonymous2017-07-16 3:38
>>27 I don't indent code and find the idea ridiculous, but sometimes use editors which add "indentation level"(which i don't fix).
>>31 I don't write pretty novels. I'm not a code artisan. I don't need a style guide. I don't need your rules about indentation. All this superfluous mental garbage(tabs vs spaces, one true brace, the right font) is a distraction from actual programming.
>>32 You don't need people reading your crap either.
Name:
Anonymous2017-07-16 16:26
Indentation is nothing but an instrument of code oppression created by the so-called ``code artisans'', who believe that the importance of code is determined by their level of indentation. Break your code free from the oppression of the patriarchic code artisans, comrades! Programmers of the world, unite and stop indenting! All lines of code are equal!
>>40 I don't see how that's going to fix capitalism.
Name:
Anonymous2017-07-17 6:36
I don't see how that's going to implement diff
Name:
Anonymous2017-07-17 7:06
>>32 I don't think you understand the purpose of indentation very well. You might think it's meaningless and have learned to get used to it, but at a glance, looking at your code to find something and identify structures becomes difficult. Then when others start reading your code they too will find it very hard to read compared to others' code.
Sure they can run ident(1), but are there really many notable benefits to foregoing indentation? All I can think of is saving file size, but that's a poor argument. Formatting your code should be an effortless part on yourself, and doesn't require you to be a ``code artisan'' to accomplish. Just think of how many people who looked at your code for 5 seconds and in the end just thought you are an amateur Apper without analyzing your techniques indepth.
So don't think it will only affect you. With almost all code people see being well formatted, it's hard to think they'll be ok with formatting some guy's code themselves just because he is kinda narcissistic.
>>43 Benefits of not joining the indentation cult: 1.Lower file sizes 2.More data fits on one screen "The visual field is a scarce UI commodity" 3.Code doesn't get mangled due text filters and processing(indented code like python suffers from it well). 4.Its faster to read: Reading indented code requires more scrolling and mental processing(comparing visual indentation with logical structure). 5.Its faster to write: Without superficial indentation rules and policies, code writing naturally flows at the speed of typing out mental concepts(aids "Flow state"). No spacing, no indentation, no distraction: focus is always on code and not the aesthetic form it takes. 6.Its easier to debug: Indented code error bring little context, often only a single statement. Non-indented code errors show up as blocks of code. 7.Its terse structure allow to keep more of code in mind at the same time:with indented code you can't see it all due #2
>>46 it's FV, what did you expect? he doesn't work on anything big and complex, he's just experimenting with pre-processor macros for fun. you don't need indentation to hack together an apply macro therefore it's useless for FV. the same goes for version control.
Name:
Anonymous2017-07-17 9:58
>>45 Consider the following: An excerpt of anoncoreutils, with indentation modified to mimic your ``Apping'' style. Can you understand how it works and what it does in 10 seconds?
>>63 C macros is only one of my interests. They're probably well known because i like to showcase theoretical stuff from the void.h/void2 headers. I don't actually write programs composed from macros, unless its a demo thing.
>>65 Well. Its partially correct. I don't write "programs" i write apps or utilities. Writing big projects and committing to support them isn't for me. I prefer to use my time rationally, not being an open source code monkey. see http://void.wikidot.com/effort-reward-curve
Name:
Anonymous2017-07-18 1:10
Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.
Name:
Anonymous2017-07-18 10:45
>>66 then stop shitting on things that help immensely when writing big programs.
Name:
Anonymous2017-07-18 13:57
>>68 >big programs 1./prog/riders didn't write anything big(20K+ line of code) 2.Big programs are usually split into small modules. 3.The only case where this could be useful is some huge file like sqlite source amalgamation(which is never edited manually).
Name:
Anonymous2017-07-18 14:23
>>69 Big programs are anything above 15 lines, thanks
Name:
Anonymous2017-07-18 14:27
Never argue with stupid people, they will drag you down to their level and then beat you with experience.
Name:
Anonymous2017-07-18 15:05
>>70 log10(LOC) Type 9+ Enterprise-Class 8-9 Enormous 7-8 Gigantic 6-7 Huge 5-6 Large 4-5 Medium 3-4 Small 2-3 Tiny 1-2 Extra Tiny
Name:
Anonymous2017-07-18 15:14
>>60 Needs to be replaced by emoji and APL will become popular overnight.
>It's estimated that there are 111 billion lines of new software code generated by developers every year, If they didn't indent the number would be much smaller.
Start (a line of text) or position (a block of text) further from the margin than the main part of the text. ``type a paragraph of text and indent the first line''
synonyms: move to the right, move further from the margin, start in from the margin. ``the first line of a paragraph is indented by using the tab key''