[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 353
Thread images: 41

File: K&R c.png (1MB, 1000x1400px) Image search: [Google]
K&R c.png
1MB, 1000x1400px
old thread: >>57256927

What are you working on, /g/?
>>
File: wtf.png (557KB, 934x1000px) Image search: [Google]
wtf.png
557KB, 934x1000px
Thank you for using an anime image
>>
Thanks for the gay anime image.
>>
>>57263655
debating whether to buy "cracking the coding interview" 6th edition from amazon. should i pull the trigger?
>>
>>57263686
How is it gay?
>>
File: hnb.jpg (81KB, 750x937px) Image search: [Google]
hnb.jpg
81KB, 750x937px
interview stuff for a few hours
sure is preferable to building anything useful
>>
>>57263686
traps aren't gay though
>>
File: codemonkey.png (42KB, 1217x228px) Image search: [Google]
codemonkey.png
42KB, 1217x228px
put this in the last thread as soon as it died

New to programming, trying to make this program where it prints out the results of votes but when I call this method. Instead of calculating the results and printing them its asking me for then in this box, whats wrong?
>>
>>57263747
>int totalVotes
>totalVotes = candidate1Votes / candidate2Votes
Why is totalVotes a parameter?
>>
File: McDowell--026.jpg (117KB, 1000x665px) Image search: [Google]
McDowell--026.jpg
117KB, 1000x665px
>>57263708
you could spend a couple days with a libgen copy to see if you like it
in any event it's priced pretty reasonably

>>57263747
how are you calling it
this seems like an issue specific to an unpopular ide so you may be waiting a while
>>
>>57263747
you're probably following some tutorial, so either follow the tutorial or don't. the method you posted isn't causing the box to appear. if you want to be spoonfed, make

public static void main(String args[]){
printResults(5, 2.0, 3.0);
}

and run main
>>
>>57263776
>how are you calling it
This might be it, if he is calling it as printResults() because he doesn't understand what a parameter is >>57263774, maybe BlueJ decides to prompt for him to fill in the missing parameters?
>>
>>57263708
>conspire to make all software interviews stupidly difficult
>publish book that makes all those problems just go away!

Cracking the Coding Interview is literally racketeering, and so is requiring a 4 year BSc just to write websites.
>>
Why is cross compiling so painful?
>>
File: aaaaaaa.png (21KB, 654x576px) Image search: [Google]
aaaaaaa.png
21KB, 654x576px
>>57263774
Should it not be? When I remove it it won't compile

>>57263785
It's more of an exercise than a tutorial, it doesn't go into specifics it just tells me what to make and I gotta figure it out

>>57263807
>>57263776
You sound like you're on to something. Here's the top half of the code if it helps at all
>>
How to make fucking tables with rowspan on various number in django?
>>
>>57263834
it aint like it's a 300 dollar textbook.
>>57263776
just bought it.

i'm a little anxious because i have a research internship set up this summer dealing with machine learning, not an actual software development internship. do you think people will cast me aside for it? i didn't even think of it until now that it's not really a software development internship. it goes nicely with my mandatory senior honors project is the thing
>>
>>57263655
if (op.image.IsAnime() == true)
{
post("fuck you for watching anime weeaboo scum\n>>>/a/\n")
}
>>
Hey guys knew to programming and I wanted to know what's the point in using statements like:
printf("℅s World", "Hello");
When you could simply do
println("Hello World);
Speaking of Java btw
>>
>>57263874
did you not read the second half of my comment? i told you exactly what you need to do to run the method
>>
>>57263880
Work on your English first, then learn a programming language.
>>
>>57263879
>needing to copy and paste this because you don't understand it
>>
>>57263880
public void displayUsername(String name){
printf("You are logged in as %s", name);
}
>>
>>57263900
How could you not understand this? It reads like normal English.
>>
Let's make a Java program together, /g/.
public class fourChan {
>>
>>57263900
Who says I copied/pasted?

I just wrote it out
>>
>>57263893
Typing on a phone, now tell me the answer
>>
>>57263879
>== true
>>
>>57263874
>Should it not be?
A parameter is used to pass a value from outside the function to the function. You are just using totalVotes, candidate1Share, and candidate2Share as variables, not receiving them from outside the function.

>When I remove it it won't compile
You should do
public void printResults()
{
int totalVotes;
double candidate1Share;
double candidate2Share;

/* ... */
}

This declares those as local variables, not parameters, and now you can just call
printResults();


>Here's the top half of the code if it helps at all
What you should post is where in your program you call printResults
>>
Hey guys i'm new to coding and my java won't work here's my code
public class myClass {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}

Help!
>>
>>57263909
Wouldn't
println("You are logged in as " + name);
still be perfectly sufficient?
>>
>>57263977
yeah
>>
>>57263880
Because maybe you might want to greet the world differently. You could then replace "Hello" with the name of a variable and store the greeting there, and the program will print out the greeting. My C is rusty so I'll use Python:

greeting = raw_input()
print("%s world!" % greeting)
>>
If I can't get access to my office's MS Exchange server and I can't use SMTP without messages being forwarded to Outlook spam boxes, how can I have an in-application message system? Not a live chat, but more of a post or note system.
>>
>>57263974
>my java won't work
Go away.
>>
>>57263977
in this specific example it's probably fine
in general when combining fixed and variable text i think printf has a lot to recommend it
>>
>>57263974
it needs to be in a file called myClass.java
>>
>>57263655
optimizing a random tree regressor

I have no idea what I'm actually doing but it's getting better.

And I learn to like python and hate the python community.
>>
File: 122.png (5KB, 323x143px) Image search: [Google]
122.png
5KB, 323x143px
>>57263948
Fucking perfect anon. The code did tell me to declare them as local variables and that's what I thought I was doing by making them parameters. Works a treat now.

This is what happens when you get thrown in the deep end. This is only my second program that I'm actually creating and not just reading about.
>>
>>57263880
>printf("℅s World", "Hello");
This code is trash, never write like this.
printf("%s, %s - %s.", name, greeting, ending)

is much faster & more readable than
println(name + ", " + greeting + " - " + ending + "."); 
>>
Functional languages are weird. Did I do this retarded? Trying to do exercises out of a book on Elixir, it's the basic high-or-low number guessing game. Seems to work properly at least.

defmodule Chop do

def guess(n, low..high) when n in low..high do
g = div(low+high, 2)
IO.puts "Is it #{g}?"
check_guess(g, n, low..high)
end

def check_guess(g, n, low..high) when g < n, do: guess(n, g..high)
def check_guess(g, n, low..high) when g > n, do: guess(n, low..g)
def check_guess(g, n, low..high) when g == n, do: IO.puts g

end
>>
>>57264038
No problem. That's what I'm here for :)
>>
>>57264071
10/10 would rather be taught java by you than by books and some pakistani who can barely speak English
>>
File: goodlookingresult.png (54KB, 1743x782px) Image search: [Google]
goodlookingresult.png
54KB, 1743x782px
How do i make tables in Django with rowspanning on number of repetitive occurrences? After adding "squats", row with "bench press" and "overhead press" span on 4 but I want it to span on 3 because i only have 3 "bench presses"
>>
File: 2016-10-27_17-34-26.webm (2MB, 768x768px) Image search: [Google]
2016-10-27_17-34-26.webm
2MB, 768x768px
>>57263655

I'm working on making curves using OpenGL
>>
Anyone in here reading/read "Objects First With Java"? What are your thoughts on the book?
>>
>>57264090
bottom table looks about right, idk what you're talking about
>>
what do when after x layers of abstraction the classes start to pile up close to 100 methods?

Im thinking to split up everything and to create some sort of modular entity approach (1 entity and then you can add modules with certain properties). but this has its own challenges.

what do?
>>
>>57264112
>>57263880
Kinda fucked that up, let's try again.

Let's say you want to use 3 or more variables there.

printf("℅s ℅s, my name is %s", sHello, sWorld, sName);


Looks cleaner than:

println(sHello + " " + sWorld + ", my name is " + sName);
>>
>>57264112
i also always assumed that the library was doing something more efficient than four string concatenations
>>
>>57264127
I dont want it to look like this
>>
Trying to solve a Project Euler problem... I have a grid of numbers and I need to find the maximum sum (choose one number per row, and add the number to a number adjacent to it and below).

Currently using a map of Coord (a class that contains information about the row and column) and ints (representing the sum at each Coord). How would I go about accessing a certain element within a map?

I'm trying to use this function:
bool doesMapContainKey(map<Coord, int>& mapToCheck, Coord& check)
{
bool doesContain = false;
std::map<Coord, int>::iterator it;
it = mapToCheck.find(check);
if(it != mapToCheck.end())
{
doesContain = true;
}
return doesContain;
}


to see if a map contains a Coord as a key, but I get the following error:
...usr/include/c++/v1/__functional_base:63:21: Invalid operands to binary expression ('const Coord' and 'const Coord')


What should I do?
>>
>>57264129
what do you even mean
>>
>>57264038
You'll notice your percentages probably aren't what you'd expect.

>>57263874
candidate1Votes and totalVotes are integers (int).

The division operator ( / ) works differently when dividing two integers than when dividing two floating point numbers (double). Dividing two integers returns only the integer part, which is 0 in this case since the percentages would be something like 0.30 (30%) or 0.75 (75%), etc (if a candidate had 100% of the votes it would print 1.000000). Its still formatted as a float because you used %f in the formatting string but you've lost the decimal part.

To keep it, you should convert the operands of / to doubles, which you can do like this:
candidate1Share = (double) candidate1Votes / (double) totalVotes;

This is also known as "casting". You are changing an int value (e.g. 42) to a double value (e.g. 42.0) so that / gives you a double value back instead of truncating (removing the decimal part).
>>
>>57264233
> doubles
Why? float should be accurate enough for his purposes.
>>
File: 1474221076415.jpg (35KB, 463x611px) Image search: [Google]
1474221076415.jpg
35KB, 463x611px
>>57263879
> == true
Opinion discarded
>>
>falling for this bait every single time
>>
>>57263930
>now tell me the answer
Go fuck yourself
>>
>>57264252
Sure, he was already using double though, and for this simple exercise there's not really any difference either way.
>>
>>57264228
really simple. let me give an example:

you have base class Building. now you start expanding it vertically like
SmallHouse extends Building
SmallHouseWithGarage extends SmallHouse
SmallHouseWithGarageAndLawn extends SmallHouseWithGarage

and so on. now with every layer you get a whole bunch of shit added and suddenly you get stuff you dont really need on higher levels.

now what I mean with modular approach would look like this:
entity Building (empty so far)
#add(HouseProperties) (has the same properties of a house)
#add(LawnProperties) (has the properties of a house with a lawn. but no garage)

understandable?
>>
>>57264327
sounds like you want Interfaces and composition instead of inheritance.
>>
>>57264327
Yeah, that approach is better.
>>
>>57264327
Inheritance was a mistake.
>>
>>57264327
Woah, so novel and esoteric.
class HouseWithLawn {
HouseProperties isHouse;
LawnProperties isLawn;
}
>>
>>57264385
wouldn't a decorator be better in this example?
>>
>>57264455
to achieve Maximum OOP SmallHouse must implement the interfaces Lawnable and Garageable.
>>
>>57263921
What? He's that one who doesn't understand.

>>57263928
It's exactly the same as the previous time you posted it. Is this the only code you know?
>>
>>57264419
did I say that? entity systems are nothing new, Im just trying to improve the horizontal communication. not so easy if its for a library and amount of properties are unknown.

>>57264385
doesnt really solve the problem that it turns into spaghetticode. and no hot-swap in runtime.
>>
>>57263942
>>57264261
>implying readability is bad
Go back to making fizzbuzz in scheme you neet fucks

>>57264507
Not exactly the same. I added '\n' to the end of the post last time.
>>
>>57264536
Why would you use 4chan if you don't like anime?
>>
File: giphy5434567.gif (1MB, 320x240px) Image search: [Google]
giphy5434567.gif
1MB, 320x240px
>>57264233
amazing, was contemplating if I should shit up the thread again with more easy java questions but you've saved me anyway. Thank you
>>
>>57264505
class SmallHouse implements Leggable
>>
>>57264536
I'll bite
isThing()
is more readable than
isThing() == true
>>
>>57264505
you could just make a House abstract class. And make Lawn, Garden, Garage ... classes who implement it and use them as Decorator. Lawnable and Garageable sounds gay.
>>
>>57264160
it looks good though, it's avante garde
>>
>>57264678
>>57264505

fuck, I didn't mean implement I meant the extend thing
>>
Does anyone still compile for x86 instead of x64?
>>
>>57264768
We all compile for Javascript now
>>
>>57264838
but I compile for Stallman
>>
>>57264768
Isn't it x86-64?
>>
>>57264768
>compiling

just run it in your head, pajeet
>>
>>57264884
that's 'cum piles'
>>
>>57264559
Why would you program if you don't have a job?

>>57264599
nah m8
>>
>>57264913
x64 a well-understood colloquial nickname for x86-64, so that we don't have to write the full thing all the time
>>
    for(int i = 0; i < m*n; i++){
if(i % m == 0 && i != 0) std::cout << "\n";
std::cout << matrix[i] << " ";
}

uh so why does it ignore the matrix[i] print when the if statement is entered?
>>
>>57264995
No wonder you invented PHP, anti-weeb
>>
>>57264768
Why would i compile for x64 if i don't need long long pointers?
>>
>>57264995
Yeah 'm8', "If this is that thing" makes more sense than "If this is that thing is true"
>>
>>57265022
it doesn't
>>
>>57265022
Because you don't flush your print buffer,
>>
>>57265022
do you mean doesn't?
>>
>>57265092
>>57265143
good thought i was going crazy, guess im just too tired and am making some other dumb mistake
>>57265139
should maybe read up on whats happening in iostream someday
>>
>>57265055
It's explicit rather than implicit brah.
>>
>>57265055
Why not

(x == true) == true
>>
>>57265246
you want it to be like this right?
if(i % m == 0 && i != 0)
std::cout << "\n";
else
std::cout << matrix[i] << " ";
>>
128 bit cpus when
>>
Advocating using (x == true) instead of x is like saying you should write id(x) instead of x "to really make sure it's x".

== true is the identity function on booleans, so it's really not a stretch.
>>
>>57265320
nahh thats what i thought was happening which made me question everything
>>
>>57265246
>should maybe read up on whats happening in iostream someday
Hey, i'm not going to take the rap for you asking the wrong question.
>>
>>57265370
What language are you talking about? Some languages you literally have to perform a boolean test.
>>
>>57265431
Probably dynamically-typed garbage, right?
>>
>>57265423
have it coming though, i mean shit i use it in every damn piece of code i write it's like the first thing i should look up
>>
OK, we've been tasked with creating a data type that describes a person. The info that we want to store about that person is: first name, last name, age, height, phone number, and favorite ice-cream flavor. I don't know about you, but that's all I ever want to know about a person.
>>
>>57265515
copy that bravo, we'll be on your six in twelve
>>
>>57265431
such as?
>>
> What are you working on, /g/?

TFW you just rewrote a couple of subroutines from a shit code to an elegant code, reducing it size by half.

I'm being happy, that's what I'm doing. Unfortunately though, because I spent all time today on refactoring, I didn't do shit.
>>
>>57265606
haskell
>>
>>57265045
I compile for x86-64 because my Linux system won't run x86 code (it's not worth the effort of building all of the libraries for both 32-bit and 64-bit, and disabling x86 support in the kernel eliminates some potential security issues due to legacy x86 cruft).
>>
>>57265497
I've seen people spend hours trying to debug correctly functioning code, simply because their trace prints didn't happen when they though they should, because they didn't flush their prints.

This is especially hilarious when people start to learn threads.
>>
>>57265660
That's a legitimate enough reason.
>>
>>57265674
threads coming up next semester, ill make sure to actually go through the chapters before then
did some multithreading before (not c++), was enough weird bugs without adding unnecessary ones
>>
>>57265431
There are some languages (C) where doing the additional == true test could actually be wrong. if (x) is said to be true if it is any non-zero value, but 'true' is one specific non-zero value, hence where if (x) is true, if (x == true) may not be true.
>>
>>57265674
But debugging (or testing) multi-threaded code is often pointless. You just have to make sure you get it right to start with.

You have to screw up quite badly to get race conditions which are more likely than not to trigger for any given test case.
>>
File: cleancode.jpg (31KB, 386x499px) Image search: [Google]
cleancode.jpg
31KB, 386x499px
What does /g/ think of this book? Is this a good way to write code or is he full of shit?
>>
>>57265967
If it's not FP then throw it away

FP is the way to write clean code
>>
>languages that don't have tuples as a built in
hate having to create structs everytime I deal with coordinates tee bee age
>>
GOOGLE, REVEAL THE ALGORITHMS!
>>>/pol/94792586
>>
File: logo.gif (6KB, 133x63px) Image search: [Google]
logo.gif
6KB, 133x63px
>>57265989
FP stands for Free Pascal, right?
>>
>>57266459
No, it stands for functional programming
>>
>>57266492

Which is shit.
>>
>>57266395
wtf i love merkel now
>>
>>57266502
>Which is shit?
OOP is shit
>>
>>57265817
Console printouts tend to slow down your code quite significantly if you tend to use them heavily for trace prints, like me. This tends to increase the likelyhood of data races to standard out.
>>
>>57263874
>BlueJ
God that shit is annoying.

>Voting
That reminds me of when I learned the algorithm to find the majority element in linear time. Without pictures I had to ruminate over it pretty hard to convince myself it worked.

https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_majority_vote_algorithm
>>
>>57266516

Okay, guy.
>>
>>57266722
do fp now
>>
>>57266502
>>57266722
Tripfags never fail to have shitty opinions
>>
>>57266502
Elaborate
You can't
>>
>>57266829
>>57266829
Right? It's almost like they were Anon.
>>
>>57263926
public private abstract static factory new factory() implements final static interface private try boolean void Factory factory catch return instanceof protected class finally throws new transient switch while null
>>
>>57263926
main = do 
putStrLn "Hello fourChan!"
>>
>>57263926
}
>>
anyone else realizing design patterns arent really a meme?
>>
>>57267019
No.
>>
Rate my strrev function!
char *strrev(char *dest, const char *src)
{
unsigned len = strlen(src);
src = src + len;
while ((*dest++ = *--src))
if (src == src - len)
break;
*dest = '\0';
return dest - len;
}
>>
>>57264199
I would write such code as:
bool doesMapContainKey(map<Coord, int>& mapToCheck, Coord& coord){
return mapToCheck.find(coord) != mapToCheck.End();
}

Not sure if it solves your problem.
Posting a line number does not help if you don't post the full file
>>
>>57264199
Coord is not a primitive so std::map::find cannot compare the two, you need to provide own comparator/overload the == operator
>>
>>57267019
>can't program
>repeat yourself rather than learn
>>
>>57267041
correction:
End() needs to be end()
>>
>>57265606
reducing the size of the code is not always good
>>
>>57266855
>Elaborate

Computer programming and mathematical computations (the things which FP is trying to model) are not related in any way.
>>
>>57267038
it's shit
>>
File: 1475785898560.jpg (19KB, 222x293px) Image search: [Google]
1475785898560.jpg
19KB, 222x293px
>>57267088
>mathematical computations (the things which FP is trying to model)
>>
>>57267084
Code readability and maintainability >>>>>>>> Performance

Though this is a moot point because 99% of the time, giant functions aren't written for performance, they're just terribly written.
>>
Why don't we all collaborate on writing making something?
>>
>>57267130
my point was that reducing the code size may decrease readability
>>
>>57267150
last time /g/ tried to collaborate on something Tox happened
guess how that turned out...
>>
>>57267151
If you start resorting to multiple side effects per line, probably.
>>
>>57267168
https://tox.chat/ ? Doesn't look too bad at all.
>>
>>57267207
doesn't work that good though
and how many people have you heard say they use tox?
>>
Can GitHub be used as reference for software development experience?

I read from a blog that it's haram because:
>not commiting enough == lazy
>commiting too much == willing to work for free

I have no software dev experience because my internship was a bust.
>>
>>57264385
Interfaces are inheritance.
>>
>>57267226
I wouldn't exactly expect /dpt/ to put together the next facebook.
>>
>>57267235
I just hired some guy that built a DSL for resume-making, open sourced it, put it on his github, then built his resume using it.

I cant even remember how many commits per day he had.
>>
>>57267263
A bunch of people have been making imageboards lately, would make sense for us to collaborate on one.
>>
File: mongoclown.png (65KB, 2104x1768px) Image search: [Google]
mongoclown.png
65KB, 2104x1768px
Bluej clown back again with one final question, sorry.

I've pretty much wrapped up the program, there's a method that allows you to set the voting as completed or not. I'm trying to program it so that if the voting is completed it won't let you vote again, and that if the voting isn't completed it won't let you look at the results. However this seems to having no effect at all, whats going wrong?

Here's the related code all chopped together
>>
>>57267390
But they're all shit.

https://github.com/microsounds/akari-bbs
>meh

https://github.com/bakape/meguca
>bloated (Go, meme.js) and fucking google-analytics...C

https://github.com/tslocum/TinyIB
>PHP? No thenks

And we don't need to do anything really
>git clone https://github.com/bitcoin/bitcoin.git
>>
>>57267502
I like where akari-bbs is going, but it has a long way to go to be able to replace this site.
>>
>>57267502
>they're all shit
perfect reason to make a good one then
>>
>>57267250
No, it's not. It's subtyping only.
>>
>>57267499
if (completed = false)

= is the assignment operator, == is for comparison.

if (completed == false)

will work. Since completed is a boolean itself you might more typically see
if (!completed)

! means "not", so it reads "if not completed ..."
>>
>>57267502
>akari-bbs
>meh

What kind of features are you looking for, anon?
>>
>>57267556
I wonder how 4chan handles the volume. It cant be with a single sql database, can it?
>>
File: 1472138091296.gif (424KB, 157x157px) Image search: [Google]
1472138091296.gif
424KB, 157x157px
>>57267591
Bingo, thank you anon. It's finished now

Learned a lot more from you guys today that I do from a 2 hour lecture
>>
>>57267565
Okay help me out.
Assuming we make a blockchain based imageboard:
How do we promote block mining? If the network is lazy and too few nodes use their computing power, it could be easily attacked.
How to moderate stuff? Is it needed? Basically if their is too many pedo stuff, it will just become banned and targeted by NSA.
Also, blockchain is overkill since all posts don't need to be stored forever.

Anyone got a better idea? Should we really go P2P?
>>
>>57267556
>I like where akari-bbs is going,
What do you mean exactly? It doesn't have any interesting features (or many features at all, really).
>>
>>57267614
No shadows... :3

>>57267655
It's simple. Only the content matters.
>>
>>57267650
>How to moderate stuff?
You can't.

Creating a blockchain from scratch to host an imageboard is a silly idea.
>>
>>57267580
Using inheritance.
>>
>>57267710
Inheritance of what?
>>
>>57267640
probably a multi-relational database that manages image, post, thread, board, name, and IP
>>57267655
I like that it works at least for text, just need to make it work like a text board on 4chan and it'll be golden
>>
>>57267670
>No shadows... :3
CSS is not hard, Anon.
>It's simple. Only the content matters.
It would be a nightmare to use if it had more traffic. I think it's definetely impressive from a technical point of view, but it's not really that good. No h8
>>
>>57267640
>It cant be with a single sql database, can it?
Sure it can, easily.
>>
>>57267707
>You can't
Prove it then? P=NP desu.
>>
>>57267773
You are the one who has a claim to prove. By default you can't go back and delete stuff on, say, the bitcoin blockchain. So it's on you to prove you can implement a way to do it without compromising the entire point of having it be blockchain-based.
>>
File: reddit-alien.jpg (95KB, 1024x1424px) Image search: [Google]
reddit-alien.jpg
95KB, 1024x1424px
>>57263655
Remember like 18 months ago when this fag was trying to force this trap meme for dpt and he kept getting denied and removed by the janitors? I guess the homosexuality of /g/ guaranteed he would eventually win.

Fuck this. I'm going back 2 reddit. Enjoy your AIDS and your Fizzbuzz in C, you fucking queers.
>>
>>57267841
>Fuck this. I'm going back 2 reddit.
d-did we finally do it?
>>
>>57267841
>I'm going back 2 reddit
success!
>>
File: 1473262042526.png (55KB, 217x190px) Image search: [Google]
1473262042526.png
55KB, 217x190px
>>57267841
>Fuck this. I'm going back 2 reddit.
I hope this isn't bait
>>
>>57267841
>Fuck this. I'm going back 2 reddit
(you) and don't come back
>>
>>57267841
>trying to piss in an ocean full of piss
>finally realizing what he is doing
>but still calling others gay when he's the biggest faggot in the thread

Oh well.
>>
>>57267764
We get 12 million users per day, most mashing f5 on their favorite threads. I doubt a single db could handle the load.
>>
>>57267841
Bye. :)
Also, don't forget the first rule of Reddit:
Be nice. Fucking faggot.
>>
>>57267841
>Fizzbuzz in C
Haven't seen FizzBuzz posted in a while desu

Let's see them lads
>>
>>57267917
>most mashing f5 on their favorite threads.
This doesn't actually matter because of caching.
4chan really doesn't have that much disk I/O going on.
>>
>>57267755
>It would be a nightmare to use if it had more traffic

Do you mean the single-thread layout?
Because that was meant to be a temporary thing while I get proper threads up and running.
>>
File: meme fizzbuzz 2.png (24KB, 514x323px) Image search: [Google]
meme fizzbuzz 2.png
24KB, 514x323px
>>57267936
>>
>>57267724
The interface.
>>
Is valgrind supposed to give eye cancer?
>>
>>57267936
https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
>>
File: 1468731493795.jpg (273KB, 959x716px) Image search: [Google]
1468731493795.jpg
273KB, 959x716px
>>57267975
too abstract
>>
>>57267985
Which is just a type. "Inheriting" the interface is subtyping that type, and implementing an interface is giving a value for that type.
>>
>>57267965
>Because that was meant to be a temporary thing while I get proper threads up and running.
I thought so. I just mean that it's currently not that interesting *yet*
>>
File: jg.jpg (368KB, 1360x768px) Image search: [Google]
jg.jpg
368KB, 1360x768px
http://openjdk.java.net/jeps/295

>JEP 295: Ahead-of-Time Compilation
>Status Targeted
>Compile Java classes to native code prior to launching the virtual machine.

It's coming, guys. aot compilation for java.
>>
>>57268003
fizzbuzz :: forall a. a
fizzbuzz = fizzbuzz
>>
>>57268046
But running in a VM is an actual redeeming feature of Java that keeps it somewhat relevant.
>>
File: snapshot1.png (7KB, 728x431px) Image search: [Google]
snapshot1.png
7KB, 728x431px
>>57267936
https://gist.github.com/anonymous/b045d2ac0dda7e2f64ad874c45cf699f

Rewriting the Fizzbuzz kernel in Pascal
>>
>>57268072
or do the same as ART

https://en.wikipedia.org/wiki/Android_Runtime

>send .class to client
>client aot compile .class on installation
>???
>profit
>>
>>57267940
How could caching work when there are multiple new posts every second in popular threads?
>>
>>57268321
AJAX is also a thing
>>
>>57268321
Ever notice how you can make a post and it won't show up for at least 30 seconds?

That's caching.
You're being served a static webpage.
>>
>>57267019
In the Dawkins sense, absolutely. In the fourchan sense, no.

They're meant to be bite sized pieces of information that you can abstract away to work on other details, even if it's not an exact 1-to-1 relationship to the underlying problem.
>>
File: 1476553936959.jpg (38KB, 500x667px) Image search: [Google]
1476553936959.jpg
38KB, 500x667px
How to deal with having no version control at work?
>>
Does Haskell have operator overloading?
>>
>>57268574
git init
>>
>>57268601
You can define arbitrary operators
>>
>>57268574
tar -czf "../backup-$(date).tar.gz" ../code
>>
>>57268574
Easy.

Switch jobs to a non-shit company.
>>
>>57268640
But can i redefine existing standard operators? +, -, *, /
>>
>>57268601
Yes and no.

Many operators work on type classes, so you can define an instance for Num which allows you to specify how + and - work for your type. The signature can't be changed from "Num a => a -> a -> a" so you can define e.g. multiplication between two matrices resulting in a matrix, but not multiplication between scalars and matrices.

However, you can define your own operators using combinations of non-letters.
>>
File: 1477502427072.gif (415KB, 480x238px) Image search: [Google]
1477502427072.gif
415KB, 480x238px
>>57268612
>>
>>57268687
Yes, there are two ways

1) Make a Num instance. +-/* will need to obey certain type signatures (a -> a -> a, for some specific a)
2) Use NoImplicitPrelude and define them like regular functions, or make your own custom typeclasses
>>
>Bjarne basically saying he would love to design a new C++ but doesn't want to compete against c++

Pretty sad lads
>>
>>57268743
>Bjarne trying to sabotage programming for another 30 years
>>
>>57268714
>>57268723
Cool. Thanks.
>>
>>57268764
Modern c++ isn't his fault.
ISO committees getting too big and bolstered was.
>>
>>57263655
hey /g/

im writing a gui in java, and need to move a GUI item with a mouse drag. ive got it prety much working, however theres a bug. basically, the items dont move at the same rate as the mouse, e.g. if i move the mouse 10 pixels in any direction, then the item moves 20, so the problem isn't the direction, just that it doesn't move at the same speed of the mouse.

i moved it by saving the cursor position when i start dragging, and when the mousedrag event occurs, i just subtract the old position from the current, and move the items by this.

any idea what could cause that?
>>
>>57268816
Modern C++ isn't the problem, it's less like C++ than ever
>>
>>57268601
You can define your own operators (infix functions) and it has function overloading, so yes.
>>
>>57263655
>just discovered FFCALL in C

my fucking dick, who even needs C++11 lambdas anymore?
>>
>>57268612
this
>>
>>57267054
I defined an '==" operator within the Coord class, but the error still persists:


bool operator==(Coord& second)
{
bool equals = false;
if(this->getRow() == second.getRow() && this->getCol() == second.getCol())
equals = true;
return equals;
}
>>
File: 1471719526619 (1).gif (844KB, 800x786px) Image search: [Google]
1471719526619 (1).gif
844KB, 800x786px
>>57269169
>equals = false
>if (cond) equals = true;
>return equals;
>>
Why the fuck are ordinary unions STILL not implemented in Rust?
>>
>>57269309
Type-punning, maybe?
>>
>>57269309
Ada doesn't have this problem
>>
what's the deal with weebs being so fucking annoying? they're to anime what muslims are to islam
>>
>>57263879
What's the algorithm for figuring out if a pic is anime or not
>>
>>57269422
it's a trained neural net
>>
>>57269415
You've been dealing with autistic people, what do you expect?
>>

bool operator==(Coord& second){
return(this->getRow() == second.getRow() && this->getCol() == second.getCol()));
}
>>
>>57269412

Ada is an advanced and beautiful language.
>>
>>57269269
I thought it was the other way (returning twice within a function)that was looked down on
>>
>>57269422
for you
>>
>>57268574
Is version control the same as source control?
>>
>>57269169
>>57269463
>>
>>57269473
just return the expression you have in the if statement

also you forgot you're using !=
>>
guys, sbcl says coord is undefined even though I defstructed like so
(defstruct coord x y)

what gives
>>
Is there a good way (in java) to put a char and an int together into a string?

currently I have
 String output = char + "" + int; 

but I feel like that's a bad way to do it
>>
>>57269309

I have no clue but at the rate Rust is going, it's going to have to at least take another 1-2 years before it can at least get features and stuff C and C++ have that are semi important to systems programming.

Most of the effort I've seen in Rust has been entirely focused on the high end side of things and backend/frontend work. Not too much effort has been taken apart from a pretty equivalent/better than expected freestanding implementation.

However, missing stuff like unions and memory allocation to a byte boundary are massive oversights which boggles my mind how they haven't been rectified yet.
>>
>>57269549

>Not too much effort has been taken apart

I meant that not too much effort has been taken on the low end/systems level.
>>
>>57269488
>(this->getRow() == second.getRow() && this->getCol() == second.getCol()))
Yeah, that makes sense... Hadn't really seen it written that way before...

'm still having this error, and have no idea why this: >>57269169 still gives me an error about the invalid operands... If it helps, when I click on the error in XCode, I'm sent to a different file and this is highlighted as the source of error:

struct _LIBCPP_TYPE_VIS_ONLY less : binary_function<_Tp, _Tp, bool>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x < __y;}
};
>>
>>57269528
have you tested it before asking this fucking question?
>>
>>57269549
>However, missing stuff like unions and memory allocation to a byte boundary are massive oversights which boggles my mind how they haven't been rectified yet.

I can tell you - because that's the "modern way" to program. Low-level stuff is boring, so they just shove it together there, make it work someone, and then they are working on the high-level stuff.

From personal experience I can say that they are not gonna be successful with that. Although I at least can point to mere inexperience, not to laziness.
>>
>>57269591
It works though, I just feel like it's a shitty way to do it.
>>
>>57269597
>someone
somehow - god damn, it was a long day.
>>
>>57269602
what do you want to do with? and why do you think it's not the right way?
>>
Okay so I started college in September and since then I've been using Sublime + Terminal (compiling with clang, on Mac) for C.

Should I be using an IDE. I tried using Eclipse CDA but it seems far too bloated for the work I need to do, which are literally just single .c files. It was also pretty slow in general

Should I be learning to use an IDE or should I just stick with the text editor and terminal?

The reason I didn't use Xcode as opposed to Eclipse was because I know we will be doing Java later in the course
>>
>>57269578
So this is "readable C++"...
>>
learning lisp was a mistake...
>>
>>57269614
I want to put a char and int into a string
for example a 'b' and 1 will become b1
> and why do you think it's not the right way?
Because it looks messy I guess
>>
>>57269616
Just my personal preference, and limited to Visual Studio and Eclipse - but whenever I have to use an IDE I have to choke. Intellisense is not worth it half the time, and a CLI is just way comfier than a GUI.

IMO you should get accustomed to both, only to decide which one suits you better.
>>
>>57269616
this is a religious debate
i personally don't like ides very much
>>
>>57269578
I dont do C# so I'm guessing but what if you move out the "this->"-notation out of the if-statement, seems that could be problematic.

bool operator==(Coord& second){
var row = this->getRow();
var col = this->getCol()
return(row == second.getRow() && col[spoiler][/spoiler] == second.getCol()));
}
>>
Is it a good idea to take a database result set and map it to my own custom data transfer object to pass back to my domain layer? I want to be able to find an item, create the transfer object, and then pass it back to the domain where that item is loaded with the data from the transfer object.
>>
>>57269643
>Because it looks messy I guess
you could do it like this if you like this better
StringBuilder sb = new StringBuilder(2)  ;
char c = 'b';
int a = 1;
sb.append(c);
sb.append(a);
>>
>>57269309
how do you make them safe?
>>
>>57269616
IDE's are nice. I love vim, but can't be fucked putting in the time to automate make bullshit.
>>
>>57269732
You don't. It's an unsafe thing, mostly for FFI.
>>
>>57269616
I'd skip the IDE. You'll pick up good habits and learn the language faster if you use a text editor. IDE is basically bloat for autocomplete, which most text editors support anyway.
>>
>>57269749
i understand you better now. that, i think, they are working on
>>
>>57269778
>You'll pick up good habits and learn the language faster if you use a text editor.
Absolutely no. Learning how to program using nothing but a text editor and a compiler/interpreter, leads to debugging by printf, lack of automated testing, lack of integrated source control etc.
>>
>>57269740
Make is extremely simple to understand and very powerful once you figure it out.

It even lets you write makefiles in a generic way so you never have to update it again, even as your project grows.
>>
>>57269809
printf debugging predates all your fancy IDE crap.
>>
>>57269809
No that's learning how to program in general. Do you think some chucklefuck is gonna write an automated test just because he's using a 500$ IDE?

If you hand a newcomer an IDE, all of the following things will happen.

>my project is misconfigured how do I fix it? python sucks
>I dont know how to use this function and i'm too lazy to read the docs but autocomplete suggested it so might as well
>how does code get run, anyway? How does the green play button know what to do?
>>
>>57269616
You should try and get a copy of CLion. made by JetBrains.
>>
>>57269809
I unironically use print debugging. I hate it, but gdb makes me mad.
>>
>>57269897
Actually, it doesn't. Debugging predates visual consoles, when all you had to go from was measuring voltage in your actual registers.
>>
File: cinnameg-masterrace.png (130KB, 760x1564px) Image search: [Google]
cinnameg-masterrace.png
130KB, 760x1564px
>>57269809
if you used cinnameg, you'd be able to make use of the built in automatic example testing
>>
>>57269982
Just use vim or emacs or even fucking Eclipse as front-end to GDB.
>>
>>57269990
What IDEs were people running on their oscilloscopes?
>>
>>57269990
debugging predating visual consoles doesn't mean debugging doesn't predate IDE's

baka
>>
>>57270001
>Python and Java does not have built in unit tests

The creator of that image is a retard.
>>
>>57269875
I know make for the most part, I just don't like it.
>>
>>57270025
idk about python, but java didn't have build in unit tests last time i used it. you had to use extraneous testing frameworks like junit
>>
>>57270023
>>57270010
There's no principal difference in printing the register in GDB or using hardware breakpoints and halting execution and measuring voltage on the different register bits
>>
>>57270031
Have you used the automatic variables?
How about the built-in implicit rules?
>>
>>57270042
Python unittests are part of standard library. So are threads, but there's the issue about the GIL.

https://docs.python.org/2/library/unittest.html
>>
File: Hky9k2W.gif (21KB, 1150x950px) Image search: [Google]
Hky9k2W.gif
21KB, 1150x950px
How are you enjoying writing Go today?
>>
>>57270112
I wish I was, but I can't think of anything to make. Propose a meme webapp for me to make.
>>
>>57269422
if (op.image.dimensions <3) {
printf("Thank you for using an anime image!");
} else {
printf("Saged.");
}
>>
what app should I make in Haskell so the cute girl on the train notices me on the train?
>>
>>57270057
patsubst is a gateway to makefile ricing
>>
>>57270112
Go is harmful anon.

Friendly reminder that type safety in Go is completely lacking, when using generics you have to cast your data into the correct type aka Java 1 style

Also, friendly reminder that Go's preferred way of importing/including code is to import directly from github/bitbucket using an URL, and has no form of security or version handling whatsoever (so if library changes, your code breaks). Go's recommendation to work around this, is to download the git repos physically and store them along with your project.
>>
>>57269875
>>57269740
>>57270031
>>57270057
>>57270152
Rate my Makefile

### Functions ###
range = $(if $(filter $1,$(lastword $3)),$3,$(call range,$1,$2,$3 $(words $3)))
make_range = $(foreach i,$(call range,$1),$(call range,$2))
equal = $(if $(filter-out $1,$2),,$1)


### Variables ###
limit := 101
numbers := $(wordlist 2,$(limit),$(call range,$(limit)))

threes := $(wordlist 2,$(limit),$(call make_range,$(limit),2))
fives := $(wordlist 2,$(limit),$(call make_range,$(limit),4))

fizzbuzz := $(foreach v,$(numbers),\
$(if $(and $(call equal,0,$(word $(v),$(threes))),$(call equal,0,$(word $(v),$(fives)))),FizzBuzz,\
$(if $(call equal,0,$(word $(v),$(threes))),Fizz,\
$(if $(call equal,0,$(word $(v),$(fives))),Buzz,$(v)))))


### Target ###
.PHONY: all
all: ; $(info $(fizzbuzz))
>>
File: 1465641317981.gif (4MB, 298x400px) Image search: [Google]
1465641317981.gif
4MB, 298x400px
>>57270133
Twitter bot that bullies https://twitter.com/antibullyranger

>>57270159
Go does not use URLs for importing, just because it has github.com in the name doesn't make it a URL.
>>
File: 98424394.jpg (30KB, 532x487px) Image search: [Google]
98424394.jpg
30KB, 532x487px
>>57270185
w-what does this do
>>
>>57270212
Stuff
>>
>>57270194
>Go does not use URLs for importing, just because it has github.com in the name doesn't make it a URL.
It fucking downloads the code directly from github

OR

*YOU* download the code from github, point go at it and have to INCLUDE every single fucking library you rely on INTO your own repo

What THE ACTUAL FUCK were Rob Pike & co thinking???? This "UNIX philosophy" bullshit is insane.
>>
pascal
haskell

coincidence?
>>
>>57270212
>w-what does this do
Pic related
>>
>>57263655
scraping, parsing being half-good code monkey

does any one have a suggestion for a linux alternative to fiddler?
>>
File: 1476471852927.jpg (196KB, 900x900px) Image search: [Google]
1476471852927.jpg
196KB, 900x900px
>>57270224
There is special support to handle sites like github, it's an implementation detail.

We have over 80 packages at work and it just werks ;DDD

Just actually do management of versions yourself instead of relying on a tool.
>>
>>57270150
an app that scans for nearby pokemon for your apple watch.
>>
>>57270275
sounds real fuckin' useful, guy
>>
>>57270275
my rolex doesn't have apps. should I get an apple watch??
>>
>>57270265
>There is special support to handle sites like github, it's an implementation detail.
Not only is that a massive security risk, you also risk breaking your entire project because THERE IS NO FUCKING VERSIONING

I mean, as a minimum, they could have allowed you to specify a specific commit hash... Would that have been so hard??

>We have over 80 packages at work and it just werks ;DDD
Sounds like your work is a hipster place and your projects are all a bunch of microservices.

Go is fine for microservices. Go is not fine for larger projects.

>Just actually do management of versions yourself instead of relying on a tool.
This is an admission of defeat anon.


Also, there's the complete lack of type safety. The complete lack of any form of modern exception or error handling. Optional GC when you don't have any form of pointer arithmetics or pointer semantics (which makes an optional GC just fucking useless).

Go is harmful and should not be used.
>>
>>57270287
yes do it they're on sale for $600 now. cute girls will like you
>>
>>57270260
Sadly, no. Not specific to web. I know some IDEs, like JetBrains IDEs have their own browser plugin to do similar kind of stuff.
>>
File: 1474736301657.jpg (50KB, 500x714px) Image search: [Google]
1474736301657.jpg
50KB, 500x714px
>>57270302
There was never any claim about go get being more than just fetching and installing what you fetched. If you want specific versions add it to the package name or manage it yourself.

The tool was never there for version management and people who think it did do so are idiots tbqf. Exceptions are also a meme. You can do pointer arithmetic just fine, use package unsafe.
>>
>>57270194
>Twitter bot that bullies https://twitter.com/antibullyranger
I'm not much of a bully, unless we're talking about bullying cute girls... any other suggestions?
>>
>>57268743
Sounds like he needs (the) D
>>
>>57270357
> If you want specific versions add it to the package name or manage it yourself.
That's fucking ridiculous. What the fuck were the authors thinking?

>The tool was never there for version management and people who think it did do so are idiots tbqf.
It's quite reasonable to assume that something made in the fucking 2010s can do simple versioning.

Also, you keep referring to it as some kind of external tool. It's part of Goland, anon.

>Exceptions are also a meme
I'm not talking about C++ style exceptions, I'm talking about exception and error handling.
>>
>>57270357
>he thinks exception are a meme in the days of nothrow and exception-safe guarantees as well as specific exception throwing

Why is /g/ so fucking retarded?
>>
Error handling should be monadic or done with algebraic effects, something like that. Then whether the error is implemented with an algebraic data type or a "native" exception can be abstracted away.
>>
File: plot1436047953600.png (578KB, 640x867px) Image search: [Google]
plot1436047953600.png
578KB, 640x867px
Hey guys, newbie here. How would I go about programming mutually exclusive buttons from scratch? I need to make some in structured text. Here's what I've got:

IF b3 = TRUE THEN
b1:= FALSE;
b2:= FALSE;
END_IF;
IF b2 = TRUE THEN
b1:= FALSE;
b3:= FALSE;
END_IF;
IF b1 = TRUE THEN
b2 := FALSE;
b3 := FALSE;
END_IF;

But I don't know how to make it follow a sequence so it won't toggle a button I just pressed.
>>
File: mfw-mustaine.jpg (63KB, 500x375px) Image search: [Google]
mfw-mustaine.jpg
63KB, 500x375px
>>57270247
>>57270185
wat

FizzBuzz in GNU Make? How? Why?
>>
>>57270423
>monadic
>muh maybes
>silently swallow errors and allow computation
MEME
E
M
E
>>
>>57270426
event driven programming

it's not 1970 anymore
>>
>>57269693
I talked to some people, and basically, the reason this didn't work is because of how maps are organized in C++. Because maps are trees, you need either a "<" or ">" operator, and I don't have that

Besides, the
 this->
operator simply refers to an attribute of the object you're working in (the one you're defining the class for), so I wouldn't really know why that would be a source of error. Thanks anyways!
>>
File: 1471536273806.jpg (256KB, 1280x960px) Image search: [Google]
1471536273806.jpg
256KB, 1280x960px
>>57270411
I write C++ on the side quite a bit, I don't like the complexity of exceptions especially in concurrent systems.
>>57270399
You can use defer and recover to build C++ style exceptions.
>>
>>57270232
>To postulate a state-less model of computation on top of a machinery whose most eminent characteristic is state, seems to be an odd idea, to say the least. The gap between model and machinery is wide, and therefore costly to bridge. No hardware support feature can wash this fact aside: It remains a bad idea for practice. This has in due time also been recognized by the protagonists of functional languages. They have introduced state (and variables) in various tricky ways. The purely functional character has thereby been compromised and sacrificed. The old terminology has become deceiving.
yes
>>
>>57270466
Your quarrel is not with exceptions but with side effects.
>>
>>57270466
>I write C++ on the side quite a bit, I don't like the complexity of exceptions especially in concurrent systems.
Well, I write it for a living and there's nothing wrong with exceptions in a concurrent environment, especially with lock_guards.

>You can use defer and recover to build C++ style exceptions.
But that's not the same thing at all... Exceptions don't recover.
>>
>>57270488
>>57270466
Ignore the last part, I realise now it's a go semantic thing.
>>
File: 1466625603257.jpg (57KB, 500x500px) Image search: [Google]
1466625603257.jpg
57KB, 500x500px
>>57270483
I should have clarified that, it's one of the things I don't like about it.
I don't think the error interface with multiple returns is perfect, far from that, but I do think it's more practical than exceptions.
>>57270488
I know they can work, I just don't like the flow of them.
>>
>>57270457
>Because maps are trees, you need either a "<" or ">" operator, and I don't have that
I thought that C++ maps were implemented using a hash table?
>>
>>57270590
On a related note, I spend most of my day writing SAS targeting AIX and z/OS, I might be getting oldfashioned from it.
>>
>>57270590
The only real difference between exceptions and "algebraic errors" is that the former is optimized to ideally never happen (at the cost of being really expensive if it does happen), and the latter eats some overhead in order to make it inexpensive to go either way, but slightly slower than exceptions.
>>
>>57270443
>silently swallow errors
nope
>allow computation
????
>>
>>57270628
Exactly, it's called EXCEPTIONs for a reason.
>>
>>57270643
C++ just integrates them really poorly, that's all.
>>
File: 1466783035880.png (446KB, 1500x2000px) Image search: [Google]
1466783035880.png
446KB, 1500x2000px
I like maybe types idea
>>
>>57270654
You say this, but you keep being pretty vague about what your problem really is.
>>
>>57270662
Wrong anon.
>>
>>57270672
>i don't really have a problem with exceptions, just the way C++ do it
>what do you mean? you're vague about what you refer to
>no, you're wrong!

?

Am I being trolled here?
>>
>>57270694
Two different anons, I mean.
>>
>>57270658
>I like maybes

Pig disgusting:
http://pastebin.com/XcczWLZA
>>
>>57270710
Oh, sorry. Yeah, lack of comma. My mistake.
>>
How can I learn what a monad is without learning me a haskell?
>>
>>57270601
I checked, and you might be thinking of unordered_maps, which are implemented with hashes (http://www.cplusplus.com/reference/unordered_map/unordered_map/)
>>
>>57270747
A monad is a monoid in the category of endofunctors.
>>
>>57270747
a monad is like a burrito
>>
For some reason, using ONLY text editors for every project, no matter the language, no matter the size of the project, gives some false sense of superiority.

You're not better because you're writing C++ in vim vs. somebody writing Java in Intellij
>>
>>57270757
>>57270763
>>57270747
Monads are stateful containers, but they are still pure because only the runtime is tainted.
>>
>>57270658
is good
>>
>>57270790
Funny. I was always better than Java programmers writing in Intellij.
>>
>>57270763
donde esta la biblioteca?
>>
>>57270805
No, not really. You've got things the wrong way around (monads are far more abstract), and you don't understand purity.
>>
>>57270747
Imagine a car that drives a specific way.

Now imagine the concept of other objects that can drive in that same way, but maybe you can call them Sally or buy them a drink even though you know it's not going to lead to anything at the end of the night but you do it anyway because the societal norms of chivalry are instilled into us on an almost instinctual level and feminism failed your dreams are dead
>>
>>57270836
Tell me more about how the IO monad in Haskell does not act like a stateful container.
>>
>>57270836
>You've got things the wrong way around
So the caller is a stateful container and the monad is the state?
>>
>>57270805
I've made something like that in scheme. I think I get the general concept then.

I saw some video by a greek fag who said monads are things that implement flatmap, was he full of shit?

>>57270839
>but maybe you can call them Sally or buy them a drink even though you know it's not going to lead to anything at the end of the night but you do it anyway because the societal norms of chivalry are instilled into us on an almost instinctual level and feminism failed your dreams are dead
I understand very well, I have been faced with this situation many times. It truly feels hopeless.
>>
what language should i use as i go through cracking the coding interview? my aim is to master 1 language
http://www.strawpoll.me/11519740
>>
>>57270878
>>
>>57270858
I didn't say that. I know that IO is just State (((World))).

But A => B is not B => A and purity is only about observable side effects, it's got nothing to do with only being "tainted" at runtime.
>>
nu bread >>57270889
>>
>>57270880
new, btw

>>57270878

>>57270892
sorry anon, you were too late
>>57270880
>>
>>57270881
>purity is only about observable side effects, it's got nothing to do with only being "tainted" at runtime.
The argument as for why IO in haskell is pure is because the IO monad returns impure code, but the original code itself is still pure. So only the runtime is tainted.
>>
>>57270858
You're talking about a single monad that happens to have state. Monads, in general, are not stateful containers.
>>
HAHA MOM I SPLIT THE THREAD AGAIN
>>
>>57270952
This is just >>57270892 's honest mistake. It was only a minute or so difference, he probably didn't even realise.
>>
>>57270903
Monads are technically pure, and they are not the only pure way of expressing impure operations to be performed at runtime.
However rather than arguing about what is and isn't pure, it's more useful to realize that Haskell makes all impure operations explicit, and that purity can be (almost) guaranteed for code not embedded in IO.
Thread posts: 353
Thread images: 41


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.