[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
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 24
Previous: >>54398231

What are you working on /g/
>>
Thank you for not posting an anime image.
>>
>>54406109
Thank you for posting an honorary anime image.
>>
ay, how do i put a force on the x axis please ? rb2d.AddForce (new Vector2 (7, jumpForce), ForceMode2D.Impulse);
>>
File: hun.webm (3 MB, 1066x600) Image search: [Google]
hun.webm
3 MB, 1066x600
Ask your favorite programming literate anything (IAMA)

>>54406105
last time i verified, qemu was an interpreter.

>>54406105
>If a cacheline in the instruction cache gets dirtied, I could just re-decode them again.
yes

>>54406105
>Is it feasible to write an interpreted VM and expect some decent performance?
yes, the goal is to have the smallest ratio of native instructions per virtual instruction.

>>54406105
>I have it all in a big switch statement, is that bad?
Depends the compiler.

A faster instruction decoding than the if/else is

instructionsHandlers[] = {&ADD, &SUB, &JMP, ...};

INC_IP:
++ip;

NEXT:
goto instructionsHandlers[ program[IP] ]; // double fetches + direct jump

ADD:
...
goto INC_IP;
SUB:
...
goto INC_IP;
JMP:
ip = ...;
goto NEXT;

...
>>
Is it a bad habit to use the same variable name when passing a function a parameter.
For example, using:
int myFunction(int var) { ... }

int main() {
int var;
myFunction(var);
... }

Compared to using two different names:
int myFunction(int someVariable) { ... }

int main() {
int var;
myFunction(var);
... }
>>
>>54406217
>Ask your favorite programming literate anything (IAMA)

Many of your answers seem inane and use a lot of alternative terminology I've only seen used at shitty American unis

What is your degree?
>>
>>54406378
He doesn't have a degree - he's a tripfag without the trip.
>>
>>54406262
I don't really see anything wrong with it m8. Some people make a huge deal about it and add prefixes to all their variables to say where they're from though. l_ for local, m_ for member, p_ for parameter, r_ for reference parameter, etc etc
>>
>>54406262
Yes. If it's global you also don't need to pass it in the first place.
>>
>>54406378
what terminology are you referring to ?
>>
>>54406262
No.
It's not a bad habit.
Don't listen to people who says it is for no reason.
Especially don't listen to >>54406494 who doesn't know how global variables are defined in in C/C++.
>>
File: disturbed trve friend.png (83 KB, 201x176) Image search: [Google]
disturbed trve friend.png
83 KB, 201x176
>>54406459
That's what I suspected because of the anime too

>>54406533
Lots of it. Just last thread you used a term that no one inside academia would use (and I have a BSc from EU did a year of my MSc in the US, so it is NOT a regional thing).

I'm not going to point it out because your arrogant attitude makes me hope you don't better yourself.
>>
>class grenadeobject derived from a renderingobject class that has a tick added to the virtual render func to know when to explode
>class grenadeentity derived from a physicsobject that has a virtual oncollision func that checks if the collided with object was a bullet, if so it needs to delete both grenadeobject and physicsobject
>grenadeobject and grenadeentity are glued together to make it work

God this is fucking disgusting. Seriosly considering doing a class grenade deriving from both a rendering object and a physics object.
>>
>>54406627
I didn't even notice that he posts anime because I've got the "werk tyme" option of my extension on. I just generally assume anyone who posts that line is a genuine retard trying to act smart.
>>
>go to work
>already done within 30min
>7.5h to go
What should I Program?
>>
Programming in python. I have two lists, expressionList and normalisedList. expressionList contains roughly a thousand sublists of the form [IDNUMMER,coor1,coor2,...coor8], each representing a vector. I want to normalise the vectors in expressionList by dividing every coordinate in each vector by the total length of the vector. For that, I'm using this function.

 def normalisatieFunctie(expressionList):
normalisedList = expressionList[:]
for line in range(len(normalisedList)):
lengthVector = sqrt(sum(i*i for i in normalisedList[line][1:]))
normalisedList[line][1:] = [x/lengthVector for x in normalisedList[line][1:]]
return normalisedList


However, every time I use the function, both the expressionList and normalisedList turn into the same list. Shouldn't the copy at the start (normalisedList = expressionList[:]) make it so that only normalisedList gets changed? I am so fucking confused.
>>
Do you guys think that Udacity courses are relevant enough to add them to my resume?
>>
>>54406691
I think I got it m8.
I agree that
a = b[:]
does a copy. However, it's only a shallow copy, meaning that normalisedList and expressionList refer to the same set of lists. When you mutate those lists through normalisedList, the changes thus become visible also through expressionList.
>>
c++ add-on upgrade for new software version but it sucks, they made a change i'm unable to bypass with the current version
>>
>>54406691
I could be reading your code wrong because it's very late here, but with this line:
for line in range(len(normalisedList)):


Surely you haven't expressed a range there? You've expressed that you want it to go for the length of your list, but you haven't expressed where to start (eg. 0). I haven't used python in a while, but that doesn't look right to me.
>>
>have biased generator
>xor it with 10101010
Would this make it unbiased or am I being retarded?
>>
>>54406790
Actually, no. I'm a dickhead, you can do that in python.
>>
>>54406790
It takes the length of the normalisedList, which is 1012, then makes a list which is [0,1,2...1011].
>>
>>54406792
Depends what biais, here you're betting that this bias is even vs odd in a very specific way, no?
>>
>>54406792
>xor it with 10101010
Just get it to stop consuming MSM and the bias will naturally dissipate if your generator has the power of critical thinking.
>>
>>54406822
In Python3 it's not a list
>>
>>54406839
Using python 2.
>>
File: svartad.png (2 MB, 1282x650) Image search: [Google]
svartad.png
2 MB, 1282x650
>>54406832
something something generator identifies as non-binary
>>
>>54406822
See
>>54406802
>>
>>54406827
I'm just talking about the very simple bias. I want the expected next bit to be 0.5. Obviously I don't want to just discard the random stream and replace it with 10101010 bytes though.
>>
>>54406760
Independent study is usually always a plus on a resume because it means you can actually take the initiative and learn on your own but make sure that there's something accredited there. From a quick glance I don't see anything that points to a named school outside of their CS "Masters" with Georgia Tech.

I'd also be careful if you're really relying on that as your shining point because while it takes some sort of good looking give-a-fuck to study on your own, pajeets and ching chongs can take the same courses and do the same thing. It sounds counter-intuitive but try to have real extracurriculars or knowledge in the humanities.
>>
>>54406761
How do I go about making something different then a shallow copy?
>>
>>54406906
What's the opposite of 'shallow'?

Google the answer of that, plus 'copy'.
>>
>>54406926
Namasté, I'm a fucking moron.
>>
>>54406691

kanker
>>
>>54406906
>>54406926
Or you could voluntarily copy the vector in the loop.

Also do
normalisedList = []
for vector in expressionList:
normalisedList.append(... vector ...)

It's simpler
>>
>>54406970
>>54406926
>>54406761
You are all thanked.
>>
help me out /g/
strncpy_s(char * _Dst, rsize_t _SizeInBytes, const char * _Src, rsize_t _MaxCount);

this takes a pointer as a destination, right? it also has to point to a char, right? how do i make it eat a custom string variable for the destination?
>>
>>54407085
>custom string variable
clarify.
>>
>>54407095
non standard string variable
>>
>>54407108
use the pointer to the internal buffer of "non standard string variable" then
>>
>>54407108
>non standard string variable
clarify.
>>
>>54407146
clarify what to clarify
its a GS::UniString class
>>
>>54407175
>GS::UniString
Documentation for that class please.
>>
>>54407197
http://www.graphisoft.com/ftp/techsupport/documentation/developer_docs/AC15/GSRoot/GSRootHTMLLibrary/GS/UniString/UniString.html
>>
>>54407226
Alright. It seems that the class designer really doesn't want you to do that. There seems to be no way to access the private char array of that class, assuming there is actually one (maybe it's a wonky chunked linked list or god knows what, hell, that's the reason for encapsulation). The question is: why do you want to call strncpy_s? There must be another facility for transfering string content that's more appropriate for GS::UniString.
>>
>>54407275
Why not GS::UniString::ToCStr( ... )?
>>
>>54407349
oh nevermind me
>>
File: trains.webm (3 MB, 1280x720) Image search: [Google]
trains.webm
3 MB, 1280x720
>>54407085
>>54407085

That interface only has methods to get a pointer to a _constant_ characters array.
>>
>>54406109
This is not an anime image, delete and redo please.
>>
File: pc.png (378 KB, 1450x1080) Image search: [Google]
pc.png
378 KB, 1450x1080
>>
/g/ how do i actually git gud? There's only so many books I can read
>>
>>54407356
You mean GS::UniString? (I'm >>54407275) Agreed.
>>
>>54407361
Kill yourself
>please
>>
>>54407373
yes

http://www.graphisoft.com/ftp/techsupport/documentation/developer_docs/AC15/GSRoot/GSRootHTMLLibrary/GS/UniString/ToCStr.html

>A private object which can be implicitly converted to const char*.
>>
>>54407370
Practice. There's nothing that enhances your skills as much as developing software every day for hours and hours.
>>
>>54407385
agreed.

>Note that maximum length of a Pascal string is 255 characters.
top kek
>>
>>54407275
Well it was working before, when the data i have to modify was available directly(as char). They removed it and gave a function which returns this UniString. There might be another way to modify it, but I'm not sure. Will investigate next week and also ask in their dead forum. Thx anon, at least I wont waste more time trying this method.
>>
>>54407385
that didnt work, i get a cant convert gs::unistring::cstr to char or something like that. or i juat fucked it up
>>
>>54407411
>Thx anon, at least I wont waste more time trying this method.
You're welcome

>Will investigate next week and also ask in their dead forum.
way to go

>>54407437
No don't do that, anon wasn't saying it would work anyway. But yes, according to the documentation, the CStr is only a read only copy of the UniString: It can be converted to
const char*
, but never to char*.

http://www.graphisoft.com/ftp/techsupport/documentation/developer_docs/AC15/GSRoot/GSRootHTMLLibrary/GS/UniString/Constructors.html
>Content is converted to the Unicode representation using the default user locale.
So yeah. Now everything depends on what output your code is meant to produce. UniString or char[]? In the second case: allocate your own char array, strcpy the ToCstr() result into it, and modify it.
>>
What's an easy library or API I can practice with after I'm done with the standard library for C++?
>>
>>54407696
Qt
>>
>>54407696
win32
>>
File: 663394-bigthumbnail.jpg (44 KB, 450x299) Image search: [Google]
663394-bigthumbnail.jpg
44 KB, 450x299
https://www.youtube.com/watch?v=PxdPj6vm1Pg
>>
Hey /dpt/, guess what?
>>
has anyone here gone from knowing c# to knowing java? did it take long? from what i've seen the languages are pretty much identical but i'd like to check before i apply for a job doing java thx lads
>>
char c;
int i;
c == 'A' ? i++: ((void)0);


is this bad practice? i think its easier to read these ternaries but they need a nop to work
>>
>>54407905
If you're sure it's going to stay as-is, then you might as well use a one-line if for readability.
char c;
int i;
if (c == 'A') i++;


Best practice would be to add brackets, so that in the future, if you want to do something in addition to incrementing i, it's easy to add:
char c;
int i;
if (c == 'A')
{
i++;
}
>>
>>54407760
>writing 140 lines to draw a window with "hello world"
>>
>>54407905
#define noop ((void)0)

c == 'A' ? ++i : noop;
>>
File: 235235.jpg (63 KB, 845x506) Image search: [Google]
235235.jpg
63 KB, 845x506
>>54407950
>best practice would be to add brackets
stop
>>
>>54407980
t. someone who doesn't work with other people on large projects
>>
>>54407988
this isnt /gsg/
>>
>>54407950
>first bracket on a new line
please kill yourself
>>
File: what??.jpg (29 KB, 800x534) Image search: [Google]
what??.jpg
29 KB, 800x534
>>54407888
what, mr trips?
>>
>>54407980
I'm getting the habit to do

if(var)
{
do_something();
}


instead of

if(var)
do_something();
>>
>>54408030
ffffffffffffffffffuck dynamic typing
>>
>>54407950
>>54408016
Ignoring the fact that YOUD GET A COMPILER ERROR BECAUSE c HAS NO VALUE
you should generally use
char c = 'A';
i += 1 && (c == 'A');
>>
>>54407888
>>54408033
>trips then dubs

inb4 singles
>>
>>54408064
I literally don't know how to get singles.

3

And fuck duck typing.
>>
>>54408063
>1 && (c=='A')
I like this anon
How about
1 & ~(c - 'A')
>>
>>54408016
visual studio doing its magic
>>
>>54408087
You can change this behavior if you prefer.
>>
>There are people who actually dislike Allman braces

It's 2017, folks.
>>
>>54407980
>>54408016
>thinks saving lines and brackets is more important than readability/understandability

If you ever find yourself in a professional setting you'll realize that your code golf attempts do not impress, only annoy.
>>
>>54408147
Allman braces a best
>>
>>54407970
>python baby
>>
>>54408167
>baby can't understand standard c
get out
>>
>>54408167
>not using braces for a single statement
>code golf

Jesus Christ kill me now
>>
Hindley-Milner type inference is based and lazy evaluation by default is for faggots
>>
you're all fucking terrible at programming
>>
>>54408385
:3
>>
>>54408385
at least im cute
>>
>>54408421
you're not cute you're delusional
>>
File: baka3.png (155 KB, 500x500) Image search: [Google]
baka3.png
155 KB, 500x500
>
s.AuthentificationInfoValue = new IntermediaAccountService.AuthentificationInfo();

>Authentification

I FUCKING HATE MAINTAINING THIS PARTICULAR CODEBASE

I SAT HERE AND QUESTIONED MY CONCEPT OF ENGLISH FOR LIKE 4 MINUTES WHEN I READ THIS

FUCK
>>
>>54408441
plz no bullying
>>
>>54408452
pajeet
>>
>>54408452
it's valid french lmao
>>
>>54408452
this is C# right? is there no #DEFINE-like statement? I don't remember.
>>
File: indians.png (5 KB, 235x117) Image search: [Google]
indians.png
5 KB, 235x117
>>54408452
>>54408491
>Authentification
>upgradation
>do the needful
>please revert my email with questions
>updation

fucking indians leave reeeeeeeeeee

I'm the white person that has to be competent and clean up their messes.
>>
>>54408513
>is there no #DEFINE-like statement?
There's literally a #define statement, but it doesn't work quite the same way, IIRC.
>>
>>54406492
Hungarian warts are fucking disgusting, don't blight your code with them.
>>
File: hx.webm (3 MB, 640x360) Image search: [Google]
hx.webm
3 MB, 640x360
>>54407905
yes.

c == 'A' && i++;
is what you want

https://ideone.com/SSZn3B

>>54408385
>>54408441
Please don't bully.

>>54408327
>lazy evaluation by default is for faggots
But my Lambda calculus ? (´・ω・`)
>>
>>54408567
That's not Hungarian notation. More like pseudosigils à la Perl/Ruby/QBasic.
>>
>>54408567
u just jelly cause we are better
>>
>>54408527
Janitors >>>/out/
>>
>>54407980
Apple's goto fail bug wouldn't have happened if they used braces. Or at least it would have stuck out very obviously.
>>
>>54408739
Unless they misplaced the braces, in much the same way they made the original mistake
>>
>>54408739
>we need to baby proof everything
fuck off, try "html programming" instead
>>
>>54408763
>much the same way they made the original mistake

They didn't use braces in the now-famous 'goto fail' bug.
>>
File: 1445975592163.png (158 KB, 342x366) Image search: [Google]
1445975592163.png
158 KB, 342x366
Why it is so hard to get in programming
>>
>>54408774
<- the point <-
... 1000+ meters
you =_=
>>
>>54408800

The mistake wouldn't have been made, that's the point. Braces offer visual cues.
>>
>>54408799
because you are bad and you should feel bad
>>
>>54408799
you need a skirt
>>
catch (DivideByZeroException xx) if (DateTime.Now.DayOfWeek != DayOfWeek.Sunday)


Because heathens shouldn't get working code on the day of the lord.
>>
>>54408880
>>>/wdg/
>>
>>54408739
>wouldn't have happened if they used braces
Or, you know, used their fucking eyes.
How you miss
goto fail;
goto fail;

is beyond me.
>>
>>54408799
Because you're a weebo NEET piece of shit whose personal virtues amount up to being a lazy, whimful brat with no back-bone, or determination to do anything that require the least bit of effort and persistence; anything you do that does not reward you with instant gratification is put to the side once your pitiful will drains out of your empty skull.
>>
>>54408892
word
I don't post on /g/, polite sage
>>
hi, does anyone know how to put this jumpForce on the x axis in a 2d game on unity
with c#


if (walled && !grounded && Input.GetKeyDown (KeyCode.Space)) {
anim.SetBool ("Wall", false);
rb2d.AddForce (new Vector2 (14, jumpForce), ForceMode2D.Impulse);
thenksu alot
>>
>>54408912
>>>/v/agdg
>>
>>54408763
This was the code. Because both gotos are indented, they look like they are both part of the if statement, but they aren't.
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
goto fail;
goto fail;


If the braces are placed like this it's obvious that something is wrong.
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) {
goto fail;
}
goto fail;


If the braces are placed like this, both gotos are part of the if, same is the indentation implies. The code is wrong, but the bug won't happen because the second goto is never reached.
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) {
goto fail;
goto fail;
}


If the braces are placed any other way, it would require editing the code without paying any attention to what it's doing, in which case nothing would help.
>>
>>54408880
>>>/g/wdg

And yes.

protected void cbxHideThing_CheckedChanged(object sender, EventArgs e)
{
if (cbxHideThing.IsChecked)
{
UserEmail.Visible = false;
}
else
{
UserEmail.Visible = true;
}
}
>>
>>54408912
>2d game on unity
kys
>>
>>54407366
I'm colorblind. Which ones are green?
>>
>>54408939
>if (bool) bool2 = false; else bool2 = true;

Jesus Christ
>>
>>54408944
the words "easy, medium, hard" are color coded, use an image editor if you can't tell them apart
>>
>>54408944
>>54408964
Not the most useful comment, but yeah, I guess it's valid.

Just FYI daltnon: Only the numbers are colored, not the problem statement.
>>
>>54408912
the vector2 is a two dimensional vector of (14, jump force), so if you want jump force on the X axis just flip them. 14 can become whatever feels right...I guess.
>>
File: dptrollimageforcolorblind.png (679 KB, 1450x1080) Image search: [Google]
dptrollimageforcolorblind.png
679 KB, 1450x1080
>>54408944
Here, I highlighted the green ones.
>>
>>54408960
What if you want to add an audit log later that logs the change?

It's easily modifiable to add additional logic around the current statements.
>>
>>54408993
thanksu alot, dat was helpful !
>>
>>54409015
>What is programming?
>>
>>54409015
>What if you want to add an audit log later that logs the change?
UserEmail.Visible = cbxHideThing.IsChecked;
if (!UserEmail.Visible) log("whatever\n");

Still easier and shorter in spite of your stupid point.
>>
File: dptrollimageforcolorblind.png (598 KB, 1450x1080) Image search: [Google]
dptrollimageforcolorblind.png
598 KB, 1450x1080
>>54408944
>>
>>54409040
And if you wanted to do something different in both cases?
>>
>>54409040
this will run even if visible was equal to IsChecked before that -> doesn't log the change
>>
>>54408772
>>we need to baby proof everything

Evidently we do you retard. We get it, you're the pinnacle of a software engineering and everyone else is an inferior simpleton who gets in your way of writing nothing but the finest solutions in opcode. The fucking arrogant autists in this industry I swear.
>>
>>54409040
>
UserEmail.Visible = cbxHideThing.IsChecked;

Congratulations, you're a fucking idiot.

The box is clearly labeled 'HideThing' and you're showing the thing if it's checked.
>>
>>54409055
then you'd put that in from the fucking start or change it when it's needed, dumbass
what if you wanted to not have 7 lines of code for half a line of functionality?
>>
>>54409055
UserEmail.Visible = cbxHideThing.IsChecked;
if (!UserEmail.Visible) log("whatever\n");
else log("coding superpowers");

>>54409068
Neither does your version...
saveVisible = UserEmail.Visible;
UserEmail.Visible = cbxHideThing.IsChecked;
if (!UserEmail.Visible != saveUserEmailVisible) log("oh shit it changed!\n");


> preparing the code for further modification
This is dumb, modification is modification, it still has to be done regardless. No really, am I being dumb or is it you? Please show a concrete example of a benefit of this method.

>>54409099
>what is negation operator
I see now, but I was intentionnaly careless and I recognise it. Besides, that's why debugging was created, we all make mistakes.
>>
>>54409055
Then you've got more logic and would change to block structure. Apply as much common sense as you can afford.
>>
>>54409140
>being this verbose
log((UserEmail.Visible = !cbxHideThing.IsChecked) ? "whatever\n" : "else\n");
>>
>>54409142
>>54409140
>change to block structure
>all these one-liners

Now, I understand that this is all opinion-based, but if you're not a NEET you'd understand that clarity and easy modifications are the bread-and-butter of working with many people on the same project.

The initial example, while a bit spaced out, is easy to read for the most retarded of programmers, and easily changed if needed.

Also, the clarity that comes from the explicit 'true'/'false' assignment helps to avoid mistakes like your lack of the negation operator.

I understand your intentions, but the code-golfing just annoys people in the professional world.
>>
>>54409173
That's where I draw the line personally. Thank you for participating
>>
>>54409198
This isn't Code Golf you muppet, I'm gonna fucking say that again until you understand.
a = !b is NOT FUCKING CODE GOLF
>>
>>54409229
In your example, extensibility for the true and false responses to the checkbox results in either continuing to create ternery/one-liner IF statements, or just refactoring to a block.

The preferred method in most group efforts is to start with the block in the first place.

Calling it 'code golf' is hyperbole, but the point remains.

Concision is fine in some circumstances, but it can be troublesome more often than not.
>>
Can someone explain to me whats so bad about
system("");

and what Im supposed to used instead?
>>
>>54409273
not portable. if you're ok with that, use system(). otherwise, use portable libs that accomplish the same task.
>>
>>54409198
>Now, I understand that this is all opinion-based, but if you're not a NEET you'd understand that clarity and easy modifications are the bread-and-butter of working with many people on the same project.
Which your example doesn't embody one bit.

>Also, the clarity that comes from the explicit 'true'/'false' assignment helps to avoid mistakes like your lack of the negation operator.
Fuck no, it's not clear. It takes brain time to realise "OK, he's putting in true in the case where isChecked is false, but false in the case where isChecked is true, so yeah, that's basically a negation, I get it".

Besides It's as easy to flip true and false literals than to not put a negation. Also negation is a concept, showing in code that visible gets assigned the opposite of hidden is, again, as clear as you can get.
hidden = visible
can be spotted as a countersensical thing to do more easily, that's undeniable.
>>
>>54409261
>extensibility
>block
>the point remains

Just leave you moron.
>>
>>54409094
>Evidently we are babies
that's why you should stick to html
>>
>>54409294
Again, that's, well, like...your opinion, man.

And you're welcome to program that way unless you work somewhere that enforces particular stylist choices.

>FUCK THAT I'LL WALK OUT OF THE INTERVIEW FUCK THOSE COMPANIES THAT DON'T DO THINGS EXACTLY HOW I WANT TO DO THEM
>>
>>54408884
anon pls, you cant do that, a man works when he wants
>>
>>54408772
using braces isn't baby-proofing, it's common sense and the established programming practice*

*not counting retarded allman C#
>>
Can someone help me understand why this is happening? I'm trying to use DataView in JS but I'm getting some weird results:

x = new DataView(new ArrayBuffer(4));
x.setUint16(0, 6000);
x.setUint16(1, 6000);
// x should now be two 16 bit unsigned ints in succession

x.getUint16(0) //5911 <-- what? shouldn't it be 6000?
x.getUint16(1) //6000
>>
>>54409370
Wait, nevermind I'm a complete moron. The offset should be 2, not 1.
>>
File: 1443878595513s.jpg (5 KB, 125x125) Image search: [Google]
1443878595513s.jpg
5 KB, 125x125
>>54409348
Programming is more that It Just Works®. This kind of activity is a disgrace, an insult to the field as much as advertising insults the liberal arts. We seek clarity and understanding, abstraction, not superstitious writing of superfluous brace groups.
>>
>>54408739
it's a duplicate line error. braces doesn't necessary protect you from that.

gcc now warns you if you have a line on the same level of indentation of a previous if.

if (..)
..;
..; // this line throws a warning with gcc 6.x
>>
>>54409293
How is it not portable?
>>
>>54409198
If this confuses the developers on your team:
if (x)
doStuff();


then you've got serious issues that code formatting can't fix. I suggest getting another job, or move away from Java to Scala where the idiots can't follow.

The same applies to having people on your team who abuse ternary ifs, macros and bit-twiddling without a bloody good reason. It's not like there's a lack of jobs for a good developer.
>>
>>54409362
Not in God's country, he doesn't.

Captchas made to force you to look up specific bible verses to complete them.
>>
>>54409412
For one thing, the docs says it is:
>The effects of invoking a command depend on the system and library implementation, and may cause a program to behave in a non-standard manner or to terminate.
Secondly, consider this call:
system("sudo rm -rf ./");

which will fail in windows but succeed in linux
>>
>>54409412
the command may not execute on other systems
>>
>>54409412
As for
system("");
, it doesn't pause on GNU/Linux
>>
>>54409467
that doesn't make system() not portable. just the command you passed.
>>
>>54409428
>Gods country
since when is it the property of any god? its OUR country, you filthy traitor.
>captchas made to force you look up a term in a science book
i like this idea, i really do
>>
>>54409493
argument to semantics, classic
>>
>>54409493
> splitting hair in 4294967296
>>
>>54409399
>superstitious syntax
Literally the perfect phrase for it.
>>
>>54409508
im say one could pass different commands for different systems using system(). that makes it pretty portable.
>>
>>54409546
that's assuming you know every system it's going to be run on
>>
>>54409365
>waaaaaaaah
sure thing, baby
>>
>>54409546
if you consider that portable, by all means go ahead and write it
>>
>>54409293
>portable libs that accomplish the same task
which boil down to
system("");
>>
Can someone explain to me how the fuck this works?

This is in order traversal of a binary tree, I can not wrap my hand around how it works at all.

public void display(Node root)
{
if(root!=null){
display(root.leftchild);
System.out.print(" " + root.data);
display(root.rightchild);
}
}

To me, in this form. I interpret it as this:

display(root.leftchild);
display(root.leftchild);
display(root.leftchild);
called x number of times down till we get to the left most node.

But then, how the fuck does it progress any further than that? Even if the root becomes null, the System.out.print statement shouldn't print because it's in the if statement???

The fuck??

How does it even make it to the print statement? Isn't it every time we call display, we end up at the beginning of the function again?
>>
>>54409571
you're the baby since you can't handle that people aren't too lazy to put braces around an if statement
>>
>>54409586
Consider code tags, anon.
>>
>>54409593
>waaaaaaaaaaah
you should know this subreddit is 18+
>>
>>54409579
Clearly not! Libraries don't boil down to executing external commands, external commands call libraries with an unnecessary indirection. Do you really believe there's no way to "pause", as the windowsians do, without an external command?
>>
File: PerspectiveProjection1.gif (13 KB, 470x346) Image search: [Google]
PerspectiveProjection1.gif
13 KB, 470x346
>>54409605
>>
>>54409621
>baby got told
>>
>>54409608
go on, enlighten us
>>
>>54409586
gotta love baby's first recursion
>>
>>54409586
display a node:
display the left node
display this node's value
display the right node
>>
>>54409638
>I'm this dumb
>>
>>54409636
kill yourself idiot you suck fucking ass at programming, pointlessly omitting braces is a nasty habit
>>
>>54409638
>PROVE ME WRONG!
please...
>>
>>54409557
>>54409575
well the alternative is finding a library for whatever you want to do running natively on each target system. system() is sometimes useful and much simpler. not always.
>>
>>54409653
>i'm trolling this hard
PUT UP OR SHUT UP FUCKING IDIOT
>>
>>54409645

I don't understand. How can you have statements after a recursion call?
>>
>>54409655
>syntax is too complicated
back to school, kid
>>
>>54409586
There is a call stack, anon. Each invokation of the function is different from the calling stack frame, and upon returning, whether it be to the same function or to a different one, execution jumps back to the calling point.

You're thinking too low level IMHO. It doesn't matter that we use the same function to do a part of the task or a different function: there is an abstraction that lets us call a function and then continue onwards from the calling point, and it works even if the function is recursive.
>>
>>54409681
>literally projecting this hard
fuck off kid
>>
>>54409668
>tard rage
read a book, anon
>>
I have no programming experience.
Is there are tutorials you can recommend to start learning C++ ?
>>
>>54409680

Wait a minute, does it make a new instance of the function that goes along simultaneously with the other ones?
>>
>>54409680
Because it doesn't terminate the function. You can consider the recursive call, then come back up and consider the statements that follow it, just as if a normal function call had taken place.
>>
>>54409680
>what happens when a function returns
>>
>>54409691
>waaaaaaaaaah
>pls no bully
you know what to do, kid
>>
>>54409696
joke's on you, you're the tard, you have nothing to back yourself up, you have no book or anything which says how to pause an application in a better way than using a syscall
>>
File: PFjBvPF.png (37 KB, 619x734) Image search: [Google]
PFjBvPF.png
37 KB, 619x734
some posts omitted

/dpt/ in a nutshell
>>
>>54409709
YES EXACTLY

Or almost, it's not simultaneous/parallel, the parent invocations are suspended as long as the child runs, just like regular function calls.
>>
>>54409467
>>54409481
>>54409482
Okay that makes sense then. But its not really a program since its for recreational use and pretty much everything I do recreationally is done of windows.

Thanks.
>>
>>54409720
>using a syscall
you don't even know what that is, kid; please leave
>>
>>54409720
syscall = system call != a call to the function system, which serves to invoke external commands
>>
>>54409723
you sure are butthurt to hide
>go on, enlighten us
>>
>>54409723
looks ok to me
>>
>>54409681
not him but you should definitely kill yourself you autistic fuck. leave /g/, and preferably leave this world too.
>>
>>54409725

Oh shiet, thanks man
>>
>>54409731
>>54409736
i don't give a fuck, i don't use system("") or whatever, but you still have fucking nothing, you just believe in some magical library that will solve it in some super elegant way but when you really look at it it's as stupid as 'left-pad'
>>
File: BSjMUsG.png (15 KB, 696x285) Image search: [Google]
BSjMUsG.png
15 KB, 696x285
>>54409741
I have not participated in this discussion, anon.

You would see (You)s and highlights next to posts I responded to or wrote.
>>
>>54409750
>not him
baby...
>>
>>54409757
>proud to be dumb
well then, time to go!
>>
>>54409761
http://lostallhope.com/suicide-methods
>>
>>54409773
that is some low effort trolling fuck off to /b/ lad
>>
File: eg 1.png (14 KB, 1073x201) Image search: [Google]
eg 1.png
14 KB, 1073x201
>>
>>54409774
Please, kid, you're embarrassing yourself!
>>
>woops

    1 -     0 :     2 -     0 :     3 -     0 :     4 -     0 :     5 -     0 :     6 -     0 :     7 -     0 :     8 -     0 :     9 -     0 :    10 -     0 :     1 -     0 :     2 -     0 :     3 -     0 :     4 -     0 :     5 -     0 :     6 -     0 :     7 -     0 :     8 -     0 :     9 -     0 :    10 -     0 :     1 -     0 :     2 -     1 : ***************    3 -     0 :     4 -     0 :     5 -     0 :     6 -     0 :     7 -     0 :     8 -     0 :     9 -     0 :    10 -     0 :     1 -     0 :     2 -     1 : ***************    3 -     0 :     4 -     0 :     5 -     0 :     6 -     0 :     7 -     0 :     8 -     0 :     9 -     0 :    10 -     0 :     1 -     0 :     2 -     1 : ***************    3 -     0 :     4 -     0 :     5 -     0 :     6 -     0 :     7 -     0 :     8 -     0 :     9 -     0 :    10 -     0 :     1 -     0 :     2 -     1 : ***************    3 -     0 :     4 -     0 :     5 -     0 :     6 -     0 :     7 -     0 :     8 -     0 :     9 -     0 :    10 -     0 :     1 -     0 :     2 -     1 : ***************    3 -     0 :     4 -     0 :     5 -     0 :     6 -     0 :     7 -     0 :     8 -     0 :     9 -     0 :    10 -     0 :     1 -     0 :     2 -     1 : ***************    3 -     0 :     4 -     1 : ***************    5 -     0 :     6 -     0 :     7 -     0 :     8 -     0 :     9 -     0 :    10 -     0 :     1 -     0 :     2 -     1 : ***************    3 -     0 :     4 -     1 : ***************    5 -     0 :     6 -     0 :     7 -     0 :     8 -     0 :     9 -     0 :    10 -     0 :     1 -     0 :     2 -     1 : ***************    3 -     0 :     4 -     1 : ***************    5 -     0 :     6 -     0 :     7 -     0 :     8 -     0 :     9 -     0 :    10 -     0 :     1 -     0 :     2 -     1 : ***************    3 -     0 :     4 -     1 : ***************    5 -     0 :     6 -     0 :     7 -     0 :     8 -     0 :     9 -     0 :    10 -     0 :     1 -     0 
>>
>>54409515
I'm downloading that car.
>>
>>54409792
no, you are, you think if statements shouldn't have braces, now THAT is embarrassing
>>
>>54409782
>so dumb I don't even understand the quote
are you from tumblr?
>>
>>54409790
And that's why you use monads
>>
>>54409757
We say library, but half of the time it's a standard library function that's cleaner and safer, like
system(sprintf("rm -f %s", file))
(I know sprintf doesn't work like that, I don't care, it's for illustration) and
removefile(file)
. As for the remaining half, the external command already does it, so either it's some arcane source code, or there is already a way and a library to do it. Or do I not understand your point?

Yes, if you ask us for a generic way to replace every misled external command invocation with something equivalent automatically, there is none, but it's possible to do case-by-case for a human being.

Also system/exec have legitimate use cases, like shells for example, I reckon
>>
>>54409813
quit wasting my time stupid /b/tard
>>
>>54409805
>you think
what does the language designers think? you might be surprised, retarded baby!
>>
>>54409821
Trees aren't monads
>>
>>54409831
>beyond retardation
/g/ is not for you, m8
>>
>>54409761
No, I'm literally a bystander here who noticed what a waste of space you are by reading your posts. I don't even give a shit about if you use braces or not, just kill yourself.
>>
>>54409832
WHICH LANGUAGE DESIGNER

WHICH LANGUAGE

FUCK OFF TARD

>inb4 C#
C# IS FUCKING RIDICULOUSLY SHIT SERIOUSLY KILL YOURSELF
>>
>>54409851
>got told so hard I need to pretend from now on
ok
>>
>this is what /dpt/ has become now
kill me
>>
>>54409855
>REEEEEEEEEEE
kid...
>>
>>54409897
>I'm new
>>
>>54409844
Yes they are. Monads are exactly like trees. Bind takes a normal value, like an apple and turns it into a tree. Fmap can take a function, like a fork, and a monad, like an apple tree, and turn it into a different monad, like an applesauce tree. Join takes an absurd tree of apple trees and turns it into an apple tree. So monads really are like trees.
>>
>>54409851
>>54409855
>>54409885
>literally 6 seconds between the two replies telling him to fuck off
>such an over-inflated ego that he couldn't possibly think people hate him
>>
>>54409855
>C#
Sounds like you're projecting, anon! :^)
>>
>>54409899
the joke's on you, you're wasting your time, you're doing nothing useful, you're a pathetic joke of a creature
>>
>>54409920
>bind
you mean return
>>
>>54409920
Trees are not monads.
For instance, how do you Join a tree of trees?
>>
>>54409928
>you
>you
>your
>you
>you
Are you mad by any chance? :^)
>>
Bitwise AND 1024

What does this mean?

Say, the number is 16506 or 19578.
>>
Quick, gee, how do I average 2 ints?
>>
>>54409977
Plain binary or 2s complement? (for each one)
>>
>>54409977
>Parse error: unexpected garbage, expected structured English discourse
>>
>>54409988
Add them and divide by 2
>>
>>54409969
i'm mad but mainly not because of (You)

but ok you win the internets

congratulations you're retarded.jpg
>>
File: sicppat.jpg (286 KB, 1024x768) Image search: [Google]
sicppat.jpg
286 KB, 1024x768
>>54409977
checks if the 10th bit is on.
>>
>>54410009
No workee.
>>
>>54409995
>>54410001
In MySQL, the Bitwise AND operator:

SELECT 30 & 14;

>14
SELECT 29 & 15;

>13
SELECT 29 & 50;

>16

?????
>>
>>54410026
I assure you that's how you average 2 integers
>>
>>54410016
We did it, /g/!
>>
>>54409855
>C# IS FUCKING RIDICULOUSLY SHIT

lmao
>>
>>54409988
If you want to be safe, do this I think:
(+ (div a 2) (div b 2) (div (+ (mod a 2) (mod b 2)) 2))
Thread replies: 255
Thread images: 24

banner
banner
[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.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.