/dpt/ - Daily Programming Thread

old thread: What are you working on, Sup Forums?

Other urls found in this thread:

cprogramming.com/tutorial/floating_point/understanding_floating_point_representation.html
infoq.com/news/2017/05/azul-falcon
youtube.com/watch?v=pLaJliu2_pI
twitter.com/SFWRedditGifs

>puts /dpt/ in the OP thread
what kind of fly-by-night show are you running here OP

Ocaml or Lisp?

Fuck you for using an anime image

This. Anime loserspergs are the cancer killing Sup Forums

>reeeeeee anime
lmao

newfag

I want no.3 to fuck me in my ass

t. newfag

t. new friend

Depth-first traversals of trees come in 3 main varieties: pre, in and post orders.

Depth-first searches of graphs come in 3 main varieties: pre, post, and reverse-post order.

What order does the typical textbook recursive Depth First Graph Search process its nodes in?
procedure DFS(G,v):
label v as discovered
for all edges from v to w in G.adjacentEdges(v) do
if vertex w is not labeled as discovered then
recursively call DFS(G,w)

In C, is it possible to have an unnamed (or anonymous, as gcc tells me) struct with external linkage? The header would look like:

extern struct {
int number;
} user;


How would the source code look like, or is it impossible?

you're indian, aren't you

How could you possibly live without anime?

>end of the semester
>projects due
>in one class my team is a bunch of idiots so I wrote the entire project and they didnt help so im not gonna put their names on it (like zero contact about the project)
>other class is that "I work all weekend and didnt work on it at all, but i did the easy ass manual for the program, thanks for doing the project (all the hard work) so I dont fail"

Worst part is that I know this fuckers will probably land better jobs than me because they are more social etc

>he thinks college is all about good grades
HAHAHAHAHAHAHAHAHAHA

yeah, they dont let you graduate with failing grades

WTF am I reading?

They're only getting a good grade because you did all the hard work for them.
The trick is to get the most autistic fucker to do your work in any group project, much like in real life.

What am i supposed to do? I cant just fail my classes because I didnt feel like doing the work. Theres a black guy who I got grouped with 2 times now who has done literally nothing in both times.

This shit pisses me off

Be more social, fucker.

What's a good modern alternative to Bash scripts?

Lisp

Bash scripts

...

Saw some ad shilling this on goybook

Anyone know if it's good?

How does that change anything? I dont wanna fucking depend on people to do my project

But it sucks because it's too old.

>XKCD comic in the first fucking page

dropped

is the dude who made juicebox still on here? I was gonna show my buddy your page, i liked the layout. looks like its down now.

...

Freshman here, working on a project to zoom in on the mandelbrot set.
It works pretty well until you zoom in to the order of around 2.0E-14 and lower, then pic related happens.

I'm kinda new so I was wondering if it this exceeds the decimal precision of double types or am I doing something wrong.

can link code if needed

Dude, are you studying in Sweden?

Funny

But seriously, what the fuck am i supposed to do? Do i bitch at people and in turn look like a bitch? Tell the teacher and look like a bitch?

Its like "wooo" i did 2.5% of the project, now i get to inherent your grade

im so mad

Double epsilon is 1e-16, so 1e-14 is already stretching it.
I don't exactly see the problem. Is it because it's grey? Maybe increase iteration number.

That'll be a lesson for you. You have to divide the responsibilities between each member and have regular (I repeat, regular) meetings om the project. It is important to keep contact with people. Do not micromanage them, but keep an eye on people who you don't exactly trust.

But what I dont understand is why dont these people worry about the project as much as i do

>be me
>game project with 2 classmates
>one makes art
>me and other guy programming
>project is in written in python using pyglet
>total noob at python
>i write the menus and something else for the game
>friend makes game logic
>the menus are a cluster fuck, but it just works(tm)
>friend is also having problems, we work long days
>we literally program the last few days in panic to get the shit to work
>game barely works, memory leak in the fog of war causes it to crash after 10 minutes
>my menu code is fucking shit something like 500 lines of code
>i wrote it again with half the code after the project but it was still shit

I kind of feel bad about the project now.
But i feel like i put work in to it.

The code... was so bad...

Got a good grade though.

Because they know people like you are going to fast track them into a cushy low effort job where they'll continue to make autists like you do all the work and soon they'll reach middle management and then you'll never touch them.

Maybe you said "D-don't worry, I'll do everything" in the beginning since you obviously didn't want to depend on them. Maybe they are just lazy fucks. Maybe they just forgot. Who knows. How often did you talk with them?

Unless there's some kind of tight-knit "bro code" in your classes that can fuck you up socially for the rest of your time in Uni, fuck yeah you should rat them out for being worthless.

I'd rather call you a bitch for not standing up for yourself.

Bitch.

I definitely didnt say I would do everything. We have a slack where we can communicate freely. Im not really even the 'group leader'. Me and him wrote a lot of the code, and then i finished the code myself. The black guy showed up as soon as we had to leave so he didnt help at all.

Every class its like "Well I work no matter what when ever you guys meet no matter the time but Ill do some rather insignificant part of the project so i get to put my name on it."

At least in one of my other classes you get to rate your teammates on the effort they put into the project

Is a nested still a nested loop if you have an outer for loop and an inner while loop?
Or do you need two for loops for it to be called nested loop.

this is going to depend on how the edges in the call to `adjacentEdges(v)` are ordered.

we are men of class here at /dpt/

they are called for statements

Trying to learn Java, is there any software I can download that will allow me to code in Java on Windows 7?

GNU Emacs.

Netbeans or Eclipse.

note pad

share it

Eclipse

pretty late in replying but this might be informative
cprogramming.com/tutorial/floating_point/understanding_floating_point_representation.html

there's a lot of places where he doesn't really spell it out for you, but the info is there.

A look at how gcc names overloaded GNAT/Ada functions

The functions specs
package Naming_Test is
type Smaller is new Integer range -4 .. 23;

function Add (X, Y : in Integer) return Integer;

function Sub (X, Y : in Integer) return Integer;
function Sub (X, Y : in Smaller) return Integer;

function Mult (X, Y : in Integer) return Integer;
function Mult (X, Y, Z : in Integer) return Integer;

function Div (X, Y : in Integer) return Integer;
function Div (X : in Integer; Y : in Smaller) return Integer;

procedure Plain;

procedure Check;
procedure Check (X : in Integer);

end Naming_Test;

Daily reminder that JVM's that run by JITing Java bytecode to LLVM are becoming the norm: infoq.com/news/2017/05/azul-falcon

According to the assebly output we get
naming_test__add:
naming_test__sub:
naming_test__sub__2:
naming_test__mult:
naming_test__mult__2:
naming_test__div:
naming_test__div__2:
naming_test__plain:
naming_test__check:
naming_test__check__2:


Very clean and simple, just a basic enumeration.

I don't know why I had to split that into two parts, but Sup Forums was very unhappy with it.

...

Is there a non-deepcopy version of strcpy() for C?

Your question makes no sense.

Yeah maybe I'm understanding my problem poorly. I have a string that's apart of a structure that I allocate memory for and when I try to make a copy of that string into another string then free the memory in that copy string the original string gets freed too.

So I'm trying to think if this has a name, or if it's even possible to solve.

I'm trying to model N games of telephone in parallel.

Let's say you have N people in a circle and N starting words. Is there a way pass messages so that everyone will hear each word, and no one will hear from the same person twice? Or is this some group theory provably wrong?


Make sure the pointers aren't the same right before you strcopy? that's the only thing I could think of.

Why does g++ do weird shit to it's overloaded functions?

How to copy a string properly in C (malloc error checking omitted):
char *orig = "abcdefg";
char *new = malloc(strlen(orig) + 1);
strcpy(new, orig);
Shorter POSIX version:
char *orig = "abcdefg";
char *new = strdup(orig);

Just copying a char * isn't going to "duplicate" a string.

I'm doing all this.

if, I'm using a gridlayout in Swing(Java), how would I go about making it change a tiles colour every time its right-clicked?

I get here and then I'm not sure what to do afterwards.

public void mouseReleased(MouseEvent arg0) {
if(SwingUtilities.isRightMouseButton(arg0)){
//code
}
}


Any help is appreciated.

Gnat is benefiting from the tighter restrictions for identifiers in Ada. For example double underscore is not allowed. C++ doesn't have this luxury.

How do you do text manipulation like this? Either in C or Bash?

youtube.com/watch?v=pLaJliu2_pI

new to this board, not sure how to add code like everyone else is doing

how about you read the sticked post in this board?

last sentence:

search in google

"change a tiles colour every time its right-clicked java swing"

jButton1.setBackground(Color.Red);

function fractal {
local lines columns colour a b p q i pnew
((columns=COLUMNS-1, lines=LINES-1, colour=0))
for ((b=-1.5; b

Only 36% of software engineers in India can write compilable code based on measurements by an automated tool that is used across the world, the Indian skills assessment company Aspiring Minds says in a report. The report is based on a sample of 36,800 from more than 500 colleges across India. Aspiring Minds said it used the automated tool Automata which is a 60-minute test taken in a compiler integrated environment and rates candidates on programming ability, programming practices, run-time complexity and test case coverage. It uses advanced artificial intelligence technology to automatically grade programming skills. "We find that out of the two problems given per candidate, only 14% engineers are able to write compilable codes for both and only 22% write compilable code for exactly one problem," the study said. It further found that of the test subjects only 14.67% were employable by an IT services company. When it came to writing fully functional code using the best practices for efficiency and writing, only 2.21% of the engineers studied made the grade.

The only remaining question is, why doesn't /dpt/ makes six figures?

>The only remaining question is, why doesn't /dpt/ makes six figures?
but I do?

I assume you are critisizing me becuase my code is inefficient and messy, but I have also said that I am new.

what are the best coding practices?

I figured it out. I wasn't allocating for the string directly. I was allocating the pointer in the structure for it.

Instead of this:
string = malloc;
structure->str = string;


I was doing:
string = otherstring;
structure->str = malloc;
structure->str = string;


Thanks for trying though guys.

N E W F A G

no not at all, I was showing an example that was written for zsh hoping somebody would take the bait on it.

your code seems simple and clean to me

...

// code goes here

really, moot?

Ocaml because it's actually used and not dead.

Why use a language without a garbage collector?

More efficient usage of data.

Curious what the problem is if people can't even compile code for it.

It contains cancerous puns and typography fucking emojis, but overall decent.

Alright, since I guess this is a better place to ask this than /sqt/, here's a dumbass programming question:

Let's say I have this C code:
#include

int main(int argc, char * argv[]) {
while (argc-- > 0) {
printf("%s == ", *argv);
char c;
while (c = *(argv[0]++))
printf("%c", c);
printf("\n");
}
return 0;
}
And here is the output:
./a.out == ./a.out
-xyz == -xyz
-xvf == -xvf

How is argv[0], and by extension *argv, pointing to the first item in the next array despite the fact that it is not iterated past the terminating '\0'?

> The code... was so bad...
...
> Got a good grade though.

pic related

What kind of RegEx voodoo do i need to make this work?
>A number followed by a semicolon represents a rating
>2 semicolons in a row followed by another semicolon is a null rate (did not rate)
How do I delimit so i only add number or null ratings to a 2Darray (pic related)

>Posts on a Japanese emulated website >Complains about anime

The cognitive dissonance never gets old

>one anime board makes the entire website anime based
go away Sup Forumsutist

Make a counter, then clear it when it hits a number like before you add it to the list, ex:
(list here)
int semicnt = 0;
for (int i = 0; i < ratingsthing.length; i++) {
if (ratingsthing[i] is a number) {
if (semicnt > 1) list.add(null);
list.add(number);
semicnt = 0;
}
}

How would you expect to be able to parse the 'null' ratings? How could you parse it when there are extra random semicolons? (The garbage you point to)

Are you sure it isn't just a bunch of ratings delimited by semicolons? (So it might read: 5, 4, null, null, 4...)

Woops also outside the first if statement make an else and do semicnt++

It doesn't, not for me at least
// ./a -asd -dsa
// outputs
./a == ./a
==
==

...

go to the front page and count the anime boards vs the other boards

>yes hello, im a redditor that goes into places he doesnt like then complains that he doesnt like it there