[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: 23
File: 1456075074460.jpg (60 KB, 627x627) Image search: [Google]
1456075074460.jpg
60 KB, 627x627
https://www.youtube.com/watch?v=J2vqeKd8Vos

Previous thread: >>54576477

What are you working on, /g/?
>>
File: ocaml2.jpg (9 KB, 132x195) Image search: [Google]
ocaml2.jpg
9 KB, 132x195
>>54579670
First for OCaml.
>>
File: 1463179368635.jpg (53 KB, 540x705) Image search: [Google]
1463179368635.jpg
53 KB, 540x705
>spent 2 hours installing VS15 just because while building Python 3.5 extensions for Windows it does not recognize any other version of VS

This language wasn't made for Windows was it?
>>
File: 1456631892924.jpg (118 KB, 467x349) Image search: [Google]
1456631892924.jpg
118 KB, 467x349
>What is object oriented programming?
>>
File: yoda-bait.jpg (146 KB, 500x378) Image search: [Google]
yoda-bait.jpg
146 KB, 500x378
>>54579714
>>
>>54579714
like if you have a toaster irl, you just insert the bread, maybe adjust the heat/timer setting, and push to start. the toaster is an object. instead of you being like a caveman collecting logs and inventing fire etc just to toast some bread
>>
am i the only one who fucking hates python? i understand it's a powerful language and all, but i really don't like it, could be that i'm really bad at it but it just looks so stupid to me

fuck the sensitive whitespaces
>>
>>54579735
you're far from the only one. python is truly horrible
>>
File: le kekking church.jpg (39 KB, 235x314) Image search: [Google]
le kekking church.jpg
39 KB, 235x314
>>54579735
>python
>powerful language
>>
>>54579741
why is that so? i don't really know why i hate it, i just do
>>
>>54579758
i thought it was pretty powerful with all the math libs and all that stuff
>>
>>54579764
you can take pretty much anything in python and point out something shitty about it. it's just incredibly shit, the entire thing. it's especially bad for beginners to learn programming. it doesn't really teach you anything, after several months the average python shitter will know basic control flow and functions and that's about it. you learn those things in literally the first 1-2 days of java.
>>
>>54579795
i have to use that shit in uni for my cryptography course and it's just a pain in the ass. i'm okay with java but i don't seem to understand this python shit, it's driving me crazy.
i feel like you can create the most absurd constructs there are and all they do is add two variables
>>
>>54579859

I dislike it because van Rossum is a jew.
>>
Why haven't you implemented malloc() yet /dpt/?
>>
>>54579979
can't average 2 ints yet
>>
Anyone programmed a cli in c++ before?
Considering having a massive if/else if tree that compares given command with each program command string. A "clever" way of doing this is with a std::map<std::string, std::function<void(std::stringstream)>> and using map::find to call a system command function that handles the command and arguments from given stringstream, but this feels like over-engineering.
>>
>>54580139
>clever
>std::map<std::string, std::function<void(std::stringstream)>>
elegant as fuck! :^)
>>
>>54580168
It kind of is, I could use map.find(cmdstring)->second(stream); in that case instead of an if/else if.
But I'm going for the if/else if option right now.
>>
>>54579735
I fell for the python meme when I first started because I use R/was interested in biostatistics, but I just couldn't deal with it. Then I was forced to learn Ruby and never looked back.
>>
>>54580139
http://www.boost.org/doc/libs/1_36_0/doc/html/program_options.html

If you want to do it yourself make a function that returns an int. Define each valid argument in an enum and process them in order. Then make a switch on the return of that function. Default case prints help and an error message.
>>
So I have to find an algorithm and I can't get it.

I have an array of x objects. I can getValue() them, and that returns true or false.

The first time it has to return the first occurrence of true, the second time it has to be the second, etc. If the last in the line is found, it has to start in the front again. An example of the result:

I have 5 objects with states: true, false, false, true, false.

Result should be:

1
4
1
4
1
4
1

Then the array changes to: true, true, false, true, false.

The result then changes to (previous true value was on the 1st spot):
2
4
1
2
4
1
2
4

Anyone has an idea?
>>
>>54580251
thank god i'm not the only one
>>
>>54580251
Fell for the python meme when I first started learning how to program as well. It's not a terrible language but I've yet to see it be taught to someone with little to no programming experience well.
>>
Slowly achieving Lisp satori, guys.
>>
>>54579707
>he spent 2 hours installing VS15 when all he had to do was to set a temp env variable before invoking pip

all of my kekeronis
>>
I want to make vidya gaems. Is C a good fast and portable language to make vidya?
>>
>>54580725
C is a terrible choice for video games unless you're planning on writing some simple classic vidya clones.
>>
>>54580288
Save the previous return value, start back from there, and wrap at the end. Now where do you store it? That's where the algorithm stops and the program starts IMO: depends on your language, whether it has feature X,Y,Z, whether you're writing a procedure or a class etc...
>>
>>54580747
What would you recommend? Java? Python?
>>
>>54580725
>C
>portable
nah, man, try C# for that
>>
>there are people in this thread RIGHT NOW that don't know how to get the first byte of an int
JS babies should leave muh /gee/ forever!
>inb4 REEEEE
>>
>>54580790
Both Java and Python are also terrible choices because they're too slow for stuff like physics simulation and such (just look at Minecraft, multi billion dollar game and it can barely hit smooth 60 FPS on modern hardware). You want to use C++, even if you don't like it, because it's a good compromise between language features that make it easy to deal with common practices in video game development (like entity component systems) and the speed (although if you were pushing hardware to the limits like some modern titles you'd probably have to roll own standard implementation for some stuff but I doubt you'd ever reach that point).

Alternatively try >>54580796, C# is a decent language that can offer a lot and is relatively fast but you're tied to MS ecosystem.
>>
>>54580835
In a portable manner? In C? Impossible.
>>
File: 1393514280512.jpg (111 KB, 531x362) Image search: [Google]
1393514280512.jpg
111 KB, 531x362
> webserver in Clojure
> GC is getting buttfucked

I fell for the immutable meme, send help.
>>
>>54580863
Are you talking speed as in AAA titles or vidya in general?
>>
>>54580863
>(just look at Minecraft, multi billion dollar game and it can barely hit smooth 60 FPS on modern hardware).
10 years old hardware here and i have constantly +200 fps
>>
>>54580863
>Both Java and Python are also terrible choices because they're too slow for stuff like physics simulation and such (just look at Minecraft, multi billion dollar game and it can barely hit smooth 60 FPS on modern hardware).
It's just Notch being a shitty programmer. Java is lightning fast
>>
>>54580897
AAA

>>54580901
Specs?
>>
What are some good ways to practise pointers and memory management in C?
>>
dat
boi
>>
>>54580921
intel core2duo e8400 (2008)
2gb ddr3 (2008)
ati hd 5770 (2009)
>>
>>54580912
What's the difference between python and Java?

>>54580921
I'm not interested in AAA right now. I'm more interested making small indie games as a hobby
>>
>>54580977
>whats the difference between python and java
Lmao
>>
>>54580912
notch is decent but he rushed the development and favored features over performances which was the right thing to do.
>>
>>54581009
There is none?
>>
>>54579670
>What are you working on, /g/?
Currently coding a project for an Uber-like startup doing it in full stack Ruby on Rails, but also using the most async version of node.js for parallel agile project so I'm picking the appropriate framework atmo and reassessing user stories. I'm just writing a Medium about my project, I'm worring about scaling though and if along hte lines I'll have to include deep learning to make it more contemporary... we'll see.
>>
>>54581053
>Ruby on Rails
I loled.
>>
>>54581058
xD
>>
File: GBzPEMQ.jpg (105 KB, 640x640) Image search: [Google]
GBzPEMQ.jpg
105 KB, 640x640
>>54579670
>trump
>>
>>54581053
Prime bait.
>>
File: Screenshot_5.png (47 KB, 715x777) Image search: [Google]
Screenshot_5.png
47 KB, 715x777
>>54580977
>What's the difference between python and Java?
huge
https://benchmarksgame.alioth.debian.org/u64q/python.html
>>
>>54580892
What are you doing to make the gc gonuts
>>
>>54581107
that's cpython vs openjdk, not python vs java. he asked for differences between the programming languages.
>>
So I'm trying to learn socket.io's p2p shit and I'm not using browserify:

https://github.com/socketio/socket.io-p2p/
http://socket.io/blog/socket-io-p2p/

So it says I'm supposed to just include the 'socketiop2p.min.js' file and use window.p2p(socket), but when I do this I get an error saying 'bind' is not a function.

What am I supposed to do?
>>
>>54581126
>that's cpython vs openjdk
no, that's the Oracle's Java implementation vs regular Python 3
>>
>>54581053
ayy
>>
>>54581114
Nothing special. It's just that any changes to objects generates tons of garbage of intermediate results.
>>
scene = QGraphicsScene()

scene.mouseMoveEvent = lambda mouseEvent: (print(mouseEvent), mouseEvent.accept()) # type error


def foo(mouseEvent):
print(mouseEvent)
mouseEvent.accept()

scene.mouseMoveEvent = foo # works


How is that retard guido still allowed around computers?


>inb4 inherit from QGraphicsScene
To overwrite one (1) function, how about no
>>
>>54581107
Would a game in Python seriously be that slow?
>>
>>54581230
no
>>
>>54581230
Yes.
>>
>>54581027
python sucks dick
java is pretty neat
>>
>>54581230
probably not, most games don't perform such heavy computations and Python has a lot wrappers for numerical functions written in C
>>
>>54581277
Retard.
>>
>>54581277
Is Python more portable than Java?
>>
>>54581289
yes
>>
>>54581286
you don't have to announce your arrival
>>
>>54581289
no
>>
>>54581211
Shouldn't that be:
lambda self, mouseEvent: ...
>>
Sorry for dual monitor pic, but any help with getting C++ compiler configured/ libraries needed configured with eclipse would be really helpful. Using C++ for everyone by Horstmann.
>>
>>54581355
tried to configure eclipse for C once and I just gave up and installed Visual Studio
>>
>>54581313
>>54581328
/dpt/ in a nutshell
>>
>>54581391
Goddamn it. I'm in love with eOS and I really don't wanna have to use windows to learn this shit.
>>
>>54581355
>Eclipse C++
Doesn't that just use makefiles?
>>
>>54581436
I have no idea, honestly. It's saying that my iostream import is unrecognized.
>>
File: Rlogo.png (69 KB, 800x700) Image search: [Google]
Rlogo.png
69 KB, 800x700
Writing an R package for fetching sports data from an objectively-poorly designed API.

On that note, to what degree is it bad practice to rename fields in the objects my functions return to the user? The API is entirely undocumented and many fields (and the tables in general) have either meaningless or abstract names. I feel like, especially since there's not going to be any posting to the service, it's not a terrible idea, but my goal along the way is to attempt to document the service as well, so I'm trying to be especially careful when making decisions like this.
>>
>Get back to an old project of mine
>See // I've no idea what's the purpose of this

I'm fucked, ain't I?
>>
>>54581426
get clion
>>
>>54581338
No, that would be consistent with the other mess.

TypeError: <lambda>() missing 1 required positional argument: 'mouseEvent'
>>
guys, im taking my first programming class and the instructor is using python...

what do?
>>
>>54581905
Perform sudoku
>>
There's no stupid questions thread in the catalog, so
anyone knows how to create a matrix, multiply it with a number, add another matrix to it, or multiply it by another matrix, in c++

stuff I know as of now:
integers
for loop
cin and cout

I just dont know how to make matrices and do stuff with them..
>>
>>54581905
We had a lecturer who was supposed to teach in C# for a particular course. He took it upon himself to ramble and inject python into every part of that course.

By the end of the course, everyone was falling behind, on the verge of failing and had to look for help from prior students who didn't have to suffer through that, or look elsewhere.

My advice?
Run for the fucking hills.
>>
>>54582001
yeah you use glm
>>
>>54581905
Install Gentoo.

Barring that, actually try paying attention in class instead of being a gay fucking baby.
>>
>>54582030
what's glm?
I have an exam tomorrow and I dont know how to do this, I dont know shit about programming
>>
>>54581905
Pay attention, you dumb ass. If you're taking your first class, there's no reason you should be acting like you're above a fucking language just because the basement dwellers here tell you so.
>>
>>54582041
ur fukt then m8
>>
>>54582022
>He took it upon himself to ramble and inject python into every part of that course.
God damn, that would be annoying.
>>
>>54580725
absolutely not. use java or C++. don't use C or python.

>>54581230
yes

http://stackoverflow.com/questions/6395923/any-way-to-speed-up-python-and-pygame
>>
>>54582033
>>54582052
its an online course, and I'm studying rite now! Wish me luck!
>>
>>54582001
It makes a two-dimensional array (a matrix).

It assigns values to the two-dimensional array.

It iterates through the array and multiples and adds values as necessary.
>>
>>54581289
I don't understand the question.
>>
>>54582088
Yeah but how do I make this? Lets say I have a matrix a[100][100], how do I multiply it by 2?
I guess I could make sum[100][100] = a[100][100] + b[100][100], but not sure how to multiply it by a single number
>>
>>54582001
i'm not going to write your fucking program, but here's a hint:
- matrix is something like int x[row][column ]
- you multiply it with a number by running through a nested for loop, for example like:
for(int i = 0; i <= numberOfRows; i++) {
for(int j = 0; j <= numberOfColumns; j++) {
matrix[i][j] = matrix[i][j] * number;
}
}

- adding another matrix is basically the same, add matrix cell [i][j] from m1 with cell [i][j] from m2

apart from that, fuck you for not learning and asking others to do your shit, i hope you fail you miserable fag
>>
>>54582238
Nested FOR loops.

for each row in matrix, for each cell in that row, multiply the value by two.
>>
>>54582260
>Much of what looks like rudeness in programming circles is not intended to give offense. Rather, it's the product of the direct, cut-through-the-bullshit communications style that is natural to people who are more concerned about solving problems than making others feel warm and fuzzy.
>>
>>54582260
> not putting your matrix in a single dimensional array
> not calling your second iteration integer i2
>>
>>54582300
that was my intention

>>54582320
>not putting your matrix in a single dimensional array
why would you do that? a matrix is 2-dimensional and not 1-dimensional, and it would lose it's actual form

>not calling your second iteration integer i2
call it what you want, i've learnt it that way
>>
>>54582320
>>54582363
I also prefer i and j.
>>
>>54582320
>> not calling your second iteration integer i2
Literally nobody does this.
>>
>>54582363
Single dim array is faster technically, but the compiler will already convert it back to a single dim array anyway so..
>>
>>54582429
yeah, but it doesn't really make a difference with e.g. a 20x20 matrix
plus 2-dim arrays are good for beginners to understand how they work, 1-dim matrices would just cause unnecessary confusion
>>
>>54582079
Does it matter if I learn Java or C first?
>>
>>54582429
>Single dim array is faster
You don't know what the fuck you're talking about.
>>
>>54582572
depends, with java you also learn OOP, c only teaches you the basics of procedural programming

if you hate yourself, learn
>python
>>
>my second techincal interview with an AI company
>they literally ask me to write a fizzbuzz

I literally had to clench my teeth to keep from laughing. I've got this job in the bag
>>
>>54582621
>java
>also OOP
ishyggy
>>
>>54582642
good thing they haven't found out about averaging 2 ints, amirite?
>>
Is it possible to write a script that forwards a text when you receive an email that contains certain keywords?

I've looked into doing this before with python but I recall needing to use those @att.net @tmmail.net extensions after the number and I'd rather not.
>>
>>54582572
both are good choices for the first programming language. you definitely should eventually learn both
>>
>>54582677
unpossible!
>>
>>54581101
>criminalS
>>
>>54582665
The only other question they asked was how to add every digit in a number.
>>
>>54581101
I always found it funny the ones who complain the loudest about mexicans are the fattest and laziest blobs of protoplasm to exist.
>>
File: piece of fucking shit.png (36 KB, 1231x397) Image search: [Google]
piece of fucking shit.png
36 KB, 1231x397
So um..
I think I kinda understood this nested for loop thingie, and just when I was about to test my matrix, this happened.

I swear, so far, not a single problem testing various other shit like integers, bool, while, for, and so on things, but now damn thing keeps crashing.

Anyone has any idea what to do? I will refresh /g/ to check out if stupid questions thread is back.
>>
>>54582572
it doesn't matter too much but i would suggest learning java first and then C++ or C

https://docs.oracle.com/javase/tutorial/
>>
>>54582801
mexicans, or illegals? Trump has no issue with mexicans.
>>
>>54582850
turn <= into <
>>
>>54582850
if i see it right your matrix is empty, it doesn't hold any values
>>
>>54582850
I don't think you can just cin into a matrix like that.
>>
>>54582873
Oh I wasn't talking about trump, I was talking about the political cartoon with fatty mc fatfuck in it.
>>
I am pretty new to bash and I don't get why & is needed at the end of this fork bomb
:(){ : | :&}; :
Why does :(){ : | :}; : not do the same? According to man bash the pipeline already executes both commands in a subshell, so what does creating a new subhsell for the pipeline change?
>>
>>54582924
yes, you are definitely right, I think that's the problem
got trough the rows and columns cin after I fixed that, but now I have some other problems

at least I know where the error is, so thanks
damn I cant think for shit in this c++ format my computer demands
>>
>>54582933
>With '&', the process starts in the background, so you can continue to use the shell and do not have to wait until the script is finished.
>>
>>54582933
Without the & the parent process would eventually get killed by the system and kill all of the forked children, with it, the children won't get killed and will keep spawning new children.
>>
>>54582953
Why aren't you using an IDE?
>>
>>54582925

Are you American?
>>
>>54582677
Learn how to receive and send emails with python, use regular expressions or similar to check for keywords... you wouldn't want someone to write the whole script for you, right?
>>
>>54581101
this buttmad anon's gonna be on suicide watch when trump beats shillary
>>
>elections

Can we not?

Does this have to happen in /dpt/ again today?

>>>/pol/
>>
>>54582970
codeblocks with whatever compiler they put in, I think its gnu ++ or something

still cant get my matrix to work fully but at least I have somewhere to work from
>>
>>54583010
Fuck off you unpatriotic cuck.
>>
>>54583010
>Does this have to happen in /dpt/ again today?

It's an election year and most people on 4chan are Americans. Not only that, but most of the people here are probably tired of the hyper-liberalism they have to deal with in the public sphere.
>>
>>54583029
>>54583034
I'm American (would prefer Trump) and go on /pol/ often to read discussions about the elections.

I just don't see any constructive conversation about it happening in /dpt/.
>>
>>54583034
>Not only that, but most of the people here are probably tired of the hyper-liberalism they have to deal with in the public sphere.
this, i'm not even american and i hope trump wins
>>
>>54582987
Yeah, I just don't like fat people.
>>
>>54582953
fill it with a simple for loop, that should do the trick
>>
Is Java easier to get into than C?
>>
>>54583034
>most people on 4chan are Americans
>most of the people here are probably tired of the hyper-liberalism they have to deal with

Yeah, if you could get me those citations by Saturday that'd be greaaaaaaaaaaaaaaat
>>
>>54583124
No, C is infinitely easier to get into than Java.
>>
>>54583124
Yes, in much the same way that it is easier to find a street than it is to find a public toilet.
>>
>>54583153
>C
Easy to learn, hard to master.
>>
>>54583124
yes
>>
>>54583144
https://www.4chan.org/advertise
>>
>>54583124
It's easier to do non-trivial things in high-level languages.
>>
>>54583153
Is Java difficult to understand compared to C?
>>
>>54583165
C is piss easy to master, there's very few language features and you can even memorize the entire standard library in an afternoon.
>>
>>54582961
I know that, doesn't really help me out, though.

>>54582967
Thanks, that makes sense, but shouldn't the children get orphaned? Also, why does :(){ (:) | (:)}; : work as a fork bomb then? Wouldn't it also get killed?
>>
I'm working on learning C++
>>
>>54583225
How fast is C?
>>
>>54583225
That's strange, everybody is scared by memory management in C. Are you a God? Or just a stupid ignorant?
>>
>>54582642
i've never heard about that before and just googled it, it's basically a if elseif that checks if (i%3 == 0), (i%5 == 0) or (i%3 == 0 && i%5 == 0) or am i wrong?
>>
Ok so I fixed my matrix... but not really.
>>
>>54583248
One of the fastest usable languages, but usable is very liberally stated here.

Good luck doing anything of note.
>>
>>54583249
That's because their babby languages don't let them do memory management at all.
>>
I'm interested to see if Trump will actually make amaerica great again
>>
>>54583226
>Thanks, that makes sense, but shouldn't the children get orphaned?
They will with the & because that's what the & does (disowns a process), without it they won't get orphaned. You could try the fork bomb in a VM with user limits and watch the process tree in htop to understand it better.
>>
>>54583264
3 spaces indentation
absolutely disgusting
>>
>>54583264
Use brackets for your for-statements, you mongoloid.
>>
>>54583290
Fuck me. How could I not see this. How the fuck could I forget...
Now to see if I can fix this mess.
>>
>>54583144
47% is not most fucko.

That's also assuming those stats are even correct, when the very same page thinks that 30% of the users are female.

T O P K E K
O
P
K
E
K
>>
>>54583264
pls use eclipse and use the ctrl+shift+f shortcut

you initialize both your matrices with [10][10] and in the following line you ask the user to enter the numbers and rows of the matrix, that doesn't make sense to me

and the cin in the for loop is also not necessary, just prefill your matrix, if the values don't matter
for(int i = 0; i <= 0; i++) {
for(int j = 0; j <= 0; j++) {
matrix[i][j] = j;
}
>>
>>54583225
why were you rekt by the big dick playa then?
>>
>>54583290
can't you keep the brackets away if there is only one statement?
>>
File: Untitled.png (242 KB, 1920x1080) Image search: [Google]
Untitled.png
242 KB, 1920x1080
Guys what the hell is wrong in this code?
>>
>>54583356
Generally, you can, but you shouldn't, particularly when you're learning.
>>
>>54583332
>47% is not most fucko.
k sperg

>That's also assuming those stats are even correct, when the very same page thinks that 30% of the users are female.
the countries are probably fairly accurate, the large amount of females is probably because anons are using their mom's internet or they have faggy browsing habits
>>
>>54579725
>an object
you mean a function
>>
File: clint.gif (858 KB, 240x228) Image search: [Google]
clint.gif
858 KB, 240x228
>>54583280
>>
>>54583374
you are right, i wasn't sure if this also works in c++
>>
>>54583372
You tried to initialize 'repo' illegally.
'rep' is undeclared.
You're missing a type specifier.
'Repository' is in a weird place, resulting in a syntax error.
You're missing an ; before the &.
There are unexpected tokens after ;.
>>
>>54583377
a function doesn't have state

but sure you can get the same kind of effect like an object with a function + a monad or some meme like that, an object is just encapsulated data + methods ("functions")
>>
>>54583408
>a function doesn't have state
What are static fields, m8?
>>
>>54583372
VS doesn't support brace initialization in initializer lists
>>
>>54583426
disgusting
>>
>>54583426
Using a static field makes the function not 'pure'.
>>
>>54583404
Where exactly should I put the ; before the &? What are the unexpected tokens after ;?
>>
>>54583426
>What are static fields, m8?
parts of a Class
not a (pure) Function
>>
>>54583459
I just typed out all of the errors in your screenshot, anon.
>>
>>54574852
Fuckin nailed it, they loved me

I impressed them with big words like mySQL, python, javascript, and data management

Turns out all those hours did pay off
>>
>>54583446
>le just make everything global :^)

You can't get anything meaningful done without state somewhere along the line.
Moving the state around does not get rid of it, you're just making it more difficult to work out where it really is or should be.

>>54583458
Oh I'm sorry, I thought we were talking about productive programming techniques here.
>>
>>54583478
Yes anon I saw. The problem is that I have an identical code to this one, and that one works without problems. I literally copy pasted again this part, and it gives me those errors. I can't see for my life where that semicolon must be put.
>>
>>54583493
if you just have static fields inside a function that represents a toaster you can't have multiple toasters and you can't access those fields from other functions unless you do some convoluted scheme where you pass pointers around
>>
did i pass the fizzbuzz test?
    public static void main(String[] args) {
for(int i = 1; i <= 100; i++) {
if(i % 3 == 0) {
System.out.println("Fizz");
} else if(i % 5 == 0) {
System.out.println("Buzz");
} else if(i % 3 == 0&& i % 5 == 0) {
System.out.println("FizzBuzz");
} else {
System.out.println(i);
}
}
}
>>
>>54583474
That faggot didn't say pure though did he, he said:
>a function doesn't have state

I'm not making outlandish claims here lads, just pointing out the FP fags who don't know their earhole from their arsehole.
>>
>>54583541
kill yourself idiot
>>
>>54583535
No.
>>
>>54583554
what's wrong?
>>
there is nothing wrong with OOP don't listen to these arrogant fucktards
>>
>>54583570
Number 15 will print Fizz instead of FizzBuzz
>>
>>54583550
>Expects everyone else to know what he means when he types "function" but means "pure function"
>Calls other people idiots

So is Haskell your first or second favourite language?
>>
>>54583574
OOP is gay, learn C
>>
>>54583602
(You)
>>
>>54583535
>>54583587
>>54583570
also checking for i%3 and i%5 twice is redundant
you can eleminate one
>>
File: Triggered.jpg (44 KB, 720x599) Image search: [Google]
Triggered.jpg
44 KB, 720x599
>>54583608
>>
>>54583587
so instead of
else if(i % 3 == 0&& i % 5 == 0)


else if(i% 15 == 0)

because that includes divisible by 3 and 5?
>>
>>54583607
>living in the last century
learn ruby
>>
how to i work with bools in C?

I put bool bool1; in task main

and when I try to use bool1 like bool1 = !bool1 it won't let me?
>>
>>54583611
>you can eleminate one
no you can't, you can do i % 15 but it's not more efficient and it makes the function less extensible
>>
>>54581426
I have gotten eclipse work on windows and linux. On linux it works pretty much out of the box if you dont choose the cross compiler and use libraries installed in you system. On windows you have to fuck around with MinGW and also there are shitload of bugs related to library loading, because that shit is totally random on windows, shit tier support for 64 bit.
>>
>>54583550
>DELETE THIS
TOLD
O
L
D
>>
>>54583624
cool story bro
>>
>>54583625
i'll try again
>>
>>54583628
that's what I meant, by using i%15

how exactly is the function less extensible though? Also why wouldn't you do
if i%5
\t if i%3
\t fizzbuzz
if i%3
>>
>>54583668
if you have 6 and 10 instead of 3 and 5 you can't do i%60
>>
>>54583627
just use a char.
Or you could use a single char as a bitfield.
>>
>>54583627
Did you compile with -std=c99? Did you include stdbool.h?
>>
one more try
public static void main(String[] args) {
for(int i = 1; i <= 100; i++) {
if(i % 15 == 0) {
System.out.println("FizzBuzz");
} else if(i % 5 == 0) {
System.out.println("Fizz");
} else if(i % 3 == 0) {
System.out.println("Buzz");
} else {
System.out.println(i);
}
}
}


first if( ) check will eliminate the following checks, so if it's mod 3 and mod 5 it will print FizzBuzz
>>
Fuck Donald Trump. Racist, xenophobic trash.
>>
>>54583627
> cat foo.c
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main() {
_Bool a = true;
a = !a;

printf("%i\n", a);
}
> gcc -std=c11 -Wall -Wextra foo.c
> ./a.out
0


What's the problem?
>>
>>54583758
Take it out of main.

3 and 5 should come from function parameters, as well as the number of times to fizzbuzz.

Also, sanitize your SQL calls.
>>
>>54583625
Jesus christ, you make me feel good about my job security.

if divisible by 5
if divisible by 3 print Fizz
print Buzz
else if divisible by 3 print Fizz
else print number
>>
>>54583372
Btw fixed. It seems the problem was a circular dependency in the repos.h.
>>
>>54579782
>i thought it was pretty powerful with all the math libs and all that stuff

So python has become the hipster version of Matlab, I see.
>>
>>54583777
>that obvious false flag
>>
>>54583408
>a function doesn't have state
(define (make-account balance)
(lambda (withdrawl-amount)
(set! balance (- balance withdrawl-amount))
balance))

Stupid haskellfags.
>>
>>54579735
Fuck the forced whitespace.
>>
>>54583778
Im using C
I don't think it looks like this
>>
>>54583799
damn, what an obvious mistake
>>
>>54583812
Not pure/10
>>
>>54583804
>So python has become the hipster version of Matlab, I see.
numpy, specifically. It uses compiled FORTRAN for critical routines and beats almost every other language/ecosystem for mathematical calculations at speed.

much better than the other free-MATLABS like Octave & Scilab. Less irritating than Julia.
>>
why does *everything* break when something breaks in C++? like in this >>54583372
>>
>>54583833
I do it all the time in C89, only with chars.
Negation is a standard feature.
>>
>>54583875
Because the pre-compiler has no fucking clue what you're trying to do when certain things are written wrong, so everything inside becomes an attempt at something else entirely.

It's mostly just C++ in VS, though.

Haven't seen that in C#.
>>
>>54583778
>include <stdbool.h>
>_Bool
Nigga stdbool is basically a 1 liner that consists of typedef bool _Bool.

>>54583848
And? Still has state. OOP has state by nature. I wanna see some stateless OOP.
>>
>>54583807
He is xenophobic though.
>>
>>54583625
Don't call us, we'll call you!
>>
>>54583905
>I wanna see some stateless OOP.
I want to see a peanut butter and jelly sandwich with no bread, peanut butter, or jelly.
>>
>>54583921
>>I wanna see some stateless OOP.
OCaml.
>>
>>54583934
>stateless OOP
it ain't OOP if it has no state. The very nature of messages implies state changes. Show us this stateless "OOP."
>>
File: 2016-05-16_08-09-56.webm (44 KB, 322x378) Image search: [Google]
2016-05-16_08-09-56.webm
44 KB, 322x378
"Hey Cortana, post some bait in /dpt/."
>>
>>54583812
>functions inherently have state because there is this retarded construct in this specific language that i call a function
k tard
>>
File: 1d6hMT4.jpg (142 KB, 600x578) Image search: [Google]
1d6hMT4.jpg
142 KB, 600x578
>>54583812
not a function but a procedure.
>>
Spent an hour in my professor's office, covering his white board in Greek, trying to figure out why the hell my FFT program didn't work. Now it works, and I just have to make an inverse function (trivial now that I have the right fucking coefficients) and a write up.

This weekend, I managed to get like... 90% of the algorithm right. Unfortunately, that meant that the output was 100% wrong.
>>
>>54583972
You're stupid and ignorant. OOP has nothing to do with state. It's just how you see it.
>>
>>54583987
What retarded construct are you referring to? Sounds like someone drank the haskell kool-aid.

>>54583994
Show me that stateless oop then ocamlfag.
>>
>>54584027
>Show me that stateless oop then ocamlfag.
Too lazy to teach you. Stay ignorant pretentious brat.
>>
>>54583992
What's giving you so much trouble? I've implemented an fft before, and I just followed the Cooley-Tukey algorithm on wikipedia. Do you have some specific criteria to meet?
>>
is it just me or does /dpt/ just keep getting worse and worse, even worse than it already was
>>
>>54584071
Yes, sadly.
>>
>>54584071
what's wrong with discussing?
>>
>>54584071
The same holds for anything in life.
>>
>>54584071
Yep.

Every day I want to give up on it, but occasionally there's something interesting or someone who needs help with something I know well.

It was never good, but it was never this bad.
>>
>>54584065
Kek. It's a fucking anonymous board. You don't have to attempt to save face by being hostile when you're wrong. There is no face to save.
>>
>>54584120
Ignorant. Shut up.
>>
>>54583274
I tried that out and it really helped me understand the difference between :(){ : | :&}; : and :(){ (:) | (:)}; :, but :(){ : | :}; : appears to do nothing. I can't see any new processes being created, do you perchance have any clue what is up with that?
>>
>>54584146
I'm actually reading a page on ocaml.org about its OOP. I sure do see a lot of state here...
>>
>>54584066

Has to work for input sizes that are powers of 3, not 2. Radix-2 FFT is trivial to implement.
>>
File: iEcoNxC.webm (2 MB, 720x404) Image search: [Google]
iEcoNxC.webm
2 MB, 720x404
Ask your much beloved programming literate anything (IAMA).

>>54583972
The procedural abstraction of an object can be both functional and/or procedural.

>>54584071
It's actually getting better, probably due to the democratization of learning materials (EDX, Coursera, codecademy...)

>>54583124
No but it's less tedious once you know it.
>>
>>54584197
That's sad for you. You'll never be a good developer. You miss your chance to learn something.
>>
>>54583332
>47% is not most fucko.

It is when the next highest is 8%
>>
>>54584198
Fair enough. The generalization doesn't look to complicated but I never tried it, we just padded the data. The biggest problem I had was that the DSP board apparently didn't support doubles, but the compiler didn't tell me anything.
>>
>>54584203
And what does pure oop look like? Methods that would otherwise set a field return a wholesale copy of the object with slightly different fields?
>>
How is my overall formatting, is it organized? Should I have placed the double variables in one collumn, or is it okay how they are?

//calculate the average of 5 predetermined numbers
#include <iostream>
using namespace std;

int main()
{
double sum1, sum2, sum3, sum4, sum5, total, avg;
sum1 = 28;
sum2 = 32;
sum3 = 37;
sum4 = 24;
sum5 = 33;

total = sum1 + sum2 + sum3 + sum4 + sum5;
avg = total / 5.0;

cout << "sum1 = " << sum1;
cout << "\nsum2 = " << sum2;
cout << "\nsum3 = " << sum3;
cout << "\nsum4 = " << sum4;
cout << "\nsum5 = " << sum5;
cout << "\n\nTotal is " << total;
cout << "\nAverage is " << avg;

return 0;
}
Thread replies: 255
Thread images: 23

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.