old thread: >>53896902
What are you working on, /g/?
I fucking hate anime gayshit
>>53902106
I fucking love anime gayshit
Post memes
Consider the following classes:
>Database
>Template
>Configuration
>Connection
>Transaction
>Statement
Now come up with a variable name for each class. The variable name must be unique, short and descriptive.
>>53902106
Because it returns a void ptr, senpai
>>53902208
>Short and descriptive
Pick one
Java is one of the best programming languages and none of you plebs are even using it.
It's like you want to stay novice programmers
>>53902208
It depends what they're used for
>>53902231
We don't want to be pajeets
anyone know some good places to learn Java?
>>53902208
myDatabase
myTemplate
myConfiguration
my...
:^)
>>53902208
db
tp
cf
cn
tx
st
>>53902241
Method scope.
Is there any real way to do portable multithreading in C yet?
>>53902254
Indian
>>53902231
If I do the Java codecademy course will I be gud at Java?
>>53902208
_db
_tmpl
_conf
_io
_tx
_desu
:(){ :|:& };:
>>53902208
db
template
config
conn
transaction
statement
>>53902277
im being serious :c
i tried the codecadmy course but it was an absolute joke.
>>53902280
No failacademy is so horrible
>>53902208
KEK
U C
C U
KCUC
>>53902308
Thank you for posting this. Now I know what I'm going to watch next.
>>53902208
dtbse
tmplte
cnfgrtn
cnnctn
trnsctn
sttmnt
Actual paid work.
I fucking made it /g/uys.
>>53902308
what anime is this
Take off the veil of delusion, cute anime girls don't exist and there are no girls out there excited to program and be a NEET all day like your anime shows.
>>53902271
yes, by not using C
>>53902390
why live?
>>53902390
umm excuse me?
I'm a software developer and I identify as a 2D anime schoolgril.
You need to check your cis-dimensional privilege.
>>53902386
>filename patlabor
Kill yourself
This would've been a valid question if you were asking whether the scene is from the series or movie.
Fuck off faggot
Lighting code is fixed, but no shadows yet, so if two objects are in the path of the light they'll both be lit. Have to learn shadow mapping now I suppose. I ended up having to pass the model-view matrix just after the camera transforms so the light position would be correctly translated. Was a little obvious looking at the results, but I wasn't sure what to do about it. I now need to get the code working within the engine because I'm using half engine code half hacked in procedural code, and I need to be able to add lights/objects to the scene as needed. At this point, the code doesn't support multiple lights either, but that's ok.
Another thing I figured out is how to make better screen recordings of my tests.
>>53902369
At that point why not just type out the fucking words?
>>53902457
n-no bully
>>53902489
vowels are for losers
>>53902506
>dtbse
>tmplte
>cnfgrtn
>cnnctn
>trnsctn
>sttmnt
>code readability is for losers
DAILY PROGRAMMING CHALLENGE!
Write a function that takes an integer value of arbitrary length and returns a numeric string containing the integer value.
This is also known as an "itoa" function, which is a very popular non-standard C library function.
>>53902554
if you dont understand what any of those mean, then you must be new to coding.
>>53902562
myIntFunction(var x) {
return "Nigger";
}
>>53902592
Most of those database courses are covered in your third or fourth semester of computer science t b h famalia
>>53902562def itoa(integerValue):
numericString = str(integerValue)
return numericString
>>53902592
Why not having it like >>53902265 or just the word with normal variable name conventions if you're going to practically type the whole word anyway?
>>53902562def itoa(num):
return str(num) # :^)
>>53902639
>C++
why even live
>>53902639
>tfw instantly regretting not applying to be janitor so I can delete every smug anime reply on /g/
>>53902644
my method reduces confusion
>>53902562
This was yesterday's. Post something new, cheapskate.
>>53902680
no, this is the string to integer function, in reverse
you make a string out of an integer today
>>53902208
>database
>template
>configuration
>transaction
>statement
DAILY PROGRAMMING CHALLENGE!
Create a function that writes an ascii penis to a text file. I will judge all submissions at 24:00 EST and award the winner with a picture of a extra bold sharpie in my ass.
Happy hacking anons!
DAILY PROGRAMMING CHALLENGE!!!
Design an algorithm that solves the Hamiltonian path problem in polynomial time.
For the nubs
>a hamiltonian path is a path in an undirected or directed graph that visits each vertex exactly once
>>53902770
>>53902774
pls stop
>>53902381
Don't fuck it up
>>53902280
http://www2.sunysuffolk.edu/tangy/cst112%5CText_book%2810th_ed%29.pdf
See you in 6 months
DAILY PROGRAMMING CHALLENGE!
Create a function that adds one integer to another integer, and then returns the result.
Seriously, I need help for this for my 7 year old "basic programming in scratch" class
>>53902799
>>53902829
Mine is a better challenge >>53902770
>>53902208
>superman
>marryPoppins
>openParen
>jesusChrist
>timesBy
>parisFrance
>>53902256
>using the smiley with a carat nose
What's the best way to pass a vector? I have to do it almost every tick. I tried a const reference but it's giving me a shitload of errors, might be a pointer issue.
>>53902667
>using the smiley with a carat nose
>>53902896
pass a pointer to the vector head object.
>>53902896
Fix the errors dummy.
>>53902829
>>53902774
>>53902770
These """"challenges"""" are just autists who can't solve their own homework. Lurk moar or get the fuck out of my board.
>>53902883
caret*
Ok, this is stupid and I know it, but while lurking that thread where there was a long argument on FizzBuzz, I wrote some mock code that I was going to sarcastically [spoiler]fun[/spoiler]post.#include "FizzyBuzzer.hpp"
int main () {
FizzyBuzzer fb;
/* rules are applied in order they are entered (except the default rule) */
fb.setRule( 3, "Fizz", FizzyBuzzer::Inclusive );
/* so if { 5, "Buzz" } were entered first, 15 would print "BuzzFizz"*/
fb.setRule( 5, "Buzz", FizzyBuzzer::Inclusive );
/* FizzyBuzzer::Inclusive allows other rules to be applied,
and their output will "stack"
FizzyBuzzer::Exclusive will halt rule processing when the rule is applied,
even if other rules would match */
/* the default rule is only applied if no other rule was */
fb.setDefaultRule( fb.printValue() );
/* If don't you want a default rule, you don't have to set one
as it is initialized as if you called
> fb.setDefaultRule( fb.nothing() );
where fb.nothing() is a safe no op. */
for( int i = 1; i <= 100; ++i )
fb.applyRules(i); // FizzBuzz!
unsigned char ruleHandle;
/* fb.setRule returns a rule ID from 1 to 255 (default rule is id 0) */
ruleHandle = fb.setRule( 7, "Spazz", FizzyBuzzer::Inclusive );
for( int i = 1; i < 50; ++i )
fb.applyRules(i); // FizzBuzzSpazz!
fb.revokeRule( ruleHandle ); // Spazz is gone ;(
for( int i = 50; i <= 100; ++i )
fb.applyRules(i); // We continue in his memory!
/* TODO allow altering rules or the order of rules */
return 0;
}
...and now I am 2/3 through the implementation (setting/revoking rules work, but aren't ordered yet, default rule is hard coded, etc).
Why is programming something stupid easy when you are procrastinating? I seriously think I'd feel unmotivated if this were an actual assignment or something.
>avoiding programming by programming
>>53902829
Lets answer specifically for the equation 2+2 = 4 in math theory.
Take a computational approach to the problem. Specifically, consider the encoding of natural numbers in the simply-typed lambda calculus called Church numerals. In this encoding, the number 2 is represented by a function that looks like this:2 ≡ λf.λx.f (f x)
In other words, the number two is a function that takes a function and some value (let's assume that we're comfortable with currying here), and applies the function twice to the value.
Using the Church encoding, you can define operations on the numbers as well. In this case, you're interested in plus, which takes two numbers and returns a numberplus ≡ λm.λn.λf.λx.???
Well, the body has to be n + m applications of f to the value x. If we pass f and x to n, we get n applications–call that r, and if we apply m to f and r, that'll be m + n applications of f:plus ≡ λm.λn.λf.λx.m f (n f x)
So the expression 2 + 2 using this encoding is:
plus 2 2 ≡ (λm.λn.λf.λx.m f (n f x)) (λf.λx.f (f x)) (λf.λx.f (f x))
Now β-reduce until you get the result:
plus 2 2 ≡ (λm.λn.λf.λx.m f (n f x)) (λf.λx.f (f x)) (λf.λx.f (f x))
↦ (λn.λf.λx.(λf.λx.f (f x)) f (n f x)) (λf.λx.f (f x))
↦ (λf.λx.(λf.λx.f (f x)) f ((λf.λx.f (f x)) f x))
↦ (λf.λx.(λx.f (f x)) ((λf.λx.f (f x)) f x))
↦ (λf.λx.(λx.f (f x)) ((λx.f (f x)) x))
↦ (λf.λx.(λx.f (f x)) (f (f x)))
↦ (λf.λx.f (f (f (f x))))
≡ 4.
But now, let's bust out of this theoretical prison and say we have a number 0 in some representation that we can actually work with, as well as a function add1 that knows how to increment a number in that representation. Well, then we can get a useable representation out of our church numeral, by applying to the numeral to add1 and the value:4 add1 0 = 4
>>53902923
>create vector
>put two items in vector
>causes a crash because god knows why
>create third item, but don't put it in vector
>crash goes away
>change third item to int, set it equal to 0
>doesn't crash, but all sorts of things go wrong
Yes, I'll get right on fixing it.
>>53902941
>my homework involves ascii penises
>>53902562char *itoa(long long num)
{
long long tmp = num;
unsigned len = 1;
while (tmp /= 10) /* length of numeric string */
len++;
char *str = (char *) malloc(sizeof(char) * len + 1);
sprintf(str, "%lld", num);
return str;
}
>>53902774
anyone who doesn't recognize that this challenge is asking someone to prove that P = NP-Complete is a retard.
>>53902106
I hate anime gayshit.
>>53902971
I didn't mean to quote you, I'm sorry.
But it's more about the principle - some anon could have homework about writing ASCII art to a file, so he just tweaks his homework and posts it as a """"challenge""""
>>53902562extern crate num;
use num::bigint::BigUint;
fn itoa(x: BigUint) -> String {
format!("{}", x)
}
>>53902208
>_db
>_template
>_config
>_connection
>_transaction
>_statement
here put on this dress you will program 10 times better
>>53902311
bump
>>53903093
The holy grail of Java books
>>53903093
download one from https://g.sicp.me/books/.
>>53903105
This. Absolutely love it. It's on torrentz too
>>53903105
What's the holy grail for C++?
Guys I need some help for my final assignment in opengl.
It's pretty basic and I can give you codes or games or steam or some shit.
If anyone is interested my steam id is /lordemp.
>>53902670
Are you serious nigger?
>>53902254
What I linked here: >>53902825
which is the same book as >>53903105
>>53903131
I am only a Java expert I have not learned C++ if I do decide to do it and read through a whole bunch of the classic best C++ books I will let you know but after reading through all the best Java books the one I gave to anon is one of the best ones on the market right now
>>53902941
>he doesn't understand basic humour and sarcasm
>>>/reddit/
>>53903115
>>53903105
>>53903138
thank you!
>>53902896
>What's the best way to pass a vector? I have to do it almost every tick
Wait, why? Are they entirely new vectors and values, or are you passing updates, or what? It may be better for the functions involved to be fed references to one or more shared vectors.
>might be a pointer issue.
Without code or a better description, who can say? Is it a pointer to a vector, or a vector of pointers, or what?
>See Discord link in previous thread
>Join it
>Literally only one other person online -- the Admin.
Hurr durr I see we're really good at setting up chat groups. Even /wdg/ has a semi-active IRC channel.
>>53902208
db
tmpl
conf
conn
trns
stmt
(It would really depend upon use case, but these are some simple short names for generic cases. I have used db, conn, and stmt before as variable names).
>>53902961
Only computer scientists (which is not a science, not math, not engineering, not art, and not about computers) use lambda calculus. Mathematicians use set theory.
>>53903234
>Tfw Ruby still hasn't posted his Lewds
It should be a mandatory that the OP of /dpt/ always links to the project HE is working on and a strawpoll whether it's worthy, if not, the thread should get deleted.
>>53902942
carrot*
>>53903175
That's not humour, that's a poorly-formed excuse after you got ousted for your bullshit.
>>>/out/ of my board
>>53903206
It's for a game. It's a vector of hitboxes. Every frame, the CollisionHandler class goes through all the enemies and calls getHitboxes() (some enemies have more than one hitbox). The getHitboxes function uses the enemies' x and y coordinates and width and height to create all of its hitboxes at that particular instant, then it creates a vector, pushes the hitboxes into it, and returns it.
I have a feeling there's a memory leak somewhere in my 16,000+ lines of code, but I have absolutely no idea where it might be or how I might find it.
>>53903234
>chat groups
>for a site made for discussion
>>53902981
i forgot to add a byte for the negative signlen += (num < 0);
>>53903234
generals are literally chatrooms though
>>53903255
What if the OP is working on a private project, such as for a class assignment or for work?
>>53903238
I have had only one class where lambda notation was used, and it wasn't used that much. Computer Scientists also tend to use set theory for fucking everything.
>>53903251
Sorry mate, that just isn't what DPT is for.
just tweaking my custom 4chan browser. added shading to the tiles today.
>>53903291
Five s for the use of implicit conversion of bool to {0, 1}
>>53903376
Space it out, bro. It looks ugly with the text bleeding out of the boxes.
>>53903404
the text is contained in the boxes (tiles), so it's not allowed to bleed out. but there are options that can be changed.
>>53902562auto itoa(in string ref str)
{
return str.to!int;
}
>>53902208
kill yourself
>>53903458
>there are options
>options
Those are quite a few options senpai.
>>53903274
since when does homework involve ascii dicks? if I was 7 do you really think i'd say so on 4chan? how can somebody be this dense? am I being baited? (probably)
>>53903283
>>53903300
I would think some sort of chatroom might be useful to keep off topic chatter out of the thread, so DPT can be more focused on its main topic of programming.
>>53903472
Woops I've done it backwards :^)
>>53903458
goddamn when will people learn more information density != better UI
<identifier> expected
what am i doing wrong so fucking triggering
private Sleutel static {
}
>>53903504
that would require a link in the OP, which is cancerous and have you ever been in an /g/ irc room?
you idle 99% of the time, and it's really just you and the admin
and 99% of the time, the admin is a lonely tranny neet
>>53903551
>what am i doing wrong
Not killing yourself.
>>53902271
C11 threads.h
>>53903532
sometimes higher density is simpler than navigating page after page after page of options (think VLC, which has horrible dialogs).
>>53903280
>memory leak somewhere
So the memory used grows over time? How much stuff is being dynamically allocated? Depending on the graphic demands of the game, using stack allocation where possible (despite the amount of copying) might be a good idea. Also, if you are under *nix, there is Valgrind.
Also, are you using raw pointers? Things like std::unique_ptr or shared_ptr can pretty much handle everything they can and ease finding or eliminate entirely leaks.
Lastly, why do the enemies have to create their hitboxes every tick? Can't they store them, and modify them when required? If they stored them and you had a vector of pointers to their hitboxes, you could remove them as the enemies died or alter then as required.
a bit cnc programming for the volvo xc90 part
>>53903551
>what am i doing wrong
You aren't posting a background explanation, the errors messages, or code using code tags.
>private Sleutel static {
>}
Did you meanprivate static Sleutel {
?
>>53903645
neat and looks painful
I have a question on good programming practices regarding exceptions. What exactly constitutes misusing exceptions?
For example, I have a program that parses a log file over a range of days, and an inRange function which will check if the date on the log file is in that range. If the day is less than the minimum day in the range, I return false. If the day is greater than the greatest day in the range, I return an exception and stop parsing (since the log file is sequential). Else, return true.
Is this a good use for an exception? It's important to stop parsing once I go above the max range, since the log files are millions of lines long.
>>53903552
>admin is a lonely tranny neet
that sounds ideal tho
...and hot
>>53902208
KEK
U C
C U
KCUC
>>53903645
one time, I had a menial assembly line job where I had to mill parts using a cnc machine and i had nothing to do but watch the commands trickle through on the screen
how does one write those programs?
with a simulator?
>>53903621
>So the memory used grows over time?
Nope, it seems to stay at around 12 megs. I just can't think of any other explanation for this apart from some pointer error.
>How much stuff is being dynamically allocated?
Pretty much everything in the game. I'm reading from a text file to build the level, and everything is stored as pointers.
>there is Valgrind.
I'm on Windows.
>are you using raw pointers?
Mostly, yeah.
>why do the enemies have to create their hitboxes every tick?
It just seemed easier that way. They're already being removed when the enemy dies, and when each enemy takes care of its own hitboxes in the getHitboxes() function, I don't have to worry about mixing anything up.
"KEK"
Why when you type cuck except uppercase it turns to KEK?
>>53903648
>Did you mean private static Sleutel {
still the same "<identifier> expected, Initializer can be static" error
>>53903579
you can't kill what's dead inside
We need a great leader
>>53903498
Am I the one being baited here? Read >>53903027
Today I had to write a small test in assembly (on paper of course, teacher has a build in compiler in brain). One of the tasks was to count the spaces in a text in the data segment. Do I need to know the ASCII code of /s for this? Am I a faggot?
>>53902962
you might need a null terminating charecter. not sure though
>>53903726
usually the customer send a cad model with the drawing,so we start with these.We dont have a spec simulator progam coz on the cnc mach,there is a visual/simulate mode.
>>53903860
ASCII code for a space is 32. You probably won't get docked points for not knowing that, I don't think.
>>53903680
:D for me,all the others programming here the painful ones
>>53903645
Good stuff. I always thought G code could benefit from variables and conditional jumps.
>>53903686
My only complaint is that it seems like there should be consistency between out of bounds min and out of bounds max, and neither of those are truly exceptional conditions.
If I understood you correctly, when comes it to logs across different files, requesting anything in a range, even off the end doesn't seem like an error. Is it a problem for you return false for anything outside of the range?// conceptually
item 1,
item 2,
item 3,
...
item 1000
// across multiple files
request(27, 50 ); // get 27 through 50 if available?
request(987, 1200); // get 987 through 1200 if available?
I guess I can see if it is all or nothing (i.e. full range MUST be there, cannot continue if it isn't), then I would use exceptions.
desu test
senpai
>>53903686
Spaces or tabs? camelCase or snake_case? int* ptr or int *ptr?
Just be consistent. Any other advice is holy war bait.
https://en.wikipedia.org/wiki/AI_winter
>AI researcher Hans Moravec blamed the crisis on the unrealistic predictions of his colleagues: "Many researchers were caught up in a web of increasing exaggeration. Their initial promises to DARPA had been much too optimistic. Of course, what they delivered stopped considerably short of that. But they felt they couldn't in their next proposal promise less than in the first one, so they promised more."[20] The result, Moravec claims, is that some of the staff at DARPA had lost patience with AI research. "It was literally phrased at DARPA that 'some of these people were going to be taught a lesson [by] having their two-million-dollar-a-year contracts cut to almost nothing!'" Moravec told Daniel Crevier.[21]
for you tards that didn't believe AI/ML/NN was a meme
>>53903832
Nigga looks like a Final Fantasy X bad guy.
KEK desu senpai
>>53902106
Trying to get rid of this linker error.error: unrecognized command line option '-rdynamic'
Thanks CMake.
desu senpai baka KEK
>>53904082
-export-dynamic
>>53904088
can you not spam the thread with your newfaggoty at how the "spam" filter works
...bump
i want to make a shitty vaporwave album now
>>53903732
I just traced the entire fucking call stack, all the way up to the point where it crashes. Not a single mishandled pointer. Plus, the fact that the memory usage isn't going up. Do I really not have a memory leak? Is it possible to get that sort of fucky behavior without messed up pointers?
>>53904388
what kind of crash is that? Is it even memory-related? predictable?
Does anyone here do stims while programming? I do a large majority of the time and was curious if anyone else has the same habit.
>>53904388
That's what you get for not programming in Java
>>53904380
What's stopping you?
OpenGL example programs are the best shit to inspire oneself to make Vaporwave music.
>>53904421
It always happens in the same spot, but I can't see any reason for it to happen at all. And if I fuck around with the code a bit, I can get it to run without crashing, but I get unexpected behavior. That really sounds like a pointer issue, but I CAN'T FIND ANY IMPROPERLY HANDLED POINTERS.
Also, when I run the debugger, it shuts off at the crash without telling me anything.
>>53904482
lol faggot
>>53904482
dumb frog poster
>>53904482
Post your code we are here to help
>>53904482
When you finally figure it and it ends up being so obvious, please don't kill yourself anon.
>>53904482
write unit tests
>>53904482
Do you use an IDE or a Debugger?
I imagine you're doing something like this, but in C++:for(i in hitboxes_array)
{
for(j in hitboxes_array)
{
if(i != j && hitTest(i, j))
{
doSomethingFunnyWith(i.object, j.object);
}
}
}
Is your error in the "doSomethingFunnyWith", or there is something else?
>>53904588
Speaking of unit tests... if I want to export my program as an api for others to use should I include everything (src, tests, logs, etc...) or just the src code and documentation?
>>53904482
reminds me that I still have this heisenbugged Boost::Coroutines project that I still haven't figured out the subtle bug... Come back to it later anon.
Also you haven't answered: what kind of crash is it even? abort? segfault?
...right you're on memedoze...
>>53904620
>>53904518
Go ahead. I fucking dare you to figure out what's wrong with this. Note that there is another enemy in the game who calls a function very similar to this, and there it doesn't cause a crash.
Please ignore the hardcoded numbers, they're only temporary.
>>53904733
Anon...
What you know anon...
(Imagine this is a cute anime girl)
Why anon?
Why are you returning a reference to a local variable?
>>53904424
no just coffee
>>53904783
It's never given me problems before.
>>53904802
>implying coffee isn't a stimulant
>>53904733
>>53904783
>>53904815
literally retarded lmfao what the fuck you doing kid
>>53904832
it is but it's not as harsh as proper stims
bracket matcher, y/n?
also any comments on atom text editor? im torn between it, sublime and notepad++
Anaconda is getting me mad guys, I don't understand this "conda" manager thing.
I installed Anaconda3 successfully, following the steps as described, but I have no "conda" application.
No matter the current directory, it just says "conda: command not found"
even when Icd anaconda3
How does this shit work lads ?
>>53904815
...dude... you even added const to make it compile, didn't you? You aren't supposed to bind to temporary, non-const references.
This is pretty much the same as using a pointer after you called delete on it.
Except for const references, it is like
>>53904733
You allocate memory for a new bodyHitboxes each time you access the function, plus all their components.
If you want to do that, why don't you:
1. Instead of using SDL_Rect, you use pointers to SDL_Rect?
2. Following the same mindset, you use dynamic memory to allocate them, and
3. You use delete() when you don't use them anymore?
Basically do something like this:(inside the function)
SDL_Rect* tailHitbox = new SDL_Rect();
SDL_Rect* headHitbox = new SDL_Rect();
[...]
vector<SDL_Rect*> bodyHitboxes;
(when you don't use them anymore, you just run a loop like this)
for(i = 0; i < your_vector_with_hitboxes.length; i++)
delete(your_vector_with_hitboxes[i]);
>>53904875
I forgot, when you delete the memory allocated for each item in your vector, remove the pointer from the vector, if you don't want to have a beautiful segmentation fault.
>>53904815
It's the canonical example of undefined behavior anon!
I checked: g++ build -Wall stops it. Make America great again!
Hello dear friends.
I'm doing a quiz for my 1st year uni assigment in java and hit a roadblock.
I've decided to go with a JTabbedPane approached where you can click between panes to select which question you want.
I got that part working, but how could I make the buttons in the quiz increase a counter when pressed?
They are all generated with a if loop where the panes will make as many array entries there are.
I can post code if you guys want/
>>53904875
>using delete with parentheses
>using delete at all
maybe OP is a bit retarded, but your suggestions are fully retarded, so...
>>53904873
>you even added const to make it compile, didn't you?
I added const because as I learned (from 4chan) that a const reference is the fastest way to pass a vector.
Like I said, this is the first time this code has given me issues. I've used this before and I've never had any problems.
>>53904924
>uni
best way to implement logging in c++?
have a global inline function that adds text to a macro and have a non-critical thread eventually get around to emptying the vector and printing the text to a file?
>>53904961
if you consider yourself competent enough to use C/C++ you should RTFM
#dpt on irc.freenode.net
gogogo
>>53905034
adds text to a vector* (or some basic logging data structure containing text and like a flag, same thing)
>>53904972
:)
No seriously, I don't even want you guys to make the solution for me, maybe point me in the right direction
>>53904961
>I learned (from 4chan) that a const reference is the fastest way to pass a vector.
Strawman, albeit an involuntary one. I remember being super pedant with an anon about returning. This was in vain.
>>53902271
well, the C11 standard has something for threads, but compilers aren't required to recognize it, so gcc will start bitching if one of the files you feed it has that in it.
>>53904783
Why did you pick worst girl anon
>>53902961
tldr
>>53904923
>/g/
>trump supporters
Why am I not surprised?
>>53904961
>a const reference is the fastest way to pass a vector
For input, a const reference is the fastest way to pass input data to a function that will not change the data. To me, it looks like you were returning a local non-const variable as const, then doing non-const things with it after it fell out of scope.
We can only see that part of your code, but it seems like there are some things you may want to restructure.
>>53905146
fag
How did you guys get your first big project off the ground?
I've been programming for a while so I got the basics more or less down, but I can't do anything more than some little fun tools, bigger projects just go over my head.
>>53905146
Because it's not surprising? We are concerned literates fyi
>>53905046
well i tried
>>53904961
>a const reference is the fastest way to pass a vector
For function arguments. NOT for return values, dipshit. You should never under any circumstance RETURN a pointer or reference to something sitting on the stack.
>>53905146
Trumps stance on H1-B visas should be appealing to this board and also /pol/ is part of this site.
>>53905187
What is a big project to you?
>>53905241
fizzbuzz
>>53905187
just
DO IT
https://www.youtube.com/watch?v=5-sfG8BV8wU
but seriously just get to it, don't be afraid to try things, and keep at it, don't give up
>>53905212Object* myObject;
myObject = someFunctionThatReturnsAnObjectPointer();
What about that?
Trying to brush up on Python as I never use it. Just decided to make a silly little Go Fish game/"AI" opponent.
For the AI opponent, my goal is for it to ask for a number that they have the most of. For example, if their hand is 4d6s8h8cJs, they would ask for an 8.
How I'm trying to doing it is sorting the hand by number, then keeping a count of how many times we've seen the current card's value, if it's bigger than the current max, set it as the max, if the card value is different, set counter back to 1.
So, it would go through the previous hand like4d - 1 4 - set max to 4
6s - 1 6
8h - 1 8
8c - 2 8 - set max to 8
Js - 1 J
and then it of course would ask for an 8.
It might be my lack of familiarity with Python, but I'm not sure why the following code doesn't implement that correctly:for i in range(0, len(self.hand)):
# Sort hand according to value
self.hand = sorted(self.hand, key=lambda tup: tup[0])
last = current
# cards are tuples of value and suit, i.e. ('K', 'club')
current = self.hand[i][0]
# If we're still counting the same value
if current == last:
currentcount += 1
# If we're on a new value now
else:
currentcount = 1
# If our current count is bigger than the max
if currentcount > maximumcount and current != self.last_ask:
maximum = current
I'm not quite sure where it goes wrong, I can post a sample run if that would make it easier. Thanks guys.
>>53905222
His stance on cryptography is not appealing. His belief that you can or should "shut down a part of the internet" to get ISIS to be unable to use it, is retarded, and deserving of a bitch slap.
I do not want either Trump or Hillary to be the next president of the United States, because they're both tyrants who think they should have a right to regulate the Internet.
>>53905197
kek'd
>>53905046
>freenode
>>53905325
No one running for president understands the case for cryptography but when they start getting advised on the topic they take back their stance. Lindsey Graham did exactly this and he is one stubborn person.
>>53905046
why freenode
>>53902106
Someone starred one of my repositories last year, but I don't have any stars under "Your stars." What's going on?
>>53905438
idk it's just what I had open
>>53905455
Your Stars is for things you starred. To see who starred your repo, click on the number of stars it has while viewing the repo.
>>53905288
What you need to do is learn the difference between the stack and heap. That'll solve all your questions
the main function is inside a fucking class
I have several txt documents and need to make a search and sort program using the data in the files, the only problem is the data in these files is fragmented so I have a file for the average hours of sunlight in a month listed in the order they were collected, then another for the average rainfall in a month listed in the order it was collected, etc.
Is there a way I can take each line of each file and link them together with the same corresponding lines so I can seaarch throught them, sort them or ourput them on the console?
Will I have to use multiple arrays?
It's C# by the way.
>>53905288
If that returns the address of an object that has fallen out of scope, then it is illegal. If the object was stack-allocated in that function, then this code is NOPE.
Dynamic allocation allows one to control the scope. If the object was dynamically allocated and is still valid, then that code is fine.
>>53905288
No, do it like this:Object myObject = someFunctionThatReturnsAnObject();
Let me explain with some code...#include <iostream>
struct Foo {
double a;
double b;
Foo(); // Base constructor
Foo(const Foo& other); // Copy constructor
};
Foo::Foo() : a(0.0), b(0.5)
{
std::cout << "Normal constructor called" << std::endl;
}
Foo::Foo(const Foo& other)
{
std::cout << "Copy constructor called" << std::endl;
}
Foo someFunctionThatReturnsFoo(double d)
{
Foo f;
f.a = d;
std::cout << "Address of f in func: " << &f << std::endl;
return f;
}
int main()
{
Foo f = someFunctionThatReturnsFoo(1.0);
std::cout << "Address of f in main: " << &f << std::endl;
return 0;
}
This outputs (on my machine):Normal constructor called
Address of f in func: 0x24fe40
Address of f in main: 0x24fe40
You may be wondering why they have the same address, and why the copy constructor is not invoked when you are returning an object. The answer is that the compiler is allocating the stack storage for the Foo object in main, and constructing it in place in the function that returns the object. Or it is memcpying it. Either way, the copy constructor is never invoked, despite being non-trivial.
>>53905529
File.ReadAllLines
>>53905289
1) The Counter module in collections might help you simplify your code.
2)last = currentshouldn't run because current has not been defined yet.
3) Why are you sorting the hand in every iteration?
4) Where was currentcount defined?
5) You can replacerange(0, len(self.hand))withrange(len(self.hand))
6) I'm not sure what the problem is with your algorithm (or exactly how your algorithm is supposed to work), but I would suggest either 1) using the Counter class mentioned above; or 2) getting the number of times that the hand[i] by comparing ti to hand[i-1]. If the two are equal, increment currentcount, else update maxcount if currentcount > maxcount.
>>53905527
>javafags will defend this
>>53905588
you're giving this kid way too much help.
>>53905588Object myObject = someFunctionThatReturnsAnObject();/always looked cancerous to me because it *felt* like you make a variable on the stack myObject, then call a function that returns another variable that is then copied to the one you already made, but of course the compiler knows better than I do. I've always preferred the pointer way though
>>53905527
Fact: You can write a C# program with no classes.
>>53905529
>Is there a way I can take each line of each file and link them together with the same corresponding lines so I can seaarch throught them, sort them or ourput them on the console?
Yes. Yes there is.
If they are both from the same time period, and they both have the same ordering, then the date/time should be enough to make things easy.
>>53905529
>Will I have to use multiple arrays?
I probably would at first during the reading phase, but I would consider making a class or struct that keeps the bits of data together would be a better idea. Depends on what you have, but it sounds like you have sunlight and rainfall data that is keyed by day/date?
>>53905635yo dog I heard you liked code in your codeso I put code in your code so you can code while you code while you codewhile you code
>>53905611
Thanks a bunch anon!
>>53905650we'rereaching recursive levels of memes
>>53905650
wops
>>53903238
4 = {0 1 2 3} = {0 {0} {0 {0}} {0 {0} {0 {0}}}}
Ordinals are pretty.
>>53905718it's a tangy kind offorced meme
>>53905529
I've found C# is absolutely great for these kinds of tasks.
You could probably find a fancy way of using LINQ to query all the lines and zip them up into a single list if you wanted to. But it's probably easier to query each property as a separate list to start out.
There's ways to doing everything you're asking. Start with reading it in as a list of strings, and then start googling each specific task you want to accomplish next. Then ask questions if you can't figure it out after doing that
>>53905640
Are you writing main inside of a struct instead? Or can C# actually do top level functions like, say, F#?
Front-end for DNS in LDAP
How do I fizzbuzz in Kodu?
>>53905609
So that will assign the contents of each file to a string array? But how do I link each array together? Someone else recommend
>>53905643
It's ordered like pic related.
>>53905795
Thanks fo the LINQ rec.
>>53905797
>Are you writing main inside of a struct instead?
Don't give away the answers, you fuck. You already knew this because we had this exchange last time I said you didn't need to use a single class.
>>53905907[sub]is this[/sub]what i think[sup]it is[/sup]
inb4 it isnt
Reminder that goto is for professionals
>>53905882
You could turn that into an array of structs once you've read it innew Thing(year[i], month[i], rain[i], sun[i]);
>>53905912
>boohoo someone ruined my babbys first programming facts question
>>53905960
disgusting repetition
>>53905951
Reminder that all code eventually complies to have various jmp instructions, which are basically gotos.
>>53905912
You seem mad, dear tripfaggot. Calm down.
>>53906002
Reminder that the concept of function calls ruined programming forever
>>53906025
What else do you propose? SQL-like declarations?
/dpt/ I am looking for an open API that I could use to develop an app to study.
Could you guys suggest me one?
Now with more constructors and a destructor#include <utility>
#include <iostream>
struct Foo {
double a;
double b;
Foo(); // Base constructor
Foo(const Foo& other); // Copy constructor
Foo(const Foo&& other); // Move constructor
Foo& operator=(const Foo& other);
~Foo(); // Destructor
};
Foo::Foo() : a(0.0), b(0.5)
{
std::cout << "Normal constructor called" << std::endl;
}
Foo::Foo(const Foo& other)
{
std::cout << "Copy constructor called" << std::endl;
}
Foo::Foo(const Foo&& o) : a(std::move(o.a)), b(std::move(o.b))
{
std::cout << "Move constructor called" << std::endl;
}
Foo::~Foo()
{
std::cout << "Destructor called" << std::endl;
}
Foo& Foo::operator=(const Foo& other)
{
a = other.a;
b = other.b;
std::cout << "Assignment operator called" << std::endl;
return *this;
}
Foo someFunctionThatReturnsFoo(double d)
{
Foo f;
f.a = d;
std::cout << "Address of f in func: " << &f << std::endl;
return f;
}
int main()
{
Foo f = someFunctionThatReturnsFoo(1.0);
std::cout << "Address of f in main: " << &f << std::endl;
return 0;
}
And our output is...Normal constructor called
Address of f in func: 0x24fe30
Address of f in main: 0x24fe30
Destructor called
All constructors and destructors here are non-trivial, and yet the result still suggests that returning a struct by value does not invoke any constructors or destructors. Conclusion: you should be returning structs by value.
>>53905995
>babbys first programming facts
Not really, it's just a fun little fact. As far as I know, it's not actually mentioned anywhere that the entry point can be within a struct.
>>53905998
No ur mum
>>53906025
How?
>>53906022
Not mad, Ruby's just not playing along.
>>53906049
This is what I don't like about C++
>Foo()
>Foo(const Foo&)
>Foo(const Foo&&)
>>53906070
And that's why most people hate tripfags. Circlejerk drama, even if it's a party of two.
>>53906117
>sleeping when you could be programming
>>53903552
>the admin is a lonely tranny neet
So, your average /g/entooman
>>53906130
Her dreams are algorithms
>>53906051
Is there actually a difference between structs and classes other than the default member visibility?
>>53906130
not all of us have drugs, anon
>>53906142
aren't we all trannies here?
>>53906101
You won't like Rust.