[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: 39
File: 1467570941060.jpg (517 KB, 1521x1076) Image search: [Google]
1467570941060.jpg
517 KB, 1521x1076
Previous Thread: >>55486761
Next Thread: >>55500240

What are you working on, /g/?
>>
>>55496229
>next thread
what magic is this???
>>
>>55496229
First for C++.
>>
>>55496255
retro evaluation
>>
right now I'm casting a class pointer to void* in order to avoid a circular dependency. What better options are there to avoid this?

plase respond
>>
>>55496255
you'll see
>>
NOTAÞ HASKELL
>>
>>55496229
Would /dpt/ join an anime club?
>>
>>55496322
Already signed the application form.
>>
>>55496322
i took a picture of this but idk where it is, at my university there were 2 posters up on the hall in a csci building, one was for an anime club and right beside it was one for a fundraiser about autism awareness
>>
Is it impossible to literally scrape a site online? Like say you wanted to supply forged headers and data to an external website (like github) to login and retrieve information

Without a server of some sort this is impossible right?

I understand embedding is possible but that is a specially formatted template isn't it?
would ask wdg but they're slow
>>
File: 1467582963947.png (303 KB, 403x460) Image search: [Google]
1467582963947.png
303 KB, 403x460
>>55496499
https://www.youtube.com/watch?v=30nfka8J8Y0
>>
File: lainsad.png (325 KB, 941x1021) Image search: [Google]
lainsad.png
325 KB, 941x1021
I got my first job three days ago and I feel fucking useless.
There's a bug I can't find that shits up everything I've done and is making me feel worthless.

Is this what working feels like?
>>
>>55496562
i wonder how the staff at that store reacted when they saw the name of the video. i bet they were so excited for it too
>>
>>55496574
are you unit testing? a bug can only be so un-findable if it's in a single function
>>
>>55496574
I work in an office doing office work and it's awkward for a few weeks but eventually you become a part of the team and begin actually understanding your job and what skills you need

I'm an aspie too so the social bit was hard to develop but I'm doing OK
>>
>>55496599
No, but since I can't even seem to understand why this is happening I doubt I'd be able to make a test that can capture the bug.
It's a huge program with tons of functions and to do my work I need to call a ton of them, but I don't know how they're coded and something seems to be interacting wrong between my code and it.

I talked about it and no one understands why either.
>>
>>55496677
then they bug might not even exist in code you've written, so you may need to test the functions you're using as well

i don't work btw
>>
>>55496229
i work on a bot that can fake gps location and gyro output to become THE BEST pokemon trainer in the world
>>
>>55496792
why not use a drone instead
>>
I dont have a project to work on right now, any ideas?
>>
File: prog1.png (1 MB, 800x1149) Image search: [Google]
prog1.png
1 MB, 800x1149
>>
>>55496801
drones are expensive familia
>>
>>55496807
write a compiler

>>55496812
>he
>>
>>55496521
>literally scrape a site online
kill yourself
>>
File: prog2.png (976 KB, 1200x865) Image search: [Google]
prog2.png
976 KB, 1200x865
>>55496812
>>
>>55496812
>>55496915
even if wearing a skirt made you a better programmer, it's not like they'll let you do it at work
>>
File: le unwelcome gays.jpg (44 KB, 329x399) Image search: [Google]
le unwelcome gays.jpg
44 KB, 329x399
>>55496812
>>55496915
                                                                     :^)                         
>>
>>55496944
accuse them of transphobia
>>
I have no problems with anime as images, but fuck off with its discussion in this shit pile you call the technology board. Also, traps are shit.
>>
File: prog3.png (999 KB, 800x1149) Image search: [Google]
prog3.png
999 KB, 800x1149
>>55496915
>>
>>55496881
i mean through only html and javascript on the clients side asshole
>>
>>55496792
Users using gps bots will certainly be banned as they were on Ingress
>>
File: tranny poster.jpg (298 KB, 1177x892) Image search: [Google]
tranny poster.jpg
298 KB, 1177x892
>>55497021
                                                                              fag                                      
>>
>>55497021
sauce
>>
File: 2013121114092929139_lrg.jpg (647 KB, 800x1972) Image search: [Google]
2013121114092929139_lrg.jpg
647 KB, 800x1972
>>55496944
>>
File: buzz off.png (208 KB, 412x479) Image search: [Google]
buzz off.png
208 KB, 412x479
>>55496839
>write a compiler
>>
File: 1449376542734.png (33 KB, 937x193) Image search: [Google]
1449376542734.png
33 KB, 937x193
>>55497048
why the codetags?
>>
>>55497058
http://exhentai.org/g/416078/d0a23c2d27/
>>
>>55497066
extra whitespace gets removed by 4chan otherwise
>>
>>55497087
And what is the point of the extra whitespace? Is it a fetish?
>>
>>55497100
it's a significant whitespace language

the whitespace is more significant than you
>>
>>55497110
>forced indention
>>
I have a list of walls (rectangles) that falls in the screen.

I have a circle (a sprite) that I move with the keyboard.

how do I check when the circle collides with a wall without iterating with each wall in a for loop?
>>
SURE IS PROGRAMMING IN HERE
>>
>>55497141
i'd forcibly indent my tab into your textbox
>>
>>55497141
>why can't i put my entire program on one line? what a shitty language!
>>
>>55497165
First 100 posts of /dpt/ are always fighting about something before janitor cleans the tread (or not) and topic shifts to programming.
>>
File: 1466969439647.png (695 KB, 782x1080) Image search: [Google]
1466969439647.png
695 KB, 782x1080
What's the best programming language and why is it not your favourite?
>>
>>55497078
Kinda newfagish question, but how does one not get the sad panda?
>>
>>55497198
Soþlice
>>
>>55497219
The gallery is also on g.e, just go there
>>
>>55497217
Idris

The book for it isn't finished yet
>>
>>55497217
The best language is C and it's my favorite
>>
Can dragon-kin be programmers?
>>
>>55497219
I think google will help - it does vary deepening on browser


http://g.e-hentai.org/g/416078/d0a23c2d27/
>>
>>55497233
>buggy as shit
pick again

>>55497235
>no polymorphism of any kind
pick again
>>
>>55497257
>no polymorphism of any kind
This is a problem because?
>>
>>55497231
>>55497250
Thanks
>>
>>55496229
This is the worst OP image for this yet.
>>
>>55497217
Java
>>
>>55497268
>no parametric polymorphism
>no ad hoc polymorphism
>no f bound polymorphism
>no quantification or subtype polymorphism
>>
>>55497282
Make a new one, soþlice
>>
>>55497295
You managed to type a lot without saying anything.
>>
>>55497282
That's odd considering we've had this exact same image before
>>
>>55497295
What are f bound parrot arrows?
>>
File: MisakaPoster.jpg (119 KB, 1521x1076) Image search: [Google]
MisakaPoster.jpg
119 KB, 1521x1076
>>55497282
>>55497316
This image has been used before for /dpt/, it's edited from pic related.
>>
i've been working on an automatic backup tool.
2k LOC so far. most of the core functionality is done, now i'm cleaning up bugs and working on OS stuff.
also need to work on windows support
>>
File: feels frog 1.jpg (13 KB, 448x332) Image search: [Google]
feels frog 1.jpg
13 KB, 448x332
>>55497282
i spent a lot of time on it
>>
>>55497257
If you know of bugs, please report them! I'd love for Idris to be stable enough to use in production.
>>
>>55496521
Umm yeah? What do you think google is doing? You can get into trouble if you're scraping against the site's policy, tho
>>
>>55497257
>>no polymorphism of any kind
Wrong, turd.
struct object
{
struct inhereted something;
stuff
} nig;

void thing(struct inhereted *);
...
thing(&nig); /* valid */
>>
>>55497398
I think you did a great job on it, anon.
>>
>>55497403
Fuck me
>>
>>55497403
not polymorphism
>>
File: 1452958662065.png (191 KB, 1000x386) Image search: [Google]
1452958662065.png
191 KB, 1000x386
>>55497398
Don't worry bro, I feel you. I made many OCs in the past that were widely used but nobody posts them anymore ;_;
>>
>>55497403
Doesn't work with multiple inheritance and before you meme on me yes multiple inheritance is completely valid assuming all inherited types are pure interfaces
>>
File: uZ6RFsB.gif (443 KB, 400x480) Image search: [Google]
uZ6RFsB.gif
443 KB, 400x480
>>55497432
>>
File: 1437851286005.png (109 KB, 688x1434) Image search: [Google]
1437851286005.png
109 KB, 688x1434
>>55497432
>>
>>55497363
jesus christ that's disgusting
>>
theres a concert somewhere outside my house i can hear it
it prevents me from doing anything

i hate it
>>
i agree C is best language

you just write a scheme interpreter and off you go

eheh
>>
>>55497403
Doesn't even work on a function that takes an array of "inhereted".
>>
File: 1465177600155.png (237 KB, 1500x1500) Image search: [Google]
1465177600155.png
237 KB, 1500x1500
>>
File: 1341876636372.jpg (4 MB, 2500x1667) Image search: [Google]
1341876636372.jpg
4 MB, 2500x1667
>>55496562
I AM AUTISMIC AND I HATE MANGA
>>
File: 1443766383701.png (2 MB, 1200x1726) Image search: [Google]
1443766383701.png
2 MB, 1200x1726
>>
>>55497431
It clearly is.

>>55497436
I will probably tomorrow try to do some hackery on it to make it work with multiple inheritance.

>>55497619
What do you mean exactly?
>>
>>55497629
(define (fizzbuzz) 
(define (fbIter x)
(begin
(cond
((= (modulo x 15) 0) (display "fizzbuzz "))
((= (modulo x 3) 0) (display "fizz "))
((= (modulo x 5) 0) (display "buzz "))
(#t (begin (display x) (display " ")))
)
(if (< x 100) (fbIter (+ x 1)) #t)
)
)
(fbIter 1)
)
>>
File: futzbutz.png (8 KB, 238x831) Image search: [Google]
futzbutz.png
8 KB, 238x831
>>55497629

i did it
>>
>>55496812
I would wear a skirt and no panties for her.
>>
>>55497629
Fuck u Dennis! C is a disgrace!
>>
>>55497629
((lambda (f) (f f 1)) 
(lambda (f n) (if (= n 100) (display "Buzz")
(begin ((lambda (x)
(cond ((and (= (remainder x 3) 0) (= (remainder x 5) 0))
(display "Fizz Buzz"))
((= (remainder x 3) 0)
(display "Fizz"))
((= (remainder x 5) 0)
(display "Buzz"))
(else (display x)))) n)
(newline)
(f f (+ n 1))))))
>>
>>55497647
>LISP
so edgy
>>
>>55497629
implemented in the English language
for every number between 1 and 100 (inclusive)
if it is divisible by 3, then print "Fizz"
if it is divisible by 5, then print "Buzz"
if it is not divisible by 3 or by 5, then print the number
print a new line
>>
>>55497629
int i = 0;
while(i < 100){
if(i%3==0) printf("fizz");
if(i%5==0) printf("buzz");
if(i%3!=0 && i%5!=0) printf("%d",i);
printf("\n");
i++;
}


where's the trick
>>
>>55497678
hot
>>
>>55497679
hope you're having fun memorizing syntax nerd
>>
>>55497721
they're supposed to be separated by spaces, not one per line. 0/100
>>
>>55497755
that's not what the interviewer said nerd
>>
>>55497721
why not a for loop?
>>
File: ssssssss.png (215 KB, 1038x693) Image search: [Google]
ssssssss.png
215 KB, 1038x693
I have the function to turn:
Nichijou 01 audio:"en, jp, ru" width:1920 height:1080
into
'Nichijou 01', {'audio': '"en, jp, ru"', 'width': 1920, 'height': 1080}
now. Used Regex like someone in the previous thread suggested.
Right now I'm writing the SQL queries myself, which is sort of a pain but at least I'm learning something. I might end up swapping to SQLAlchemy in the future.

I think it would also be cool to have the "recently indexed" update without refreshing, but I do sort of want to avoid javascript.

Thats my hot anime blog for today.
>>
>>55497775
For loops are an inferior abstraction

>>55497779
I happen to be watching Nichijou right now, thank you for blogging
>>
>>55497775
they're kinda ugly
>>
>>55497629
program FizzBuzz;
var i: integer;
begin
for i := 1 to 100 do
if (i mod 3 = 0) and (i mod 5 = 0) then writeln('FizzBuzz')
else if i mod 3 = 0 then writeln('Fizz')
else if i mod 5 = 0 then writeln('Buzz')
else writeln(i);
end.
>>
>>55497796
thats a fair opinion. Plus its not like you need to keep the namespace clean if the only thing you're doing is looping once.
>>
File: 1466716035850.png (280 KB, 541x541) Image search: [Google]
1466716035850.png
280 KB, 541x541
why are programmers always so retarded?

take an example: dropbox.

for the longest time double click on try icon would open the folder. now they removed it to "streamline" with gentoo or some shit. why would you remove a good feature instead of adding it to everyone or make it optional. now to open the folder you need to click -> move your mouse -> click again. fucking imbeciles. seriously.
>>
>>55497913
ITS A FEATURE YOU RETARDED SHIT
>>
>>55497925
take a chillpill and try again, nerd
>>
>>55497913

Mine says up-to-date and it still does that.
>>
>>55497803
Whoa! I too just wrote an object pascal fizzbuzz!
>>
Any opengl programmers here? I stumbled upon a "hack" in someone elses code example where instead of using two separate buffers for vertices and UVs, they use a single buffer like this:

//verts is a vector of vec5s, first 3 elements are vertices, last two are UVs
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(verts), &verts, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5*sizeof(GLfloat), (GLvoid*)0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5*sizeof(GLfloat), (GLvoid*)(3 * sizeof(GLfloat)));


This seems pretty fucking great. Does this method have a name? Any juicy performance boosts?
>>
>>55498141
that just looks like they've interleaved it
>>
>>55498174
Yeah, now that I think about it the concept is pretty simple, but I never knew you can actually do that. Could probably pack normals in there as well with that method.

>interleaved
Yes! Thank you, this is the word for it. Gonna do some benchmarks with this interleaving method, pretty exciting.
>>
>>55497913
It's shitty UX people who read "Principle 5: Consistency" and think that it means their application needs to be consistent across platforms. It doesn't, it means that it needs to be consistent with the other applications on that platform in order to conform to user expectations and make the application easier to use.

Spotify does the same thing and it's infuriating, even to someone that uses multiple operating systems. When I'm on my desktop my brain goes into Windows mode and I expect applications to behave like Windows applications, when I use my laptop I expect applications to behave like OS X applications.
>>
>>55498238
iTunes and Safari always pissed me off for the same reason. If I wanted Apple's GUI themes I'd buy a Mac.
>>
>>55498055
not for me and they even state on the forums that it shouldnt work
>>
>>55497629
with Ada.Text_IO;

procedure FizzBuzz is
type MyRange is range 1 .. 100;

package T renames Ada.Text_IO;
package I is new Ada.Text_IO.Integer_IO(MyRange);
begin
for X in MyRange loop
if X mod 3 = 0 and X mod 5 = 0 then
T.Put("FizzBuzz");
elsif X mod 3 = 0 then
T.Put("Fizz");
elsif X mod 5 = 0 then
T.Put("Buzz");
else
I.Put(X, Width => 1);
end if;

if X < MyRange'Last then
T.Put(" ");
end if;
end loop;

T.New_Line;
end FizzBuzz;
>>
>>55498141
Who uses separate buffers for vertices and UVs? Interleaving is just the standard method. It is not a hack.
You usually have one vertex buffer, and one index buffer.
The vertex buffer contains some number of floats per vertex which the shader reads.
It's very common to just do something like this:
struct vertex {
float pos[3];
float normal[3];
float uv1[2];
}

and then place an array of such structs in a VBO.

See https://www.opengl.org/wiki/Vertex_Specification_Best_Practices
>>
>>55496284
In some cases you can pre-declare the class in a .h file as an extern, without having to specify its contents immediately.
extern class classname;
>>
What language are embedded systems usually done in?
>>
>>55498458
C
>>
>>55498458
forth
>>
>>55496284
Yet another C++ problem that wouldn't even exist in C (unless you're a typedef fag, I guess).
>>
what sick ass fonts do you guys use in your IDEs, im tired of the default i have and want a taste of the wild side
>>
>>55498398
I've read 2 opengl books and read like 4 tutorials, first time hearing about this shit. Absolutely depressing.

>https://www.opengl.org/wiki/Vertex_Specification_Best_Practices
Thanks
>>
>>55498503
Webdings
>>
File: ahhh.png (25 KB, 541x504) Image search: [Google]
ahhh.png
25 KB, 541x504
>>55498503
Comic Sans
>>
Writing a 3D cheese pizza MMORPG in WebGL
>>
Why even call it GNU/Linux? Stallman is mad.
>>
>>55498544
>webdev
top kek
>>
>>55498544
looks neat T B H
>>
Is Idris the future of programming? Dependent types make dynamic and weak typing obsolete, don't they?
>>
File: 000172.png (4 KB, 400x84) Image search: [Google]
000172.png
4 KB, 400x84
when will you ever stop
>>
>>55498618
Because Linux is a kernel and not an operating system
>>
>>55498693
So call it GNU, it's the operating system. We don't call Windows "Windows/NTOSKRNL.EXE".
>>
>>55498461
I was hoping to hear that. Wasn't sure if C was too high level.

>>55498463
Just looked it up, never heard of it. Interesting.
>>
>>55498706
But an OS is useless without a kernel, soþlice
>>
>>55498544
it honestly hurts my eyes to look at this, not even memeing
>>
>>55498558
well, whats the purpose of the game?
>>
systemd/Linux
>>
File: s2.png (75 KB, 275x294) Image search: [Google]
s2.png
75 KB, 275x294
>>55498746
>>
>>55498505
Another good link, since I just realized that the other page I linked you doesn't definitively say that interleaving is preferable: https://www.opengl.org/wiki/Vertex_Specification#Interleaved_attributes
Of particular note is this quote:
>As a general rule, you should use interleaved attributes wherever possible. Obviously if you need to change certain attributes and not others, then interleaving the ones that change with those that don't is not a good idea. But you should interleave the constant attributes with each other, and the changing attributes with those that change at the same time.
>>
File: n.png (619 KB, 763x875) Image search: [Google]
n.png
619 KB, 763x875
>>55498558
Intriguing
>>
>>55498709
Forth is much more powerful and expressive than C, but getting used to the concatenative paradigm takes some effort.
>>
How do I stop being a tutorial monkey and start actually writing code?
>>
>>55499019
You can't, you can only write tutorials now
>>
>>55499019
Wear a skirt
>>
>>55499039
But I don't write them. I take code from them.

>>55499042
I don't think that will help, anon.
>>
>>55499019
Work on a project
>>
>>55498874
Not the same anon, but what forth implementations would you recommend?
I mean, there's gforth, but the gpl license and the creators' attitude kinda makes me dislkie it...
>>
>>55498503
source code pro
>>
>>55499019
I think a good way is to work on a fairly simple problem without using a bunch of libraries and APIs (other than basic stuff like file IO and console IO,) and try to figure everything out yourself from scratch, rather than reading tutorials. Even if your solution is sub-optimal, it will be a good learning experience.


I'd recommend a fairly low level language if you want to really understand programming, something like C or C++.

So you might decide to write a simple text parser. Learn how to manipulate raw char arrays, and write and test some string handling functions. Reimplement strstr, strcmp, stricmp, etc.
Look up the spec for some file format and write a simple console-based utility to load the file and extract interesting information from the header, etc.
Forcing yourself to figure out how to do it on your own is really useful.
>>
>>55499106
MPE's VFX
>>
>>55496284

class Foo;

struct Bar {
Foo* foo;
};


You don't need a class definition to make a pointer to an object of a particular class. Don't use void* unless you need a completely generic pointer.
>>
>>55499192
Well I'm using C#, which I don't think is fairly low level.

I'm not sure if that will really help me, as my problem is more around the level of "I don't know how to utilize this APIs/libraries" (I'm messing around with monogame). The docs for monogame/xna don't really tell me a lot about what each library function does, at least in a way I can understand.

I will look at doing what you said though. No harm in more practice, especially if people say it will help you understand better.
>>
File: Chicago middle finger.jpg (59 KB, 550x730) Image search: [Google]
Chicago middle finger.jpg
59 KB, 550x730
>>55497541
no u
>>
>>55499255
Oh, well working with huge libraries that are poorly documented is always a nightmare, and I think it's actually bad for your problem solving skills - it encourages you to look up StackOverflow solutions rather than creating your own solutions based on a good understanding of the resources available to you.
If you have to use bloated APIs, then you'll have to learn a ton about them and essentially become an expert if you want to solve original problems well with them.
>>
File: 1460255607191.png (150 KB, 366x362) Image search: [Google]
1460255607191.png
150 KB, 366x362
>>55496229
In C++, I'm trying to make an arithmetic progression of steps of 5 from 1 to 100, and trying to print a specific index that are label only by the elements in the arithmetic progression.
So far my code looks like
intVector1D nprint = {};
for(int k = 0;k<=100;k++)
{
if(5|k)
{
nprint.push_back(k);
}
return nprint;
}
if(nprint.count(n) = 1)
{
std::cout << "n = " << n << "\n";
}
Errors show up when I try to compile it, including how "count" isn't a vector operation.
>mfw cucked
>>
>>55499287
Well, I'm not sure if it's just poorly doc'd, or if it's my inexperience. XNA is a microsoft framework, and monogame is basically a port after they ditched it.

While making games, I'm not sure if I'm better off honestly trying to write the huge amount of libraries that something like monogame provides, but at the same time, I see how it cripples my problem solving skills.

Quite a bind.
>>
>>55499060
write a program that prints out numbers 1 through 10, a function that tells whether a number is even, stuff like that
>>
>>55499304
How about you read the sticky thread first of all, and read some language basics second.
>>
>>55499304
wrap that shit in a code tag brother
>>
>>55497629
FizzBuzz <- function(x){
Vect <- NULL
for(i in x){
Vect <- c(
Vect,
if(i%%15==0){
"FizzBuzz"
}else if(i%%3==0){
"Fizz"
}else if(i%%5==0){
"Buzz"
}else{
i
}
)
}
cat(Vect, sep = "\n")
}

FizzBuzz(1:100)
>>
>>55499336
I took a year of programming in uni, so I can do basic, basic stuff like that. But I don't extend much beyond that. I know:

primitives
what an array is (not really how to use them well, though)
loops
if/else
methods
>>
>>55499329
Yeah, I'm afraid there's probably no single correct answer.
Personally, I hate working with huge, hard-to-debug, opaque libraries. But I might have over-corrected a bit too far in the other direction, because I've built several game engines from scratch in various languages/graphics APIs, but never completed a game.
It's a lot of fun, a great learning experience, and it allows you to do real programming and problem solving, but it does mean a lot of time that you're not actually working on a game.
Arguably, if you don't care about working on engine development or cutting-edge graphics tech, your best bet might be to put your time and effort into learning a good API.
>>
>>55499383
Fuck right sorry.
intVector1D nprint = {};
for(int k = 0;k<=100;k++)
{
if(5|k)
{
nprint.push_back(k);
}
return nprint;
}
if(nprint.count(n) = 1)
{
std::cout << "n = " << n << "\n";
}
>>
>>55499391
muh sides
>>
>>55499304
How are we supposed to know how intVector1D is defined?
Include more of your code, and put it in a code tag.
Also, your loop will always return on the very first iteration. I don't know what you were thinking.
>>
>>55499387
have you done all the practice problems in SICP?
>>
>>55499391

god fuck

>trying to print a specific index that are label only by the elements in the arithmetic progression.

im assuming you mean you want to only print at certain intervals, which seems to be only when you have one item the collection

starting off, where are you getting the class/type definition for what a "intVector1D" is and/or are you correctly adding the header for it

i havent used c++ for awhile but i dont know how conventional it is that you can initialize an object with "{}", that's a javascript/python style thing

| is a bitwise operator and you probably meant something else, but even 5 || k wouldn't really make sense, look for the modulus operator

in your for loop you're returning out of the function (which since you didn't give the outer scope of this im assuming is main) which means it's just going to stop right there, just remove that return

going by what you said earlier and how i interpretted it, you should actually remove the brace after your wrong return statement because you want this conditional to be inside the loop

on nprint, if there was a size method it probably wouldn't take any arguments but you'd have to look at the api to know what it's called, it'd probably be either nprint.Count or nprint.size or nprint.Length

immediately after that you're using the assignment operator instead of equality check, = vs ==, and i'm not really sure why you only want to print if there's only going to be one item in the collection so you should probably rework that

you didn't fuck up the print statement atleast, but instead of using "\n" use std::endl

just redo it
>>
>>55499452
No. Though I suppose I should? The class I took was pretty shit, and that book wasn't mentioned. I'll go check it out.
>>
>>55497629

void FizzBuzz(size_t Num) 
{
char* messages[4] = { "%i\n", "Fizz\n", "Buzz\n", "FizzBuzz\n" };
for (size_t i = 1; i <= Num; ++i) {
printf(messages[(!(i % 3)) + 2 * (!(i % 5))], i);
}
}
>>
>>55499501
also there's not even an n in scope, so either declare an n somewhere and use it or rework your logic to not include it since it actually isnt needed here, which should be easy enough
>>
>>55499501
Yeah the return line is a mistake. Also the '|' was meant to be "divides". You''re right that it shoud probably be a mod.
n is defined elsewhere to run from 1 to 100. The nprint if loop is supposed to check if n is in the sequence.
>>
Just started my first software job and I'm feeling very overwhelmed. I've got all the core programming concepts down, I've just never worked on a big piece of software like this before and I'm having trouble tracing everything and figuring out which parts do what. How do you wrap your head around and manage large projects, especially those that are foreign to you and lack any good documentation?
>>
>>55499513
> 2 * x
> not x << 1
git gud
>>
>>55499576
An IDE with good code navigation helps.
>>
>>55499579
-O2
>>
>>55499579

The compiler optimization should turn one operation into the other when it's better for that platform.
>>
>>55499586
>>55499619
>trusting the compiler
wew lads
>>
>>55499576
They ought to have everything abstracted away into black boxes
>>
Once I've learned a language, what do I search and what do I look for exactly to figure out which methods should be used and what the best way to do things are? It seems like theres always a one off blog post about doing something a particular way but no easy way to find these things out.
>>
>>55499579
That's a bad idea. It's bad for readability, and should only really be done in a part of the code that you've profiled and determined needs to be sped up.
Worrying about that kind of thing for non-performance-critical sections of the code is a waste of time (and actually makes the code worse.)
>>
>>55499623

This comment is a quality indicator that you may suffer from premature optimization syndrome. In all honesty on most modern processors the shift and multiply operations have near identical performance.
>>
>>55499112
i dont like how this one looks
what else you got for me
>>
>>55498503
I always end up coming back to Consolas
>>
File: 1408830619293.jpg (3 MB, 3504x2336) Image search: [Google]
1408830619293.jpg
3 MB, 3504x2336
>Wondering why my function doesn't shows a chart
>Prolly I'm not calling all the constructors needed to build it, or maybe I'm not setting the members properly.
>Debug for two hours now.
>mfw I wasn't calling the function to show the chart
>>
Why do retarded languages like Java and Python even exist?
>>
>>55499729

Inconsolata isn't bad. Anonymous Pro looks pretty good.

If you're used to the letters and reading bottom to top and right to left then a Enochian font isn't bad.
>>
>>55499838
Initially, to fill a need.
Currently, due to momentum.

also 400 shitposts incoming; thanks for the unconventional bump mechanism
>>
>>55499838
Python is great for prototyping.
>>
>>55499838
Because there are people out there who are not elitists, and realize that one can use different tools for different jobs.
>>
>>55499838
java is a fast, subjectively ugly looking language
python is a slow, subjectively clean looking language
>>
>>55499889
NO ONLY C++ REEEEEEE
>>
For a while now, I had no idea what I wanted to program after finishing like a whole year and a half of comp sci classes.

I started reading up on stuff, and the idea of genetic algorithms is REALLY cool to me. I wanted to know, just how hard is it to make a genetic algorithm?

I planned on using it to make a bot to play chess against me and beat me. Is it difficult?
>>
SECTION .data
Fizz: DB "Fizz", `\n`, `\0`
FizzLen: EQU $-Fizz
Buzz: DB "Buzz", `\n`, `\0`
BuzzLen: EQU $-Buzz
FizzBuzz: DB "FizzBuzz", `\n`, `\0`
FizzBuzzLen:EQU $-FizzBuzz
Number: DB "Too Lazy", `\n`, `\0`
NumberLen: EQU $-Number
SECTION .text
GLOBAL _start
%MACRO print 2
mov eax, 4
mov ebx, 1
mov ecx, %1
mov edx, %2
int 80H
%ENDMACRO
%MACRO divide 3
mov eax, %1
mov ebx, %2
cdq
idiv ebx
test edx, edx
jnz %3
%ENDMACRO

_start:
mov esi, 1
FizzBuzzLoop:
divide esi, 3, D5
divide esi, 5, D3
print FizzBuzz, FizzBuzzLen
jmp Continue
D5:
divide esi, 5, number
print Buzz, BuzzLen
jmp Continue
D3:
print Fizz, FizzLen
jmp Continue
number:
print Number, NumberLen
Continue:
add esi, 1
cmp esi, 100
jle FizzBuzzLoop

mov eax, 1
mov ebx, 0
int 80H
>>
File: not a virus 2.png (71 KB, 950x932) Image search: [Google]
not a virus 2.png
71 KB, 950x932
Now I understand why some keygens, even from the scene are classified as Trojan.
That's because they use self-modifying code to protect their "secrets".
Self-modifying code is dangerous, that's not a normal behaviour of a program.
You can't predict what it does without actually running it.

Game company uses the same protection but gets around anti-virus issue by using digital signature.
>>
>>55500169
It seems as though it will be hard figuring out the right parameters to expose to the genetic selection process.
>>
Currently simulating cool shit in python

racketball, volleyball, craps, probably will do blackjack next

does anyone have good suggestions for things to simulate?
>>
>>55500657
My dick, though you will need a Big array ;^)
>>
>>55500657
/dpt/
>>
>>55500676
as would anything else in quantum mechanics
>>
>>55500657
simulate writing me a scrollable canvas (or label or panedwindow, doesn't matter) in tkinter that is bound to your scroll wheel, I need one.
you would save me at least two hours solving it

>>55500754
whew lad
>>
>>55500657
Write a meme inception and dispersal simulation. Based on a large set of entities with their own relations between each other, and slightly different meme evaluation functions, see which memes thrive and which die.
>>
>>55496229
Working on a lambda calculus interpreter in Haskell.
They finally infected me, /g/.
>>
>>55500940
Got any suggestion for intro material on lambda calc?
>>
>>55501052
Wikipedia
desu understanding lambda calculus enough to write an interpreter is very different from understanding it enough to write much of it, and I haven't found a decent sequence of exercises for me to learn the latter yet, but the Wikipedia page is a general good intro. If you know even a little about discrete math you should understand the Wikipedia page.
>>
>>55501208
wow that substitution failed miserably
>>
>>55499684
The compiler will turn multiplication by powers of 2 into shifts if it makes sense for the target architecture.
>>
>>55496229
Good job fucking up the next thread link
>>
>>55499838
Everyone knows Java, you can pull someone off the street or a H2B off the boat and get them started on a Java project.
>>
still in the planning process of my compiler here, but i've started writing tiny bits of code. i'm still kind of scared of trying to implement type inference with some of this shit, so that probably won't be implemented until the second iteration once i've made some final decisions on how typing will work
>>55498679
i used to think so, but i'm starting to have my doubts about Idris (as a project, not as a concept). a lot of the work behind Idris sadly seems to be more focused on writing new academic papers than actually building a useful language.
>>55500940
nice :3
>>
Am I an idiot for just starting to understand OpenGL now?
I'm been going at it occasionally for about 2 years or so and I never really understood it, I mean I could follow the tutorials and sort of understand it on a basic level, but I never really understood what's going on in the big picture.

I want to make a 3D engine for a game I want to make, do I have any hope or am I too stupid to make a game if it took me that long just to get OpenGL?
>>
>>55497629
int main(int argc, char **argv) {
int i, t, f, b;
i = 0;
loop:
i += 1;
if (i > 100) return 0;
if (i % 15) goto five;
printf("FizzBuzz\n");
goto loop;
five:
if (i % 5) goto three;
printf("Buzz\n");
goto loop;
three:
if (i % 3) goto fail;
printf("Fizz\n");
goto loop;
fail:
printf("%d\n", i);
goto loop;
}
>>
>>55501570
>Am I an idiot for just starting to understand OpenGL now?
No, why would you be?
>>
>>55501605
Well everyone here says OpenGL is piss easy and high level.
So I thought that maybe I'm just a bird brain.
>>
>>55501587
> return 0;
> not goto end;
You've got one job.
>>
Is it possible to put a window inside a window in gtk?
>>
>>55496229
>>55500000
>>
I dropped this in /sqt/ but quickly realized here might be a better place.
>>55501876
>>
>>55498232
>Yeah, now that I think about it the concept is pretty simple, but I never knew you can actually do that. Could probably pack normals in there as well with that method.

everyone does it bud
>>
>>55501898
Pump the data over serial to an arduino and have it act as a mouse?
>>
>>55501468
Idris might not be practical now and it's going to grow slowly when its growth is based on academic papers but it's going to be good at what it intends to do when it matures.
>>
Why the fuck isn't ltostr() part of the standard library
>>
>>55496606
are the guys working with you OK, or they are hostile ?
Thats what I am afraid of, ppl at the work place getting hostile because I am not good at my job
>>
>>55497629
int i = 0;

while(i++ < 100)
{
string s = "";

if (i % 3 == 0)
s = "Fizz";
if (i % 5 == 0)
s += "Buzz";
if (s.Length == 0)
s = i.ToString();
Console.WriteLine(s);
}
Console.ReadLine();
>>
>>55497231
I'm sorry, can I ask what g.e is?
>>
>>55502533
e-hentai.org I presume
has WAY less content though
>>
>>55497629
for i in range(1,101):
if i%3==0 and i%5==0:
print "Fizzbuzz"
elif i%3==0:
print "Fizz"
elif i%5==0:
print "Buzz"
else:
print i


Thanks Dennis
>>
I'm currently working through land of lisp as a /dpt/ newfag. Are the lisp lectures where the guy crosses out computer science good to watch alongside reading?
>>
Are global variables acceptable if they are constant?
>>
>>55502775
use a define or enum instead
>>
Why should one learn to program? Assuming I know nothing about programming or its uses.
>>
>>55497629

fn main() {
for i in 1..101 {
match (i%3, i%5) {
(0, 0) => println!("Fizzbuzz"),
(0, _) => println!("Fizz"),
(_, 0) => println!("Buzz"),
_ => println!("{}", i),
}
}
}
>>
>>55502202
It is though, look up itoa.
>>
>>55502947

to make a virtual waifu
>>
>>55497629
for(int i=0; i<100; i++) {
if (i%5==0 && i%3==0) System.out.println("Fizz");
else if (i%5==0) System.out.println("Buzz");
else if (i%3==0) System.out.println("FizzBuzz");
else System.out.println(i);
}
>>
>>55502984
itoa isn't either
>>
>>55496284
Use Forward Declaration in your .h
class ClassName;

class OtherClass {
private/public/protected:
int attribute;
ClassName* circular_dependency;
};
>>
>>55497647
>not using a named let
You don't write Scheme much, do you?
>>
>>55501413
I didn't think /dpt/ would be so dead
>>
What C should I learn?
>>
>>55497639
Trains are cool, you are alright anon.
>>
>>55503654
sCheme
>>
>>55503654
C++
>>
>>55503654
cython
>>
>>55503654
Has|cell
>>
>>55503654
The one and only HolyC
>>
>>55497629
static void Main(string[] args)
{
for (int i = 1; i <= 100; i++)
{
if (i % 3 != 0 && i % 5 != 0)
Console.WriteLine(i);
else
{
if (i % 3 == 0)
Console.Write("Fizz");
if (i % 5 == 0)
Console.Write("Buzz");

Console.Write("\n");
}
}
Console.ReadKey();
}
>>
>>55503654
There is only one C and its name is C.
>>
>>55504059
the C stands for crap
>>
how long does it take to learn programming if you are a bit retarded?
>>
>>55504076
Couldn't have been more original, Anon.
>>
>>55504080
>bit retarded

Just accept that you'll never be a programmer
>>
>>55504080
negative 2 weeks
>>
File: 1464229536392.png (1 MB, 1280x720) Image search: [Google]
1464229536392.png
1 MB, 1280x720
>>55504076
C stands for cute
Thread replies: 255
Thread images: 39

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.