[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y / ] [Home]
4chanarchives logo

ITT We show off shitty code that we've made, I'll start with mine in pic related


Thread replies: 312
Thread images: 59

File: shitcode.png (21KB, 990x487px) Image search: [Google] [Yandex] [Bing]
shitcode.png
21KB, 990x487px
ITT We show off shitty code that we've made, I'll start with mine in pic related
>>
>>54508959
>shitty
You sure got that right.
>>
File: index[1].jpg (7KB, 280x180px) Image search: [Google] [Yandex] [Bing]
index[1].jpg
7KB, 280x180px
did you just write a fucking goto statement in c#

you should actually be banned for this
>>
Oh boy I know this kind of code, just started computing classes huh, learning about colours and threading
>>
>>54508998
>goto is bad maymay
How to spot a shit programmer 101.
>>
>>54508998
You do realize that goto is pretty common even in C right? Goto is literally a carry over from a function in assembly.
>>
File: wew.png (263KB, 1946x1308px) Image search: [Google] [Yandex] [Bing]
wew.png
263KB, 1946x1308px
>>54508959
r8 my code
>>
>>54509015
>Non English
>Shitty Apple meme-lang
0/10
>>
>>54509015
Is that Swift? What is this supposed to do?
>>
>>54509024
> 0/10
Thanks anon! I will try improving my skills.
>>
File: 112737474794964.jpg (93KB, 802x842px) Image search: [Google] [Yandex] [Bing]
112737474794964.jpg
93KB, 802x842px
>>54509028
> is that Swift?
yes
> What is this supposed to do?
solves a mathematical expression and returns the final result as a string.
>>
>>54509015
>9 lines of actual code
>41 lines
It's like you're trying to meet LoC quotas or something.
>>
>>54508959
>using
Console.

>not using a switch statement
>not finding an excuse to use glorious LINQ
>>
>>54509014
>pretty common even in C
That doesn't mean it's right. Also in C is mainly used for error handling to free resources, as C lacks automatic memory management, exception handling and statements like 'using'. So literally no need to use it in C# or other languages besides being a shitty programmer.
>>
>>54509014
>>54509009

Any use of goto can be rewritten without it, its a very lazy habit that easily makes code unmaintainable and would get you fired instantly. If you ever actually made anything over 50 lines long you would soon realise how using goto will fuck you over, especially in a language like c#...
>>
>>54509078
>ermagerd you can write it without goto
>ermagerd it's lazy for some reason
>ermagerd when I used it I ended up with spaghetti code ?!?/1/1/
Kill yourself desu.
>>
>>54509065
> he counted all the lines
autism status = MAXIMUM
>>
Code snobbery vexes me.
OPs code does the job it's supposed to do.
So it's fine.
>>
dpt is busy arguing over anime so here you go: my first ever brainfuck program

++++++++++[>+++++>+++<<-]>--->++<<++++++++++[>+.>.<<-]
>>
>>54509078
goto is excellent for stack-like cleanup. It can lead to a lot less duplicated code.
>>
>>54509125

yeah if you're using batch not c#.
>>
>>54508959
what the fuck is your bracket style
>>
>>54509094
>just let me bask in my glory :^)

yeah, """glory""" for making a """"program"""" with an if statement that does one thing
>>
>>54509113
Exactly. Op is learning to code, his program does the job intended, and it's readable as fuck. A+ op.
>>
>>54509146
Who are you quoting?
>>
>>54509094

can't tell if you're OP.

But if you are, you should probably neck it considering you can't even use a basic loop.
>>
>>54509113
>OPs code does the job it's supposed to do.
>So it's fine.
It's not elegant though, so I'm going to call it shit.
>>
File: readable.png (6KB, 50x301px) Image search: [Google] [Yandex] [Bing]
readable.png
6KB, 50x301px
>>54509152

>readable as fuck
>>
>>54508959
http://pastebin.com/DQ3gaeK4
I vomit every time.

In case you couldn't figure out what it is, it's an assembler for a virtual architecture.
I only posted the main.c, I can post the rest if you want. You probably don't want that.
>>
File: 1424456979325.jpg (25KB, 499x499px) Image search: [Google] [Yandex] [Bing]
1424456979325.jpg
25KB, 499x499px
>>54508959
>using system
>goto
>>
File: 1437580239744.gif (2MB, 200x133px) Image search: [Google] [Yandex] [Bing]
1437580239744.gif
2MB, 200x133px
>>54509466
for(int i=0;i<srefs->n;i++) if(derefSymbol(((symbol**)srefs->objects)[i]->name,0)==-1) throwerror(0,"%s: %s: Implicit declaration\n",opts->asmfilename,((symbol**)srefs->objects)[i]->name);
>>
>>54508959
That hurt my eyes
>>
File: 1462033349503.jpg (160KB, 1024x576px) Image search: [Google] [Yandex] [Bing]
1462033349503.jpg
160KB, 1024x576px
>>54509009
>>54509014
Goto is completely fine if you absolutely know what you're doing, and OP clearly doesn't know what the fuck he's doing as shown by his extremaely basic program and his decision to use C#.
>>
http://pastebin.com/vx8P6baw
Second program I ever wrote in c#

About the OP, what would be the best way to keep asking until the right parameter is passed and close the program once it has worked once?

I mean
while (true)
{
read input
if (input is valid)
{
do something
}
}

would keep cycling even when correct parameters are passed, right?
Should I just add
Enviroment.Exit(0); 

and do something like
while (true)
{
read input
if (input is valid)
{
do something
Enviroment.Exit(0);
}
}

or is there a better way?
>>
File: poi.jpg (11KB, 419x74px) Image search: [Google] [Yandex] [Bing]
poi.jpg
11KB, 419x74px
>>
File: gsdgv.png (21KB, 919x336px) Image search: [Google] [Yandex] [Bing]
gsdgv.png
21KB, 919x336px
>>54508959
i made a GUI program in node-webkit
it fucking works
then it's full of things like
var ip = $('li', x).getAttribute('title')
var port = $('li', x).getAttribute('data-port')
>>
that's what break statements are for.
while (True)
if (condition = met)
{
do things;
break;
}
}
or you could use like
do 
{
read input
}
while (input != "y" && input!="n")
do things with input
>>
>>54509172
That's just VS's shitty auto formatting, I would put the opening squiggly bracket on the same line as else if if it were up to me
>>
>>54509515
It's C# give me a break
>>
File: 1404168936983.png (77KB, 694x801px) Image search: [Google] [Yandex] [Bing]
1404168936983.png
77KB, 694x801px
>>
>>54509604
return EXIT_SUCCESS;

It quits the program in a good way.
You can also use any int instead of EXIT_SUCCESS and have the exit code be a flag for bugs or as a way to pipe things out to interact with other programs, the possibilities are infinite.
>>
File: 1461982935950.gif (884KB, 500x500px) Image search: [Google] [Yandex] [Bing]
1461982935950.gif
884KB, 500x500px
        try:
string = string.encode('utf-8').decode('utf-8')
except UnicodeEncodeError:
string = string.encode('utf-8', 'surrogateescape')
encoding = chardet.detect(string)

if encoding['confidence'] > 0.5:
string = string.decode(encoding['encoding']).encode('utf-8').decode('utf-8')

return string
else:
return False


Fucking beautiful
>>
>>54509816
>return string
>return false
>try
It's like 5 different types of AIDS all in once place.
>>
File: 1406342141339.png (118KB, 694x732px) Image search: [Google] [Yandex] [Bing]
1406342141339.png
118KB, 694x732px
>>
arr=({a..z})
# Neat way to get the lenght of an array
arr_len="$(echo "${!arr[@]}"|tr ' ' '\n'|tail -n 1)"
>>
File: 1406342198440 - Copy.png (101KB, 694x670px) Image search: [Google] [Yandex] [Bing]
1406342198440 - Copy.png
101KB, 694x670px
>>
>>54509604
Depending on your program you might need to do some cleanup. If you have to add a cleanup function afterwards you'd have to go through your loop and find every single exit.
To be able to simply add cleanup if suddenly needed I'd still write something like below even if it might not be needed right now.
int loop = 1;
while (loop)
{
[...]
if (exitcondition)
{
loop = 0;
break; /* if needed */
}
[...]
}
cleanup();
>>
File: 1406342198441.png (72KB, 694x670px) Image search: [Google] [Yandex] [Bing]
1406342198441.png
72KB, 694x670px
>>
>>54509871

Literally nothing wrong with this code
>>
File: hmph.png (66KB, 1198x688px) Image search: [Google] [Yandex] [Bing]
hmph.png
66KB, 1198x688px
Did I do good senpai?
>>
>>54509913
test2=test;

how do you define "wrong", it does what is says but it could be way simpler and easier/faster to understand.
>>
>>54509913
There's also nothing wrong with >>54509791
this either then. It does what it's supposed to.
>>
>>54509015
0/10

>>54509604
>while(true)
WHY

>>54509939
>if ( () . )

No
>>
>>54509015
que nojo
>>
>>54509015
Why would anyone write comments, class, variable, function names etc in anything else but English? I'm not a native speaker myself, but I would still never do that.
>>
>>54509939
What the actual fuck?
Why are you casting bools to int, subtracting one from the other, and checking to see if the result is not 0 instead of just using != on the bools
>>
File: 1415091883625.png (151KB, 766x664px) Image search: [Google] [Yandex] [Bing]
1415091883625.png
151KB, 766x664px
>>
public void izreziSliku() throws IOException{
File file = new File("./telNumber/telNumberCorbel.jpg");
FileInputStream fis = new FileInputStream(file);
BufferedImage image = ImageIO.read(fis);
int rows = 1;
int cols = 11;
int chunks = rows * cols;
int chunkWidth = image.getWidth() / cols;
int chunkHeight = image.getHeight() / rows;
int count = 0;
BufferedImage imgs[] = new BufferedImage[chunks];
for (int x = 0; x < rows; x++) {
for (int y = 0; y < cols; y++) {
imgs[count] = new BufferedImage(chunkWidth,
chunkHeight,
image.getType());
Graphics2D gr = imgs[count++].createGraphics();
gr.drawImage(image, 0, 0, chunkWidth, chunkHeight,
chunkWidth * y, chunkHeight * x,
chunkWidth * y +
chunkWidth, chunkHeight * x + chunkHeight,
null);
gr.dispose();
}
}
System.out.println("Rezanje slike je završeno.");
for (int i = 0; i < imgs.length; i++) {
ImageIO.write(imgs[i], "jpg",
new File("telNumber/slika" + i + ".jpg"));
}
System.out.println("Kreiranje slika je završeno.");
}
>>
>>54509169
What makes code "elegant"?
>>
>>54510475
https://youtu.be/o8NPllzkFhE?t=858
>>
// Converts integer to binary v.0.0.2

#include <stdio.h>

int shortint2bin(int j);

int main() {
int num;

puts("\nThis program converts unsigned integers to binaries.");
printf("Enter a number: ");
scanf("%d",&num);

if(num<0||num>65535) {
printf("\nInvalid input!\n");
main();
}

else {
printf("\n%d in binary equals:\n",num);
shortint2bin(num);
}
return 0;
}

int shortint2bin(int j) {

unsigned int arr[16];
int i;

for(i=0;j!=0;i++) {
arr[i]=j%2;
j=j/2;
}

for(i--;i>=0;i--) {
if(i==0) printf("%d\n\n",arr[i]);
else printf("%d ",arr[i]);
}
return i;
}
>>
>>54508959
V1.0 was even worse:
http://hastebin.com/atulidecod
>>
>>54510495
why does he talk with his teeth closed?
>>

#include <stdio.h>

#define MOD(c,v) ((c%v))

#define FIZZ_i 3
#define FIZZ_s "Fizz"
#define BUZZ_i 5
#define BUZZ_s "Buzz"

#define COUNT 100

int main(void) {

int i;
for(i=0; i<=COUNT; i++) {
if ((!MOD(i, FIZZ_i)) || (!MOD(i, BUZZ_i))) {

if (!MOD(i, FIZZ_i)) printf(FIZZ_s);
if (!MOD(i, BUZZ_i)) printf(BUZZ_s);
printf("\n");

} else {
printf("%d\n", i);
}
}

return 0;
}
>>
>>54510475
How easy is to troubleshoot, mantain, edit, comprehend or expand
>>
>>54508959
>comparing strings with ==
>>
File: 1424450645140.gif (3MB, 280x358px) Image search: [Google] [Yandex] [Bing]
1424450645140.gif
3MB, 280x358px
>>54510503
>for(i--;i>=0;i--)
>>
>>54510776
it just werks

I could do for(int foo=i-1;foo>=0;foo--)
>>
>>54508959
>>
>>54510057
Because I'm a beginner. And I remember using something like that when programming a msp430 to loop the main function.

>>54509799
I'll look up the documentation.

>>54509875
I like this, looks very versatile.

Thank you all.
>>
>>54510160
Because I need to know a change has occurred, instead of just assigning the detected bool state to the struct's members. And the IsDlgButtonChecked doesn't return a bool, but a UINT.
>>
Don't have a pic but
>chaining different slices of an SQL command with
"element1.text + ","+element2.text
...
>>
>>54510897
SQl injection
>>
File: 1414554539138.png (68KB, 675x426px) Image search: [Google] [Yandex] [Bing]
1414554539138.png
68KB, 675x426px
>>
>>54510894
>Because I need to know a change has occurred, instead of just assigning the detected bool state to the struct's members
In the conditions you retard
>And the IsDlgButtonChecked doesn't return a bool, but a UINT
Doesn't matter. Cast it to a bool if you really want to.
>>
>>54510909
>giving database-abled programs to anyone
It was mainly for avoiding opening SQL server each time a small thing was needed, only me and the sysadmin used it.
Tho i didn't test for that shit.
does c# have a way to do it more securely?
>>
>>54510955
>In the conditions you retard
Yes, I meant that. What's your point?
>>
File: spurdo.jpg (28KB, 600x459px) Image search: [Google] [Yandex] [Bing]
spurdo.jpg
28KB, 600x459px
>>54510531
>"Type here your question:"
>>
>>54510989
You still know a change has occurred if you write the conditions in a non-retarded way
>>
>>54511004
How?
>>
File: stlext.png (7KB, 719x143px) Image search: [Google] [Yandex] [Bing]
stlext.png
7KB, 719x143px
old ass part of my stl extension library. rate and rate
>>
>>54511013
Because it evaluates to exactly the same thing? What aren't you getting here?
>>
File: Capture.png (84KB, 1515x721px) Image search: [Google] [Yandex] [Bing]
Capture.png
84KB, 1515x721px
I honestly have no idea what I'm doing
>>
>>54510966
google prepared statements for c# if you care.
>>
>>54511031
What are you on about? Evaluates where? You're saying you can write code to check if a change has occurred in a non-retarded way, so how do you propose that?
>>
>>54510955
LINQ to SQL or usage of stored procedures with abstracted calls.

Combine with input sanitizing and you're golden.
>>
>>54511056
see
>>54510160

If you're going to continue being a monkey about this, just post one of the if statements from the code you posted so I can change it without having to hand-copy from your image.
>>
>>54511073
meant for
>>54510966
>>
>>54511079

bool readChkBoxesState(HWND dialogWindow)
{
bool changeOccurred = false;
//difference should be 1 if change occurred, otherwise 0 (1-1) = 0 (0 -0 ) = 0 ||| 1-0 0-1
if ( (int)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_WINREMEMBER)) - (int)(settings.bRememberLastSizeByUser) )
{
settings.bRememberLastSizeByUser = (bool)(IsDlgButtonChecked(dialogWindow,IDC_PREFS_TOGGLE_WINREMEMBER));
changeOccurred = true;
}
if ( (int)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_bSplashScreen)) - (int)(settings.bSplashScreen))
{
settings.bSplashScreen = (bool)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_bSplashScreen));
changeOccurred = true;

}

if ( (int)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_EXIT_NORMAL_CONFIRM)) - (int)(settings.bConfirmExit))
{

settings.bConfirmExit = (bool)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_EXIT_NORMAL_CONFIRM));
changeOccurred = true;

}

if ( (int)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_FULL_PATH)) - (int)(settings.bShowCompleteFilePathInTitle))
{
settings.bShowCompleteFilePathInTitle = (bool)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_FULL_PATH));
changeOccurred = true;
}
if ((int)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_TOOLBAR)) - (int)(settings.bToolbarActive))
{
settings.bToolbarActive = (bool)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_TOOLBAR));
changeOccurred = true;

}
if ( (int)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_LINKS)) - (int)(settings.bDetectLinks))
{
settings.bDetectLinks = (bool)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_LINKS));
changeOccurred = true;
}

if ( (int)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_TOOLBAR_TEXT)) - (int)(settings.bToolbarText))
{
settings.bToolbarText = (bool)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_TOOLBAR_TEXT));
changeOccurred = true;
}
return changeOccurred;
}
>>
>>54511034
well at least it has some comments...
>>
>>54508959

Patterning out Maybe and Either in Haskell in code that can't, logically, return Nothing.

unsafeMaybe :: Maybe a -> a
unsafeMaybe Nothing = error "unsafeMaybe crash"
unsafeMaybe (Just a) = a


I could refactor the _other_ code to basically not require me to do this but gahhhhhhh.

This is really shitty BTW, for those that don't know Haskell.
>>
>>54509094
>>ermagerd
Take your own advice
>>
File: 2016-05-12 08.38.39.jpg (274KB, 427x1591px) Image search: [Google] [Yandex] [Bing]
2016-05-12 08.38.39.jpg
274KB, 427x1591px
R8
>>
>>54511097
oh my, you win, havent seen code this disgusting since i took over a project made by BSc "i kan program" shitters
>>
>>54511023
bretty good
>>
>>54511097
Man I said "one of" the if statements
>
    bool changeOccurred = false;
if ( (int)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_WINREMEMBER)) - (int)(settings.bRememberLastSizeByUser) )
{
settings.bRememberLastSizeByUser = (bool)(IsDlgButtonChecked(dialogWindow,IDC_PREFS_TOGGLE_WINREMEMBER));
changeOccurred = true;
}


bool changeOccurred = false;
if (IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_WINREMEMBER) != settings.bRememberLastSizeByUser) {
settings.bRememberLastSizeByUser = (bool)(IsDlgButtonChecked(dialogWindow,IDC_PREFS_TOGGLE_WINREMEMBER));
changeOccurred = true;
}
>>
>Do you want beep?
No Sanjeep I want nearest shitting street.
>>
>>54511161
thanks, i gotta update it at some point to take any kind of container
>>
>>54508980
This guy sure got that right.
>>
>>54508959
That's cute, OP :3

Suggested next step:

Let the user type e.g. ACF to play the notes A, C and F in order. Type in a little melody
>>
>>54511191
>still making the bool cast in the assignment
>still having parenthesis around a unary expression
nice try though
>>
>>54509015
>variable names not in english
>>
>>54510131
Heh, I'm not native either, and I only wrote comments in English.

RIght until I got my first job working with a team in my country, which is one of the main reasons to write comments in the first place.

So either you live abroad, work with English speakers, or you have never had an actual job and just write code for your own amusement.
>>
>>54511242
>still making the bool cast in the assignment
I specifically said my criticism was limited to the conditional. If you have trouble understanding English, you should say so and get clarification instead of prancing through life without having any idea of what people around you are saying
>>
File: кек.png (184KB, 392x766px) Image search: [Google] [Yandex] [Bing]
кек.png
184KB, 392x766px
>>54511251
>>54509024
>>54510131
>>
>>54511292
>one of the if statements
sir, i do believe that the fucking if block is part of the if-statement, hence yes the assignment is part of the if-statement
>>
>>54511322
idi nahui
>>
static void PrintOddNumbersVerifiedByMicrosoftSQLServer2012()
{
SqlConnection thisConnection = new SqlConnection(@"Data Source=localhost;
Initial Catalog=default;
Persist Security Info=True;
User ID=user;
Password=B1GT1tti3z");
thisConnection.Open();

string Get_Data =
@"DECLARE @start INT = 1;
DECLARE @end INT = 100;

WITH numbers AS (
SELECT @start AS number
UNION ALL
SELECT number + 1
FROM numbers
WHERE number < @end
)
SELECT *
FROM numbers
WHERE number % 2 <> 0
OPTION (MAXRECURSION 0);";

SqlCommand cmd = thisConnection.CreateCommand();
cmd.CommandText = Get_Data;

SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
var ayy = dt.AsEnumerable().ToList();

foreach (var number in ayy)
{
WriteLine(number.ItemArray[0]);
}
}
>>
>>54511191
Ah, you mean this way. The reason why I used arithmetic is because not all members of the struct are boolean, but the ones who get checked and set in my function are the rest weren't added when I turned in my assignment, so I applied arithmetic to check states thinking I would add something later.
>>
>>54511341
I asked him to post an entire if statement for context. I did not say I was going to rewrite everything in the if statement, in fact I specifically mentioned only the conditional.

Again, learn to read.
>>
>>54510996
Yes hello, i am only a but indian sorry for bad english not first language of my.
>>
>>54511374
why not just reply with
IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_WINREMEMBER) != settings.bRememberLastSizeByUser

that is the conditional expression, at no point did you say "rewrite the conditional." i believe you may have horrible shortterm memory.
>>
What do you guys expect when you read other people's code? Like what are some good programming practices that you like seeing?
>>
>>54511433
>why not just reply with
>IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_WINREMEMBER) != settings.bRememberLastSizeByUser
Because the other guy was erroneously expressing concerns with the operation of the statement body, and I wanted to make it clear that I was not proposing that that part be changed or removed.
>at no point did you say "rewrite the conditional."
If you had been following the conversation instead of jumping in without knowing what was going on, you'd see that I was talking about the conditional explicitly ala >>54510955 and >>54511004
>>
>>54511523
>If you're going to continue being a monkey about this, just post one of the if statements from the code you posted so I can change it without having to hand-copy from your image.

"so I can change it" it refers to the "one of the if statements" hence you said "so i can change one of the if statements." maybe you should not be as ambiguous then :^)
>>
>>54511462
>Functions that do one thing, and do it well.
>Comments where necessary
>No comments when unnecessary.
>Object names not spelled like a fucking pajeet (upgradation, authentification)
>Maintainability (if the same string/path/magic number is used in like 17 places, don't fucking hard-code it. Make a constant.)
>Sane, common-sense optimizations (ex: form a long string and do file I/O ONCE, not 500 times with smaller strings)
>>
def fillFooterFrame(mainApp):
xFrame = mainApp.frames.footer
lExcludeMenu = mainApp.excludeList

getButton(xFrame, 'button_moveUp', lExcludeMenu, 0, 1, command = lambda: tk_treeview.moveNode(
GL.appTreeView.focus(),
GL.dicTagsInTree[GL.appTreeView.focus()].getParent().id,
GL.dicTagsInTree[GL.appTreeView.focus()].getTreeViewIndex() - 1,
GL.dicTagsInTree))

getButton(xFrame, 'button_moveDown', lExcludeMenu, 0, 2, command = lambda: tk_treeview.moveNode(
GL.appTreeView.focus(),
GL.dicTagsInTree[GL.appTreeView.focus()].getParent().id,
GL.dicTagsInTree[GL.appTreeView.focus()].getTreeViewIndex() + 1,
GL.dicTagsInTree))

getButton(xFrame, 'button_moveBeginnnig', lExcludeMenu, 0, 3, command = lambda: tk_treeview.moveNode(
GL.appTreeView.focus(),
GL.dicTagsInTree[GL.appTreeView.focus()].getParent().id,
0,
GL.dicTagsInTree))

getButton(xFrame, 'button_moveEnd', lExcludeMenu, 0, 4, command = lambda: tk_treeview.moveNode(
GL.appTreeView.focus(),
GL.dicTagsInTree[GL.appTreeView.focus()].getParent().id,
'end',
GL.dicTagsInTree))
>>
>>54511322
what
the
fuck
>>
>>54509466
        while(*lineptr=='\t' || *lineptr==' ' || *lineptr=='\n') lineptr++; //Trim leading whitespace.

Relax, you are smarter than most JS devs
>>
>>54511548
>"so I can change it" it refers to the "one of the if statements" hence you said "so i can change one of the if statements."
Yes, and I did change it. After being explicit previously that the part of the statement I was going to change was the conditional. Nowhere in anything that I pasted was I wrong or ambiguous, you just have poor comprehension and are now grasping at straws to try to convince yourself otherwise.
>>
>>54511585
>I did change it
nope, you changed the conditional expression, you just seem to not understand a lot of things including CFLs and semantics
>>
File: Untitled.png (37KB, 811x716px) Image search: [Google] [Yandex] [Bing]
Untitled.png
37KB, 811x716px
Here I am loading some info about New Jersey into a game.
>>
>>54509015
I can understand variables in portuguese but why your function names are so long?
>>
>>54511233
Quite easy, I'll have to create an array of those notes corresponding to System.Beep(); freqs.
>>
Can't fit it in a single post but this was a prototype of part of a green-thread library. The entire premise is ridiculous. I don't recall it ever working.

http://pastebin.com/dgNtJ8Jd
>>
>>54510812
Nice encrypted code faggot. Enjoy only working on autisto projects.
>>
File: 323423646.jpg (92KB, 670x720px) Image search: [Google] [Yandex] [Bing]
323423646.jpg
92KB, 670x720px
>>54511725
It really improves readability, you also only type a long function name once, autocompletion kicks in afterwards.
>>
>>54511934
>It really improves readability

Meh, don't know about that, that's why comments are made for anyway.

But since we're not in the 80's anymore, it's okay I guess...
>>
>>54509015
Best looking font/color scheme on this thread, also pretty clean language.
>>
>>54512195
> that's why comments
I won't comment everytime I call a function. Long function names improves readability on another parts of the code as well.
>>
>>54512235
Just the function, not every call.
>>
File: IMG_4109.jpg (65KB, 960x720px) Image search: [Google] [Yandex] [Bing]
IMG_4109.jpg
65KB, 960x720px
>>54512257

// Returns 1 + 1
func x() -> Int {
return 1 + 1
}

// somewhere else in the code...

func wewLad() {
//...
me = x()
}



vs

// Returns 1 + 1
func returnsTwo() -> Int {
return 1 + 1
}

// ... Somewhere else...

func wewLad() {

//...
me = returnsTwo()
//...

}



Wich one is more readable?
>>
>>54512305
Both are pretty much readable for anyone else.

But it looks like you're an idiot who can't even find yourself in your own code, which is embarrassing. Do as you wish.
>>
>>54512409
just die.
>>
>>54511581
>>54511581
Not smart enough to use standard isspace() function though.
>>
http://hastebin.com/iwemekudof.pl
>>
>>54509065
Clearly you've never developed in Swift.
>>
>>54511934
itReallyDestroysReadability.
>>
File: crab battle.jpg (22KB, 480x360px) Image search: [Google] [Yandex] [Bing]
crab battle.jpg
22KB, 480x360px
#include <iostream>

int main()
{
for (int i = 1; i <= 100; ++i)
{
if (!(i % 3) || !(i % 5))
if (!(i % 3) && !(i % 5))
std::cout << "FizzBuzz";
else
i % 3 ? std::cout << "Buzz" : std::cout << "Fizz";
else
std::cout << i;

std::cout << std::endl;
}

return 0;
}
>>
Why doesn't someone design a language where function names can have spaces?
>>
>>54513568
Because that would be a pain in the dick.
>>
#!/usr/bin/python3.4
import rs232 as port
from output import output
import sfml as sf
import sys
types = 'hh'
offset = 200
scale = 0.1
width = 1900
height = 1000
outfile = None
minmax = 1

with output(types,offset,scale,width,height,minmax,outfile) as out:
x = 0
for l in port.getlist(types):
x+=1
if x>=width:
out.clearWindow()
x=1
events = out.add(x,l)
if not events:
continue
for e in filter(lambda x:type(x) is sf.KeyEvent and x.pressed,events):
if e.code is sf.Keyboard.S:
out.changeDrawOrder()
if e.code is sf.Keyboard.C:
out.changeColors()
if e.code is sf.Keyboard.R:
port.get("b")
if e.code is sf.Keyboard.Q:
sys.exit(0)
if e.code is sf.Keyboard.M:
out.resetMinMax()
if e.code is sf.Keyboard.O:
offset += 100
out.setOffset(offset)
if e.code is sf.Keyboard.K:
offset -= 100
out.setOffset(offset)
if e.code is sf.Keyboard.P:
scale *= 2
out.setScale(scale)
if e.code is sf.Keyboard.L:
scale *= 0.5
out.setScale(scale)

>tfw no switch statements in python
>>
            string s = ("bcdfghjklmnpqrstvwxyz");
string vo = ("aeiou");
Func<int, string> fun = (i) =>
{
string t = "";
for (int o = 0; o < i; o++)
{
if (o % 2 == 0)
t += s[rand.Next(0, s.Length)];
else
t += vo[rand.Next(0, vo.Length)];
if (o == 0)
t = t.ToUpper();
}
return t;
};
>>
        public static void gol()
{
int xmax = 1920;
int ymax = 1080;
int iterations = 0;
var sb = new StringBuilder();
int[,] grid = new int[xmax, ymax];
int[,] pgrid = new int[xmax, ymax];
for (int i = 0; i < xmax; i++)
{
for (int j = 0; j < ymax; j++)
{
grid[i, j] = ((rand.NextDouble() > 0.4) ? 1 : 0);
}
}
while (iterations < 1000)
{
pgrid = (int[,])grid.Clone();
grid = new int[xmax, ymax];
Parallel.For(0, xmax, (i) =>
{
Parallel.For(0, ymax, (j) =>
{
int pi = i == 0 ? 0 : i - 1;
int pj = j == 0 ? 0 : j - 1;
int ni = i == xmax - 1 ? xmax - 1 : i + 1;
int nj = j == ymax - 1 ? ymax - 1 : j + 1;
int count = 0;
if (pgrid[pi, pj] != 0) { count++; }
if (pgrid[pi, j] != 0) { count++; }
if (pgrid[pi, nj] != 0) { count++; }
if (pgrid[i, pj] != 0) { count++; }
if (pgrid[i, nj] != 0) { count++; }
if (pgrid[ni, pj] != 0) { count++; }
if (pgrid[ni, j] != 0) { count++; }
if (pgrid[ni, nj] != 0) { count++; }
if (pgrid[i, j] != 0)
{
if (count < 4 && count >= 2)
grid[i, j] = 1;
}
else
{
if (count == 3)
grid[i, j] = 1;
}
});
});
iterations++;
}
}
>>
>>54509015

hue/10
>>
>tfw I don't even know if my code is shitty or not
>tfw I never looked back at my old code and cringed

I-is there some book to learn this?
>>
>>54513546
you can do a fizzbuzz with half that many modulos tho.
>>
>>54509774
yea... no

this is op's fault for being a retard, and the shitty java bracket positioning you said is shit as well

there is only one right way of doing that, and it's this one:

if (wrdf)
{
werf
}
else
{
derf
}


you can actually see where the block starts and finishes without having to look to the side
>>
>>54509078
>Need to break out of nested loops
>"goto would be perfect here!"
>Remember what /g/ told me
>Kill myself because I must be retarded for even considering goto
>>
>>54509118
>dpt is busy arguing over anime
Your program looks like some japanese kirby emote shit too

>>54514532
>there is only one right way
If the code isn't simple as fuck
>>
>>54510913

Not a clever human here, what's wrong with this one? I'm assuming a and c aren't primitives else he would've used ==
>>
>>54511694

Wouldn't it be easier to have each county as an object with the names/revenues/populations as properties? idk I don't know much about programming
>>
>>54509015
>mexican java codemonkeys
B U I L D W A L L
>>
>>54514912
That's Portuguese you uncultured swine
>>
>>54514912
That's argentinian you donkey and it's swift
>>
>>54514912
That's estonian you dumb rock.
>>
>>54511103
inline comments are code smells anon
>>
>>54514912
That's indian, you dumb fag poster
>>
>>54514785
and since its .equals() its probably java since no operator overload.
>>
File: 1454101966171.jpg (30KB, 369x292px) Image search: [Google] [Yandex] [Bing]
1454101966171.jpg
30KB, 369x292px
>>54510913
can someone explain whats wrong with this? I really dont understand why its bad
>>
>>54518407

I'm not sure if it's "bad." Just looks like some edgy commentary on graduates with some random variables being put through an equals method. I don't really get it either.
>>
>>54509015
BR/10
>>
>>54511109
It's meant to be shit code, not decent code
>>
>>54518407
>>54518495
>>54514785
System.out.println(a.equals(c));
>>
import operator
def memoize( f ):
class memoize( dict ):
def __missing__( self, x ):
ret = self[x] = f(x)
return ret
return memoize().__getitem__

def c( a, b ):
if( b == 0 or a == b ):
return 1
return reduce( operator.mul, xrange( b + 1, a + 1 ) ) / \
reduce( operator.mul, xrange( 1, a - b + 1 ) )

@memoize
def ans_r( tup ):
N, K = tup
if( K == N - 1 ):
return N ** ( N - 2 )
elif( K > ( N - 1 ) * ( N - 2 ) // 2 ):
return c( N * ( N - 1 ) // 2, K )
else:
return c( N * ( N - 1 ) // 2, K ) - sum( [ c( N, i ) * sum( [ c( i * ( i - 1 ) // 2, j ) *
ans_r( ( N - i, K - j ) ) for j in
xrange( K - min( [ K, ( N - i ) * ( N - i - 1 ) // 2 ] ), min( [ K, i * ( i - 1 ) //
2 ] ) + 1 ) ] ) for i in xrange( 1, N // 2 ) ] )


def answer( N, K ):
return str( ans_r( ( N, K ) ) )

Code from a programming challenge problem. I mostly copied the else part from work on a whiteboard so that why it looks so retarded.
>>
nodejs: not even once
>>
public class NumChecker {
boolean [] nList;

public NumChecker (){}

public boolean isEven(int n){
n = Math.abs(n) + 1;
nList = new boolean [n+1];
nList[0] = true;
for (int i = 1; i<n+1; i++){
if(nList[i-1]){
nList[i]=false;
}else{
nList[i]=true;
}
}
return nList[n];
}

public boolean isOdd(int n){
return !isEven(n);
}

public boolean isPos(int n){
return (0<n);
}

public boolean isNeg(int n){
return !(0<n);
}
}
>>
double mysqrt(double a) {
double const sqrt_2 = 1.4142135623730950;
double x, f, sqrt_f;
int e;

f = frexp(a, &e);

sqrt_f = 0.585786437626904951*f + 0.420495128834865949;

sqrt_f = 0.5 * (sqrt_f + f/sqrt_f);
sqrt_f += f/sqrt_f;
sqrt_f = 0.25 * sqrt_f + f/sqrt_f;

x = (e & 1) ? sqrt_2 * ldexp(sqrt_f, e/2) : ldexp(sqrt_f, e/2);

return x;
}



r8
>>
>>54518699
Can Java convert booleans to strings like that? Would System.out.println(2 != 1) print "True"?
>>
>>54518915
if you believe hard enough
>>
>>54518915
yes
>>
>>54518853
>that unnecessary variable x
time to commit seppuku
>>
>>54514532
bsd/allman masterrace
>>
#include <stdio.h>
#include <stdlib.h>

#define HELLO_STRING "Hello"
#define WORLD_STRING "world"
#define HELLO_WORLD_FORMAT "%s, %s!\n"

typedef char * func(int);

int doHelloWorld();
char ** getHelloWorld(func, int, func, int);
char * getHello(int);
char * getWorld(int);

int main(void)
{
int numCharToPrint = sizeof(HELLO_STRING) + sizeof(WORLD_STRING) + sizeof(HELLO_WORLD_FORMAT) - 2 - 2 - 1 - 1 - 1 - 1 + 1;

if(!(doHelloWorld() == numCharToPrint))
return 1;

getchar();
return 0;
}

int doHelloWorld() {
char ** helloWorldArray;
helloWorldArray = getHelloWorld(&getHello, 1, &getWorld, 1);
return printf(HELLO_WORLD_FORMAT, *(helloWorldArray), *(helloWorldArray + 1));
}

char ** getHelloWorld(func getHelloFunction, int helloFunctionConfirm, func getWorldFunction, int worldFunctionConfirm) {
char ** helloWorldArray = (char **)malloc(2*sizeof(char *));
*(helloWorldArray) = getHelloFunction(helloFunctionConfirm);
*(helloWorldArray + 1) = getWorldFunction(worldFunctionConfirm);
return helloWorldArray;
}

char * getHello(int confirmGet) {
if(confirmGet) {
return HELLO_STRING;
} else {
return 0;
}
}

char * getWorld(int confirmGet) {
if(confirmGet) {
return WORLD_STRING;
} else {
return 0;
}
}
>>
it would be easier to just link my github, none of it is impressive
>>
Part of a college assignment in my junior year:

for (int i = 0; i < numElements; i++) {
cout << " | ";
while (mItr->getRow() == i+1) {
for (int j=0; j < numElements; j++) {
if ((mItr->getRow() == i+1) && (mItr->getColumn() == j+1)) {
cout << mItr->getValue();
mItr++;
} else cout << '0';
if (j != numElements-1) cout << '\t';
}
}
cout << "\t |\t |" << mult[i] << "\t | ";
if (i / 2 == 1) {
cout << equals;
equals = ' ';
} else cout << ' ';
cout << " | " << solved[i] << "\t |" << endl;
}
cout << " +- ";
for (int y = 0; y < numElements; y++) cout <<"\t";
cout << "-+\t +- \t-+ +- \t-+" << endl;


I probably thought I was hot shit with this too.
>>
File: 1406342198443.png (71KB, 694x670px) Image search: [Google] [Yandex] [Bing]
1406342198443.png
71KB, 694x670px
>>
>>54510503

Why are you calling main() on invalid input instead of just exiting?
>>

//bmi calc
#include <iostream>
using namespace std;

int main()
{
double inch, feet, lbs, bmi;

cout << "Enter your height.\n";
cout << "Feet?: ";
cin >> feet;
cout << "Inches?: ";
cin >> inch;
cout << "Weight (lbs)?: ";
cin >> lbs;

feet = feet * 12;
inch = feet + inch;
bmi = (lbs / (inch * inch)) * 703;

cout << "Your BMI is " << bmi;

return 0;
}
>>
File: ayi.png (17KB, 860x440px) Image search: [Google] [Yandex] [Bing]
ayi.png
17KB, 860x440px
>>
File: q-c.png (30KB, 561x1050px) Image search: [Google] [Yandex] [Bing]
q-c.png
30KB, 561x1050px
doesn't give correct output but whatever

supposed to be for problem 17 in projecteuler
>>
>>54508980
>>54511231

These two guys got it right.
>>
>>54511106
why would you need unsafeMaybe?
just design such that a Nothing does return ()
>>
>>54509078
>Any use of goto can be rewritten without it
Any use of for loops can be rewritten without it. Doesn't stop you from trying to argue that for loops should be banned.

>abstractions are bad because I don't understand how to use them
>>
>>54509015
Your verbs are way too long,
You write too much in your comments.
Change that and I'll read your code.
>>
>>54509078
>If you ever actually made anything over 50 lines long you would soon realise how using goto will fuck you over, especially in a language like c#...
https://github.com/mpv-player/mpv/search?utf8=%E2%9C%93&q=goto
~120k lines and counting, still encountered no problems with goto
>>
>>54509015
func resolveThsMathematicalExpressionThatIHaveProgrammedInThisFunctionWhichReturnsADoubleAndTakesAStringAsItsArgument(stringTheExpressionArgumentYouArePassingToThisFunction: String)

verbose/10
>>
>>54514837
yes
>>
>>54509069

What should be used in place of Console?
>>
>>54512990
That code I posted was pretty old.
I've improved a lot since then.
>>
File: 1462316067352.jpg (39KB, 500x500px) Image search: [Google] [Yandex] [Bing]
1462316067352.jpg
39KB, 500x500px
>>54520064
do you not comment on your code? This shit is hard to follow. Always comment anon, even on practice or school problems. It builds good habbits
>>
File: jnIpIQI[1].png (191KB, 558x238px) Image search: [Google] [Yandex] [Bing]
jnIpIQI[1].png
191KB, 558x238px
so you're saying my brackets are in the wrong place? b-but it works right??
>>
Can someone explain to me why OP has
Thread.Sleep()
method at the end?
>>
>>54524397
To make it extra shitty.
>>
>>54524517
But how does it help him, what did he plan to do with it?
>>
>>54523019
Nothing, just use
WriteLine()
.
>>
>>54524528
Ostensibly, there's no use for it.

However, it may be a kludge to keep the process running a bit longer for some other reason not apparent in the code.
>>
>>54525044
I reckon it's because console window closes as soon as the program finishes and you don't get to see the output.

All he had to do is run it in debug mode and he'd get little press enter to continue or whatever it outputs once the program finishes, but he did say it's shitty code so can't blame him.
>>
>>54525304
I usually drop a
ReadKey()
at the end of main with a 'Press any key to exit...'
>>
>>54524292
>hover image
>ask myself how you could have written that without curly brackets
>look to the right
>>
>>54524292
Looks more readable this way t b h.
>>
>>54525304

Actually, after the process terminates, control is returned to whatever console process called it. Unless of course you're some kind of retard that just double clicked it or something...
>>
>>54525032
using System;

public class Test
{
public static void Main(String[] args)
{
WriteLine("Test");
}
}


Gives:
Test.cs(7,9): error CS0103: The name 'WriteLine' does not exist in the current context
>>
>>54510057
>>while(true)
There's literally nothing wrong with this
>>
>>54527454
Come on, it's [current year].

using static System.Console;
>>
>>54527454
>>54527488
For more information:
https://www.simple-talk.com/dotnet/.net-framework/whats-new-in-c-6/

Also, pattern matching, tuple primitives, functions within functions, and other fun things are coming with C# 7.
>>
>>54527488

>using static
That would have been much more helpful to tell me. I was not aware that was a thing.
>>
File: 1431883261561.png (383KB, 560x540px) Image search: [Google] [Yandex] [Bing]
1431883261561.png
383KB, 560x540px
def highestLetterCount():

typedWrdList = []
while True:
typedWrd = input()
if typedWrd.isalpha() == False:
break
typedWrdList = typedWrdList + [typedWrd]


prevWordCount = 0
biggestWord = ''
for word in typedWrdList:
letterCount = 0

for letter in list(word):
letterCount += 1

if letterCount > prevWordCount:
prevWordCount = letterCount
biggestWord = word

maxLetterCount = prevWordCount

if maxLetterCount == 0:
print('Type some words you dingus')
return highestLetterCount()
print(biggestWord)
print(maxLetterCount)

highestLetterCount()
>>
>>54522588
You're right about these guys getting it right
>>
>>54524292
That's fucking genius, I think l'll do that from now on
>>
>>54524292
<code>using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using static System.Console;

namespace TestConsole
{
class Program
{
static void Main(string[] args)
{
start:
ForegroundColor = ConsoleColor.Gray;
Write("Do you want the beep? (y/n) ");
string i = ReadLine();
if (i == "y") {
ForegroundColor = ConsoleColor.Green;
WriteLine(">beeps");
Beep(1200, 900);
}
else if (i == "n") {
Write("No Beeps for you then.") ;}
else {
ForegroundColor = ConsoleColor.Red;
WriteLine("The input is either 'y' or 'n'.");
goto start;
}
ReadKey() ;}

}
}</code>
>>
>>54508959
>goto
What the fuck senpai
>>
File: triggerwraning.png (21KB, 580x533px) Image search: [Google] [Yandex] [Bing]
triggerwraning.png
21KB, 580x533px
>>54528038
Here, because fuck you
>>
>>54510455
>slavcoding
>>
>>54528105
You missed two braces.
>>
>>54528441
If that was true, it would have never compiled like it actually did.
>>
>>54528463
Under the namespace and class declarations, dickhead.
>>
File: rendering.png (64KB, 942x951px) Image search: [Google] [Yandex] [Bing]
rendering.png
64KB, 942x951px
Some of the rendering code from my current project.
>>
>>54528550
(fuck(that(language, (holy(shit)))))
>>
>>54528596
I don't even see parens bro, I just see function applications and variables.
>>
File: fib.png (41KB, 767x362px) Image search: [Google] [Yandex] [Bing]
fib.png
41KB, 767x362px
>tfw fibonacci in python will never be as elegant as in Haskell
>>
>>54528684
Wat editor/IDE?
>>
>>54528703
Why would the IDE or editor matter? It's literally just monospaced text.
>>
>>54528550
what happens when you wanna chain alot of functions together? do you just keep your thumb on the parenthesis button or commit suicide?
>>
>>54528684
puke
>>
>>54528717
Just wondering what this certain guy on /g/ uses for Python. For polling purposes
>>
wrote this in the past 2 hours:
/* Stores digits of a floating point in an array of integers
version 0.0.1*/

#include <stdio.h>

int main() {

float pi = 3.14159;
int k,i,arr[6];

k=pi;
for(i=0;k>0;i++) {
arr[i]=k;
pi = pi - k;
pi = 10*pi;
k = pi;
}

for(int j=0;j<i;j++) {
if (j==i-1) printf("%d\n",arr[j]);
else printf("%d ",arr[j]);
}

return 0;
}
>>
>>54511322
Hahaha
>>
>>54528703
>>54528737
emucs. Since the ein guy fixed compatibility with the latest Jupyter notebooks, it's a surprisingly good environment to do literate programming in.
>>
>>54528722
>thumb on parenthesis
What kind of keyboard are you using?

Also, pairs are auto-balanced. I don't have to manually close anything.
>>
>>54528717
>>54528684
More curious about the color scheme. I really like earth-toned ones. What is it?
>>
>>54522520
this is certified shit code
>>
>>54522778
top kek
>>
>>54528801
https://github.com/emacsfodder/emacs-theme-darktooth
>>
Are these too many nested ifs?
>>
>>54526257
>it's like they're trying to copy python's no curly or semicolon ideals
>>
>>54527782
>Professor would give me a solid fuckyou/10
>>
http://pastebin.com/vKLFTrLC
My shitty Snake program in pajeet language.
>>
File: p93cc3r.png (7KB, 956x141px) Image search: [Google] [Yandex] [Bing]
p93cc3r.png
7KB, 956x141px
>>54528684
So I heard you like inelegant Fibonacci sequences.
>>
>>54528842
In most cases, if you're more than 3 deep you should be farming stuff out to other functions.

Shit gets unreadable real quick.
>>
>>54528638
>neglecting to remember that variables aren't actually variables in scheme and lisp
>>
>>54529027
Not in a particularly nitpicky mood today, so no.
>>
>>54528824
Thanks. Kind of a shame it makes ERC look bad though, but I'm still going to use it for other things.
>>
>>54511424
>cancer/10
>>
>>54514912
that's Egyptian you plague
>>
>>54522520
that's one beautiful language
>>
File: 1463101755416.jpg (69KB, 600x787px) Image search: [Google] [Yandex] [Bing]
1463101755416.jpg
69KB, 600x787px
>>54511322
it's, it's beautiful!
>>
File: 1463100023079.png (638KB, 4760x4986px) Image search: [Google] [Yandex] [Bing]
1463100023079.png
638KB, 4760x4986px
>not enough ||
>>
>>54528751
Surely you mean
>xaxaxaxaxa
>>
>>54509015
>programming
>not even using english
>>
File: `scala master race`.png (4KB, 308x160px) Image search: [Google] [Yandex] [Bing]
`scala master race`.png
4KB, 308x160px
>>54513568
>>
>>54509015
mata-te na vida real
>>
>>54509069
>>switch statement
Please tell me its a bait.
>>
>>54508959
>goto
xD but it werks
>>
>>54531504
holy shit nice
bur do I have to use def?

I'd only Scala was almost like haskell in the syntax sense
>>
>>54508959
I once did a Beep Piano, shit was fun
>>
File: qXS.png (15KB, 571x424px) Image search: [Google] [Yandex] [Bing]
qXS.png
15KB, 571x424px
r8 pls
>>
>>54522778
underrated
>>
Still have not heard a single good reason for using gotos...

enough of this contrarian bullshit. tell us why gotos are OK to use or shut the fuck up.
>>
>>54536484
good way to return to the initial question prompt as pointed out in the code
>>
>>54536533
re-structure your loops.
using goto = I don't know what I'm doing
>>
>>54536560
Since you're a guru from what you claim with your words, show me then, how I can do it without needing to make it complex just to do a simple task of going back to the beginning of the function?
>>
>>54529843
WHY NOT A SIEVE!
>>
>>54536484
Still have not heard a single good reason for using for loops...

enough of this contrarian bullshit. tell us why for loops are OK to use or shut the fuck up.
>>
>>54512195
Have you ever written a program that's more than 100 lines?
>>
>>54528477
no, he didn't you dumbass

all of them but the first two are on the right
>>
File: code.png (49KB, 1192x944px) Image search: [Google] [Yandex] [Bing]
code.png
49KB, 1192x944px
>>54508959
dont even remember waht this does
>>
>>54537646
what in the fuck is that zigzag bullshit?
>>
>>54537671
its the fobbonachi curve, true beatuty
>>
File: coding.png (78KB, 679x736px) Image search: [Google] [Yandex] [Bing]
coding.png
78KB, 679x736px
I love coding! I just learned some html and it's a lot of fun
>>
>>54537720
>I'm a grill, btw
>Markup language
>coding
>>
>>54537740
at least she indents the html

that's more than most people I know can do
>>
>>54537754
Most IDEs auto-indent though, so that would imply the people you know actively go against the IDEs auto-indentation
>>
>>54537766
they use notepad++, basically they don't really care
>>
>>54537766
>>54537754
>>54537740

She doesn't have shit taste either (follow the audio link in her doc)
>>
>>54537913
I just tuned in to Smooth Criminal lel
>>
>>54537913
Also, out of all places, the grill is from Gabon, an island that used to be owned by France
>>
File: btree_invert.png (26KB, 615x775px) Image search: [Google] [Yandex] [Bing]
btree_invert.png
26KB, 615x775px
This inverts the tree.
>>
File: sosorry.webm (2MB, 1502x807px) Image search: [Google] [Yandex] [Bing]
sosorry.webm
2MB, 1502x807px
I forgot when I wrote this I think 6-7 years ago

If I remember correctly it glues together a chatbot written in python (pyborg), the twitter api, the win32 api, and Tesseract OCR

for the purpose of feeding in messages from habbo hotel ready by OCR to the chatbot and typing back responses

I had no idea what I was doing and I apologize in advance
>>
File: 1443389730860.png (122KB, 348x421px) Image search: [Google] [Yandex] [Bing]
1443389730860.png
122KB, 348x421px
>>54529843
>>
>>54508998
Right because
while(i != "y" && i !="n") {
if(i=="y"){

}else if(i=="n"){

}else{

}
}


Is cleaner? You are duplicating predicates, that's a good way to get your shit fucked up.

People like you who just want to start holy wars are super annoying mate.
>>
>>54532110
switch(i){
case "y": ... break;
case "n": ... break;
default: goto derp;
}

For anything above binary flow control switch is superior yeah?
>>
>>54536981
Have you ever written a program that's not a fizzbuzz?

If you can't even find yourself in your own code and can't document it properly, you might as well quit programming entirely.
>>
>>54510503
>enter invalid input too many times
>stack overflow
??? for what purpose ???
>>
>>54518407
System.out.println(a.equals(c));
>>
>>54508959
Made this in a few minutes for a friend who didn't know how to use ffmpeg to convert mkv's to mp4 (which he needed because he uses an iphone, and apple hates using open standards):

from re import match, sub, IGNORECASE
from subprocess import Popen, PIPE
from os.path import isfile

while True:
while True:
inFile = sub('(^["\']*|["\']*$)','',sub('(^[\t\s]*|[\t\s]*$)','',raw_input('Input file: ')))
if isfile(inFile):
if match('.+\.mkv$',inFile, IGNORECASE):
break
print('"'+inFile+'" is not an .mkv file')
continue
print('"'+inFile+'" doesn\'t exist')
outFile, i = sub( '\.mkv$', '.mp4', inFile, IGNORECASE), 2
while isfile(outFile):
outFile, i = sub( '\.mkv$', '_{0}.mp4'.format(i)), inFile, IGNORECASE), i+1
command = 'ffmpeg -v error -stats -i "'+inFile+'" -c copy "'+outFile+'"'
print(command)
try:
process = Popen(command, stdout=PIPE, bufsize=1, shell=True)
for line in iter(process.stdout.readline, b''):
print(line.strip('\r\n'))
process.stdout.close()
process.wait()
except OSError as e:
print(str(e))
>>
>>54540184
>helping an iFag
eheheh
>>
>>54528550
>Lisp
Yeah that is pretty shitty.
>>
>>54528684
That's fucking terrible.
>>
>>54536484
Error handling.
>>
>>54518915
The type of System.out is PrintStream, and that class got overloads for all primitives. For random objects, their toString() method is called.
Even without all that you could call a method superMethod(Object o) with superMethod(true), which would autobox "true" to an instance of the class Boolean which contains one boolean field with the value true.
>>
>>54528550
What editor colors matching parentheses like that? With that i may actually start using a lisp
>>
File: 1390418922293.png (313KB, 543x673px) Image search: [Google] [Yandex] [Bing]
1390418922293.png
313KB, 543x673px
>>54522520
What's the font senpai?
>>
>>54510455
Java programiranje, oh boze. Sta se jebes sa slikama, bezi na Cloud, tamo su pare. Samo EE
>>
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <stdlib.h>

int get_int(int *param)
{
char buffer[16] = {0};
*param = 0;
fgets(buffer, 16, stdin);

if(!buffer[0]) return 1;

char *p;

for(p = buffer; *p; ++p)
{
if(*p >= '0' && *p <= '9')
{
if(*param > INT_MAX / 10) return 3;
if((*param == INT_MAX / 10)&&((*p - '0') > INT_MAX % 10)) return 3;
(*param) *= 10;
(*param) += *p - '0';
} else if(*p != '\n') return 2;
}
return 0;
}
>>
>>54510556
Crippling autism.
>>
>>54538472
oh god
>>
>>54514912
That's british english you sweepety poop
>>
File: 1446113705817.jpg (247KB, 1224x1445px) Image search: [Google] [Yandex] [Bing]
1446113705817.jpg
247KB, 1224x1445px
>>54543067
>>
Made a slightly harder fizzbuzz in python. The function is retarded, but it works:

import math

loop = 0
maxAmt = 1001

def addZeros():
addedZeros = ""
maxTens = float(maxAmt)
tensPlaces = 0
loopTens = float(loop)

while maxTens > 10.0:
tensPlaces += 1
maxTens /= 10.0

while loopTens >= 10.0:
tensPlaces -= 1
loopTens /= 10.0

while tensPlaces > 0:
addedZeros += "0"
tensPlaces -= 1

return addedZeros + str(loop)

while loop < maxAmt:
if loop % 3 == 0 and loop % 5 == 0 and loop != 0:
print addZeros() + " FizzBuzz"
elif loop % 3 == 0 and loop > 0:
print addZeros() + " Fizz"
elif loop % 5 == 0 and loop > 0:
print addZeros() + " Buzz"
else:
print addZeros()

loop += 1

>>
>>54522629
lmao MPV is a fucking meme confirmed
>>
>>54511322
Кpacивo
>>
>>54539278
while (true) {
...;
var i = ReadLine();
if (i == "y") { ...; break; }
else if (i == "n") { ...; break; }
else { ...; }
}
>>
>>54545446
var i;
while (true) {
...;
i = ReadLine();
if (i == "y") { ...; break; }
if (i == "n") { ...; break; }
...;
}
>>
>>54543907
Fuck off, band wagoner.
>>
>>54518828
who is this semen demon??
>>
>>54511109
That's pretty good, actually
>>
^(<((?<C>\w*)|(?<-C>\/\k<C>))>)*(?(C)(?!))$

It matches correctly nested xml-like tags. .net regex flavor.
>>
>>54509172

I haven't worked with any programming languages in years and I could still wrap my head around it. It's readable.
>>
>>54546429
>regex

I always hate doing regex, but it's so damn useful to know when writing scripts.
>>
File: .png (64KB, 1888x1080px) Image search: [Google] [Yandex] [Bing]
.png
64KB, 1888x1080px
>tfw functions are objects
>>
>>54509859
I've seen this so many times, but I still have absolutely no fucking idea how this shit is supposed to work.
Thread replies: 312
Thread images: 59
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y / ] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
If a post contains illegal content, please click on its [Report] button and follow the instructions.
This is a 4chan archive - all of the content originated from them. If you need information for a Poster - you need to contact them.
This website shows only archived content and is not affiliated with 4chan in any way.
If you like this website please support us by donating with Bitcoin at 1XVgDnu36zCj97gLdeSwHMdiJaBkqhtMK