[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: 326
Thread images: 18

File: not an anime picture.png (88KB, 713x667px) Image search: [Google]
not an anime picture.png
88KB, 713x667px
Previous: >>57631945

What are you working on, /g/?
>>
>>57635912
first for lisp
>>
>>57635923
second for this
>>
>>57635912
>linking xkcd unironically

cringe
>>
File: polite conversation.png (311KB, 2072x1984px) Image search: [Google]
polite conversation.png
311KB, 2072x1984px
Good code is readable code, which is to say code that is easily understandable, even for novices. The situations where you need complex and tightly written code that should be written and maintained by true experts are very rare these days.
>>
/codereview/
Problem statement - Give an integer n, write a function that returns 1 if n is even, and 0 if n is odd
int returnsOne() {
return 1;
}

int returnsZero() {
return 0;
}

int isEven(int n) {
int *(*fptr[2])();
fptr[0] = &returnsOne;
fptr[1] = &returnsZero;
return fptr[n&1]();
}
>>
>>57635940
ok
>>
>>57635945
int is_even(int n)
{
char buf[100];
sprintf(buf, "%d", n);
int len = strlen(buf);
if (buf[len - 1] == '0' || buf[len - 1] == '2' ||
buf[len - 1] == '4' ||
buf[len - 1] == '6' ||
buf[len - 1] == '8')
return 1;
else
return 0;
}
>>
>>57635945
most interesting solution i've seen so far tbqh
>>
>>57635945
print ('even' if (-1)**n==1 else 'odd')
>>
Reposting from last thread.

 
class A
{
public:

static void (A::*whatever)();
};


I need to figure out how to assign and call
whatever
.

I know how to do it when it's non-static.

class A
{
public:

void ok(){};
void (A::*whatever)();
};

int main()
{
A a;
a.whatever=&A::ok;
(a.*a.whatever)();

return 0;
}


But I can't figure out the static version.
>>
>>57635945
What is even the point of closures?
Why would you willingly mix data and code like this?

>here's a function that returns a customized function that returns what you want (probably)
WHYY
>>
>>57635994
A::whatever();
>>
>>57635945
That's a pretty good trick anon.

It's been a while since I've programmed in C and the function pointer declaration syntax looks excessively ugly.
>>
>>57636018
won't compile.
>>
>>57635994
class A {
public:
static void whatever() { };
};

int main() {
A::whatever();
}
>>
>>57636011
Because you can then change the clojured function by simply changing the data.
>>
>>57635940
ok
>>
>>57636052
Probably because you have such an odd declaration for your static variables. Just use
static void whatever();
>>
>>57635940
What do you mean by this?
>>
>>57636054
whatever
needs to be a pointer to a method.
>>
>>57635945
a=a=>+!(1&a)
>>
>>57635945
int isEven(int n) {
if (n % 2 == 0) return 1
return 0
}
>>
Javascript is the best language ever
>>
>>57636072
This is homework all about pointers to methods. This is the last problem but nothing I try works.
>>
>>57636114
nope
>>
>>57636120
its creative
>>
Trying to learn some F#

let evenodd x = if x % 2 = 0 then printfn "Even" else printfn "Odd"
>>
>>57636011
No branches, therefore no branch prediction miss. The only operator used is a single &.
>>
>>57636114
>>57636120
EDIT:
I actually really like the syntax, but its browser only, so I'd also learn different languages like C
>>
>>57635940
>The situations where you need complex and tightly written code that should be written and maintained by true experts are very rare these days.
So basically you're saying everyone should write crappy code and experts should have to struggle with the poor architecture of novices rather than have novices learn and adapt to experts?

Do you have employment somewhere? I need to protect my stocks.
>>
>>57635994
You need to implement whatever as global variable outside class A.

class A
{
public:
static void (A::*whatever)();
};

static void (A::*whatever)();

int main()
{
A::whatever = &someFun;
}


I hope i didn't mess up the function pointer syntax.
>>
>>57636146
printfn (if x < 2 = 0 then "Even" else "Odd")
>>
>>57636152
node is the future man
it has better performance than other scripting languages
>>
>>57635940
Complex code can work perfectly fine, but adequate comments and inline functions make readability 100x better
>>
>>57636077
>>57636154
The point is that you are writing code for your audience, not the compiler. Your audience is your team members, and if they can't read the code, two things are true:
>You have written bad code.
>You are on the wrong team.
>>
>>57636168
neat
>>
>>57636168
%
>>
int is_even(int n)
{
char buf[100];
int i = 0;
if (n >= 0) goto E;
n = -n;
E: ;
if (n == 0) goto LABEL0;
L1: if (n == 0) goto E1;
i[buf] = (n%10) + '0';
n/=10;
i++;
goto L1;
E1: ;
buf[i] = '\0';
int len = i;
i = 0;
int j = len-1;
L2: if (i >= j) goto E2;
int temp = buf[j];
j[buf] = i[buf];
i[buf] = temp;
i++;
j--;
goto L2;
E2: ;
if ((len-1)[buf] == '0') goto LABEL0;
if ((len-1)[buf] == '1') goto LABEL1;
if ((len-1)[buf] == '2') goto LABEL2;
if ((len-1)[buf] == '3') goto LABEL3;
if ((len-1)[buf] == '4') goto LABEL4;
if ((len-1)[buf] == '5') goto LABEL5;
if ((len-1)[buf] == '6') goto LABEL6;
if ((len-1)[buf] == '7') goto LABEL7;
if ((len-1)[buf] == '8') goto LABEL8;
if ((len-1)[buf] == '9') goto LABEL9;
LABEL0: return 1;
LABEL1: return 0;
LABEL2: return 1;
LABEL3: return 0;
LABEL4: return 1;
LABEL5: return 0;
LABEL6: return 1;
LABEL7: return 0;
LABEL8: return 1;
LABEL9: return 0;
}
>>
>>57636116
Oh I see. Try
static void (A::*)(whatever)()
as your declaration.
>>
>>57636184
I thought the compiler, and ultimately the end user, were my audience.
>>
>>57636146
C# equivalent:
void EvenOdd(int x) => WriteLine(x % 2 == 0 ? "Even" : "Odd");
>>
>>57636184
>The point is that you are writing code for your audience, not the compiler.
So we're writing code that's not meant to run anywhere. We're doing this as a masturbatory exercise where we share code in arbitrary choice of language (since it's not supposed to execute anyway) just to show off to our friends.

I know there's coding competitions and such but most programmers wouldn't consider themselves programmers when they do this.
>>
>>57636169
node is awesome for ppl who really like JS, but i will probably stay with C. Is node interpreted or compiled?
>>
>>57636149
Duh, lookup table would have been quicker
>>
>>57636224
p.s. This is how I generally view people who praise functional programming languages.

Because they're generally crap even if the concept is sound.
>>
>>57636224
In order to work as a team, you have to be able to understand what is going on, and to tell if something is wrong with high accuracy. You have to tailor to your lowest common denominator
>>
>>57636195
Is this troll?
>>
>>57636229
>JS
>is it compiled
>>
>>57636209
You thought wrong.

Even if you're working completely alone, YOU are the audience, because you must be able to come back to it six months later and understand the code well enough to maintain it efficiently.

>>57636224
Modern languages allow you write code that performs to a practical standard, while also being readable by humans.

The idea is that adding complex design patterns and sophisticated decoupling is absolutely unnecessary for some projects, particularly when you're working with a team of non-experts.
>>
>>57635945
>>57636246
Documented version
int is_even(int n)
{
char buf[100]; // Buffer for string representation for int
int i = 0;
if (n >= 0) goto E;
n = -n; // Handle negative ints
E: ;
if (n == 0) goto LABEL0; // Handle zero explicitly
/* BEGIN: Convert int to one string character at a time*/
L1: if (n == 0) goto E1;
i[buf] = (n%10) + '0'; // A[i] = i[A] = *(A+i)
n/=10;
i++;
goto L1;
E1: ;
/* END */
buf[i] = '\0'; // Null terminate
/* BEGIN: Reverse string so most significant digit is at 0-th index*/
int len = i;
i = 0;
int j = len-1;
L2: if (i >= j) goto E2;
int temp = buf[j];
j[buf] = i[buf];
i[buf] = temp;
i++;
j--;
goto L2;
E2: ;
/* END */
/* Check the least significant digit */
if ((len-1)[buf] == '0') goto LABEL0;
if ((len-1)[buf] == '1') goto LABEL1;
if ((len-1)[buf] == '2') goto LABEL2;
if ((len-1)[buf] == '3') goto LABEL3;
if ((len-1)[buf] == '4') goto LABEL4;
if ((len-1)[buf] == '5') goto LABEL5;
if ((len-1)[buf] == '6') goto LABEL6;
if ((len-1)[buf] == '7') goto LABEL7;
if ((len-1)[buf] == '8') goto LABEL8;
if ((len-1)[buf] == '9') goto LABEL9;
LABEL0: return 1;
LABEL1: return 0;
LABEL2: return 1;
LABEL3: return 0;
LABEL4: return 1;
LABEL5: return 0;
LABEL6: return 1;
LABEL7: return 0;
LABEL8: return 1;
LABEL9: return 0;
}
>>
>>57636249
I was talking about node.js not js.
>>
look no variables
a=a=>+!(!!a&a)
>>
>>57636229
>Is node interpreted or compiled?

Sort of both?

https://github.com/v8/v8/wiki/Design%20Elements#dynamic-machine-code-generation
>>
>>57636260
Holy shit
>>
File: GurbYtG.png (184KB, 326x341px) Image search: [Google]
GurbYtG.png
184KB, 326x341px
>>57636262
>>
>>57636260
that's some GNU project quality code right there
>>
>>57636260
>A[i] = i[A] = *(A+i)
kek does this actually work?
>>
>>57636290
You realize you can compile literally any language? The question is not "can you compile it" but "does a compiler exist"?
>>
>>57636260
This made me happy before I fail my test.
>>
>>57636297
Yes. A = pointer to first element, so *(A+i) dereferences A + i elements. A[i] is the same as i[A]
>>
>>57636252
But what's the point of maintaining code that doesn't compile or no one executes?
>>
>>57636309
This. If you can't write your own compiler, you should probably quit programming.
>>
>>57636242
I say you have to change the lowest common denominator or get rid of him.
>>57636252
>some projects
What kind?
The kind where you write redundant software that already exist and what you're really aiming to do is re-implement something for the millionth time.

If you're doing that just use or write software that translates what others have done into a format where you can easily extend it. For instance reverse-engineer just the UI for the application you aim to copy and inject your own.
>that's illegal
I don't know. But nobody will be able to tell when you've obfuscated it.

Your job can be automated if you're
>YOU are the audience
So? If you've written it once and you were really crappy at it you can write it again and just retain the inputs and outputs. In fact if you're not gonna do it better the second time around you should probably retire or accept the fact that you can't really comment on how to write good software.
>>57636249
Stupid stupid old man.
>>
>>57636297
A[i] is translated to *(A + i)
so it stands to reason that i[A] would translate to *(i + A) which is identical.

It's just a fun C quirk.
>>
>>57636320
bullshit
>>
>>57636309
>>57636320
The question wasn't "can you compile it" it was "is it interpreted or compiled", dipshit.
>>
>>57636321
>Your job can *easily* be automated if you're
Writing software that doesn't do anything new.
>>
>>57636315
>>57636324

I mean...that makes sense. C is so shady lol.
>>
>>57636321
There also comes a point where making it less readable doesn't make it run faster. Inlining functions can't be that hard, and it shows intent a lot better than a conglomerate of math and binary operations
>>
>>57636316
Your team is your primary audience.

It is only incidental that the compiler must be able to run the code as well.
>>
>>57636339
C gives it to you how it is, you could say other high-level languages were the "shady" ones for hiding things from you.
>>
>>57636380
Man this makes me want to learn C.
>>
>>57636398
Do it. C is basic enough that you can learn it in a week (assuming you know basic programming constructs)
>>
>>57636398
do it, it's actually really easy
>>
>>57636159
>>57636205
Neither compile, unfortunately.
>>
What's the point of learning algorithms like sorting when there are standard libraries for everything?
>>
>>57636421
class A
{
public:
static void (A::*whatever)();
void f(){};
};

void (A::*A::whatever)();

int main()
{
A::whatever = &A::f;
}

there you go
>>
>>57636321
>I say you have to change the lowest common denominator or get rid of him.
Yes, let's pay 20% more salaries for the same end-result.

Few programming projects require experts.

For example, a data integration for a particular API, for a particular web-application, for a particular client, on a particular dataset, that needs to be transformed in a particular way and delivered as a particular file format to a particular email.

Maybe you spend extra time creating big, black binders of inheritance with Haskell libraries tacked on and a sprinkling of complex nested objects and their interfaces, as well as a little memory management hack using a magical binary number to improve performance by 6%...

At this point, you've perfectly met the projects needs. Great!

However, no one else at the company knows meme languages like Haskell, nor did you comment the magic bit-level hack, and so now you're going to get hit by a bus and no one can maintain that shit.

Maybe what you've created was elegant, fast, and exceeded expectations. It doesn't matter if no one else on YOUR CURRENT TEAM can fix it.

In another environment, with a higher-paid team, that same code could be considered good, but not with a particular audience.
>>
>>57636362
Well you obviously have no idea how to make things go fast. Compilers trivially inline functions nowdays and it's very rare that they make a mistake. It's not where you put any of your focus. For some general clues to how true this is. There's no __forceinline (MSVC specifier to force the function to be inlined where called in code, bar places where you're calling a pointer to the function) equivalent in the C++ standard. It's because it's generally a stupid idea.

You're so far away from actually knowing what you're talking about you can't even see the subject.

Algorithmic optimization (generally what you do when you consider big-O notations) is trivial enough that anyone can do it. But it's not enough to deliver decent performance. Not for anything non-trivial. Which again, if you're just making trivial things I do genuinely recommend you just do it in HTML/JS. Users seem to prefer web-interfaces and if you do an OK job they can be snappy.
>>
>>57636458
Knowing when to use those algorithms and what is suitable for your problem comes from learning what the algorithms do themselves.
>>
>>57636364
No. Runnable, usable software is primary goal.
The team and code maintainability is incidental to keeping up the primary goal.
>>
>>57636458
What if you need more than what the standard library offers?
Imagine if you had a metric toolbox and you come across imperial bolts.
What now?
You can't build your own tools because you're just a CRUD codemonkey pleb.
>>

>>
>>57636458
> What's the point of learning to add up when calculators exist?
> What's the point of ovens when microwaves exist?
> What's the point of parents when children exist?
>>
>>57636458
There's no good reasons to learn algorithms (and datastructures) in general.

Understanding the way algorithms (and datastructures) are invented is far more useful.

Knowing the names of them and looking up a table of their generalized performance numbers is useful though.

But nobody should actually implement their own linked list.
>>
>>57636479
You're misunderstanding.

Runnable, usable software is EASY to obtain. You can get this outcome with both complex and simple code.

However, given a particular team, both complex and simple code are not acceptable, as the complex code is generally unnecessary for runnable, usable software, and only serves to create more technical debt.
>>
>>57636490
Spooky
>>
33 get
>>
>>57636488
>Imagine if you had a metric toolbox and you come across imperial bolts.
I go to the store and fucking buy some imperial fittings like a normal human being.

Who the fuck has an entire metal-casting setup in their back yard? Even if you did, those homebrew tools are not going to be as good of a quality, because there's a massive investment into producing high-quality tools.

0/10, shit analogy.
>>
>>57636521
You have to go back.

>>>/b/
>>
>>57636532
The metallurgy foundry analogy doesn't fit here because the act of writing new library code is fundamentally identical to the act of using standard library code.

Why don't you try writing strstr?
You might actually learn something, and you'll learn to appreciate all the hidden abstraction that you take for granted.
>>
>>57635912
How much do I need to know programming to be able to find a job in it? I think I'm decent enough in it, but I don't want to quit my job to go look for one.

Also, how much should I ask for a NY/USA wage?
>>
>>57636499
by usable, i also mean optimised.

it's sometimes prudent to sacrifice short term primary goal in favour of the primary goal in long term

i think we largely agree with each other, but to me you are talking about the difference between complex code with a purpose and OOP retardants for the sake of dogma.
>>
>>57636562
>the act of writing new library code is fundamentally identical to the act of using standard library code
It must be nice to live in a world where time has no meaning. Either that, or your time is completely worthless.

>You might actually learn something, and you'll learn to appreciate all the hidden abstraction that you take for granted.

No, thanks.

Instead, I'll spend that time actually creating something with the massive variety of tools that are available, rather than being proud of a FizzBuzz-tier script that doesn't use any standard library functions.
>>
>>57635937
>unironically making a snarky comment about xkcd on /g/
Like a damn fiddle.
>>
People literally go to coding bootcamp for 6 weeks and land jobs with 120k pay, so not a lot apparently
>>
>>57636642

>>57636617 for u

https://news.ycombinator.com/item?id=13006555
>>
>>57636626
>mfw crud codemonkey thinks he's a real programmer near me
>>
>>57636617
Impostor syndrome is common among programmers. Most programmers are shit. You can get a job (and keep it) despite being a remarkably poor programmer (even by your standards I bet). Fizzbuzzes are actually used which should give you a hint of the level of entry level positions.

So really you're probably good enough.
>quit your job to go look for a new one
That's not how it works. Just look for a job on your spare time.
>US wages
I'd say google is better than asking here.
Mostly NEETs around here.
>>
>>57635912
i'm learning web dev stuff with Go and JS, and i'm going through the MIT algorithms book with Go.

i'm going to Go kill myself
>>
>>57636665
>Impostor syndrome is common among programmers. Most programmers are shit.
Oh and to be clear. A lot of programmers think they're not good enough, while the actual standards are low.

I'm not saying programmers are all shit and are feeling bad about it.
>>
>>57636618
>by usable, i also mean optimised.
Those are completely different concepts, and modern languages are performant already with standard library functions to the point that rolling your own for the sake of "muh optimization" is going to generally cost disproportionally more in dev time and technical debt, than what it would save in computation cycles.

>it's sometimes prudent to sacrifice short term primary goal in favour of the primary goal in long term
Very true, but consider the following:
Simpler code may be "harder" to maintain later. However, code that is complex to a certain degree may be quite easy to maintain for an expert, but literally impossible to maintain for an entry-level dev.

In a case such as this, it is more financially responsible to write "worse" code, due to the intended audience, considering that the software will run virtually equivalent in performance either way.
>>
>>57636701
>modern languages are performant already
No.
And this is not a decent understanding of what 'modern languages' are.

You can take ADA and write a good compiler for it and it's gonna run fine. It's not about how modern the language are. It's that computers are now fast enough to run your crappy code in a lot of instances.

But as soon as you have anything worth keeping you need to know more.
>>
>>57636725
>You can take ADA and write a good compiler for it and it's gonna run fine.
This. It's just that it's not a very trivial task to optimise such a high level language with all those high level constructs.
>>
>>57636665
>That's not how it works. Just look for a job on your spare time.
Honestly, that just seems like I'm being a dick to my boss
>>
>>57636657
>React, Node, or JavaScript
asdfhajksdhf
>>
>>57636772
Well your boss and the company doesn't give a shit about you, you'd be a fool to think otherwise.
Also, what's the alternative?
Finding a new job becomes much harder when unemployed because everyone wants someone who is already employed.
>>
>>57636809
>Finding a new job becomes much harder when unemployed because everyone wants someone who is already employed.
This is wisdom.

Get an offer in hand before you put in your two weeks' notice.
>>
>>57636772
>that just seems like I'm being a dick to my boss
Well if you're feeling bad about it tell him you're considering switching careers ahead of time. Maybe you're valuable enough for him to negotiate a higher pay or something to stay. It's something he will have to come to terms with.

Ideally as a employer he'd keep you employed for nothing. He's probably a nice guy since you're concerned but you have to think about yourself, he will understand that.

Absolute worst case he's a horrible boss and a horrible employer who fires you on the spot (assuming you don't have any laws against that) just to spite you. But that's very unlikely.
>>
I need to learn the Spring framework and I'm wondering where to start. I'm familiar with plain old java but that's it.

Should I buy a book on JSP and Servlets and learn that, then move onto Spring? Or just dive right into a Spring book?
>>
>>57636701
>it is more financially responsible to write "worse" code, due to the intended audience
Sounds like you're sacrificing long term in favour of shorter term, by hiring Pajeet, and not letting your employees get up to speed with the better solutions.

But yeah, i see now what you mean now by catering to my audience.
>>
>>57635945
sub is_even{
return !($_%2);
}

is_even(@ARGV[0]);
>>
>>57636469
I'm not saying that inlining functions makes it run faster. I'm saying that functions in general make the code run faster, and the function being inlined (whether explicit or automatic) removes any overhead for a function call.
>>
>>57636459
Thank you, mate.
>>
Nasa Directory of Software Engineering says they uses Node.js for their space suits.
(source: https://twitter.com/CollinEstes/status/738767017843515393)

Can you fedora-wearing memes stop using C now and use a proper language like Javascript? Nobody uses that anymore rofl
>>
>>57636963
Javascript is light and fast, so it makes sense that they would use it.
Especially since you're not going to run into an allocation error or something stupid while you're up in space because a dev missed it in testing.
>>
>>57636772
If you haven't been a dick to your boss, they shouldn't care that you're looking for new opportunities.
>>
Good git tutorial?
>>
File: tmmhtd.png (24KB, 240x240px) Image search: [Google]
tmmhtd.png
24KB, 240x240px
Learning haskell. Rate my fizzbuzz.

fizzBuzz :: [Integer] -> String

fizzBuzz [] = ""
fizzBuzz (x:xs)
| x `mod` 15 == 0 = "FizzBuzz " ++ fizzBuzz xs
| x `mod` 3 == 0 = "Fizz " ++ fizzBuzz xs
| x `mod` 5 == 0 = "Buzz " ++ fizzBuzz xs
| otherwise = show x ++ " " ++ fizzBuzz xs

main = do
line <- getLine
putStrLn (show (fizzBuzz [1..(read line)]))
>>
>>57636981
life
>>
>>57636981
git add file
git commit -m "commit"
git push origin master

literally done
>>
>>57636981
I would suggest this CS oriented overview of Git if you're into those kinds of things
http://eagain.net/articles/git-for-computer-scientists/
>>
>>57637013
fizzbuzz n = case (mod n 5, mod n 3) of
(0,0) -> "fizzbuzz"
(0,_) -> "buzz"
(_,0) -> "fizz"
_ -> show n


is much better
>>
>>57637018
you forgot
git checkout <existing branch>
git checkout -b <new branch>
git push origin <branch>
git pull
git pull origin <branch>

and ya done
>>
>>57636958
>>57636459

Well it works. But sometimes C++ makes me want to kill myself.

 
class A
{
public:

void ok(){std::cout<< "fug";};
static void (A::*whatever)();
};

void (A::*A::whatever)();

int main()
{
A::whatever=&A::ok;
A a;
(a.*a.whatever)();

return 0;
}
>>
>>57637018
Thanks, i kind of wanted to move beyond the extreme basics.
>>
>>57637013
>>57637034
Write in a code that is readable 2bh
>>
>>57637078
That any of those two, but >>57637034
is as simple as you can go. Readable as fuck.
>>
>>57637078
kys, c faggot
I bet you think
switches are more radable than haskell cases
>>
>>57637096
not*
>>
>>57637102
Wakeup call: they are
>>
>>57637102
Literally nothing is readable in that meme language
>>
>>57637013
Not bad, try to split up the behaviour

fizzBuzz :: Integer -> String
-- convert just a single number to a string
fizzBuzz x
| x `mod` 15 == 0 = "FizzBuzz"
| x `mod` 3 == 0 = "Fizz"
| x `mod` 5 == 0 = "Buzz"
| otherwise = show x

main = do
num <- readLn
print (map fizzbuzz [1..num])
-- print is putStrLn of show
-- readLn is read of getLine
-- we use map to apply fizzBuzz to every integer in the list

-- mapM_ (putStrLn.fizzBuzz) [1..num]
-- slightly more advanced version


notes:
>>
>>57637096
>whatever the fuck that shit is
>readable
lolzors

>>57637102
See above
>>
>>57637013
you're a fucking disgrace
how about you map fizzbuzz to xs and not build in list processing wihtin fizzbuzz like you did

>++ fizzBuzz xs
>4 times
that should tell you you're being retarded

do you know what even map or mapM are, learn
>>
TIS-100 is on HumbleBundle
Should i get it?
>>
>>57637141
*notes are in the comments

mapM_ (putStrLn.fizzBuzz) xs
is kind of like

foreach x in xs
putStrLn (fizzBuzz x)
>>
>>57636956
Doesn't matter. Your post clearly shows you have no idea because you think the choice of making something a function or not a function is in any way relevant to code quality.

With very few exceptions it's free to make functions, ignoring compile times. So it has nothing to do with hard to read code because it's optimized vs easy to read but slow code.

It's simply irrelevant. The only reason I could think you'd say that was how you might not know

What usually makes performing code harder to read is either the deep level of abstractions required to hide away the data to retain the 'easy to read' stuff. (but imo it just fails) Or simply that you're exposed to those details.

AoS vs SoA is a good example. You'd normally think about a struct of coordinates as a point, but often it's better to have a struct of arrays, where every point is instead specified by an index for each component. I.e.:
//AoS
struct point{
int x,y,z;
}
//later
//point points[10];
//sqrt(points[i].x*points[i].x+points[i].y*points[i].y)
//just accessing the fields to demonstrate use

//SoA
struct points{
int x[MAX_POINTS];
int y[MAX_POINTS];
int z[MAX_POINTS];
}
//later
//sqrt(points.x[i]*points.x[i]+points.y[i]*points.y[i]);
//This example is too close to the original really..

This is undoubtedly slightly harder to read, but the performance gains can be absolutely massive.

But in general optimized code isn't that much harder to read. Hard to read code might get excused for poor reasons but performance is very often not a reason.
Ignoring certain cases.

Bit fiddling is something you should get comfortable with though, since it's very useful even if you're not writing code that will ever run.
>>
Daily reminder
https://better-dpt-roll.github.io/

Hard mode: No rerolls allowed
>>
>>57637118
>can't even switch on anything more complex than some atomic type
>always has to break every
hahahahhaaahahhaa

also
>c
>readable
I bet you think >>57637071 is readable
and I know its c++, but they're basically the same

anyways, nice troll, made me reply
>>
>>57637160
Yeah 2bh
>>
File: 2016-11-22 14_23_06-.png (22KB, 523x298px) Image search: [Google]
2016-11-22 14_23_06-.png
22KB, 523x298px
>>57637175
0/10
Absolutely no reason to be making cross-site calls.
>>
>>57637102
>I bet you think
>switches are more radable than haskell cases


>do operation
>based on result go to these
>if none of them go here

vs

>that shit you wrote

Why are we re-specifying the operation? That looks more like an if-else than a switch case.

p.s. I don't know haskell.
>>
>>57637174
>This is undoubtedly slightly harder to read, but the performance gains can be absolutely massive.
Not who you're replying to but can you explain?
If you're accessing the x and y of the same point, wouldn't the AoS be better due to cache locality?
>>
>>57637206
>p.s. I don't know haskell
opinion discarded
you're a fat man selling a diet book
>>
>>57637143
fizzbuzz n = case (mod n 5, mod n 3) of

> The function 'fizzbuzz', which takes 'n' as a parameter, has, depending on the modulus of the parameter against 5 and the parameter against 3, outputs...
(0, 0) -> "fizzbuzz"

If the modulus of the parameter against 5 is 0 and the modulus of the parameter against 3 is 0, ... outputs the string "fizzbuzz"
(0, _) -> "buzz"

Or if the modulus of the parameter against 5 is 0 (and the modulus of the parameter against 3 is something not 0), ... outputs the string "buzz"
(_, 0) -> "fizz"

Or if the modulus of the parameter against 3 is 0 (and the modulus of the parameter against 5 is something not 0), ... outputs the string "fizz"
_ -> show n

Or if any of the above cases do not occur, just show the number itself.

Readable as fuck.
>>
>>57637206
I don't like that guy and he's probably a faggot since he actually used "kys", but I think the haskell versions are more readable

Haskell patterns can have guards, that are boolean conditions
That's what is being done in the original post >>57637013

"otherwise" is literally just a synonym for True
>>
>>57637207
Assuming we're reading more than one cacheline we're wasting cache in the AoS version because we're pulling in the Z when we're only using the X and the Y.

In this case we're wasting a lot. Where in the SoA we'd get 100% assuming the entire array fits evenly in the cachelines (the elements are aligned and the last cacheline isn't partially wasted because they end up matching, not that that matters for real).

It's a very arbitrary example though.

SoA vs AoS should be something you can just tell the compiler/language though. There's no reason we have to write our access differently other than maybe so you're aware.
>>
>>57637290
he's a troll, why'd you spend energy on him
>>
>>57637290
>more readable than
for( int i =0 ; i<100 ; i++)
{
if( i%15 == 0 ) printf("Fizzbuzz");
else if( i%3 == 0 ) printf("Fizz");
else if( i%5 == 0 ) printf("Buzz");
else printf("%d",i);
}

At least this is in somewhat English. Your code is only just a bunch of arrows and shit
>>
>>57637191
C++ has the most readable FizzBuzz.

 
std::string string;
for(int i=1; i<100; ++i)
{
if(i%3==0)string+="Fizz";
if(i%5==0)string+="Buzz";
string.empty() ? std::cout << i << "\n" : std::cout << string << "\n";
string.clear();
}
>>
>>57637352
>>57637353
For people brought up on imperative/stateful languages, perhaps.

For actual elegance and simplicity, nope.
>>
>>57637206
>>57637306

So you can think of

fun | cond1 = out1
| cond2 = out2
| cond3 = out3
| cond4 = out4


as being

fun = 
cond1 ? out1 :
cond2 ? out2 :
cond3 ? out3 :
out4


Because when you only about boolean expressions, it's basically like a load of if elses as you said, there is actually a Haskell extension called MultiWayIf that enables a similar if | syntax
>>
>elegance
watch this
class FizzBuzz{constructor(a,b,c){this.d=++a;this.e=+ b;this.f=c}};FizzBuzz.prototype.fizzbuzz=function(){console.log(Array.apply(null,new Array(this.d)).map((i,n)=>{let c='';this.f.forEach((a,b)=>{switch(this.e){case 1:/b/.test(n)&&(c+=a);default:(n%b)?c:c+=a;break}});return(c)?c:n}).slice(1).join('\n'))}
var FizzBuzzer=new FizzBuzz(100,false,new Map([[3,'Fizz'],[5,'Buzz'],[7,'Woof']]))
FizzBuzzer.fizzbuzz()
>>
>>57637353
>hurr durr I've used this language for years
>which means I know the ins and outs and i'm used to this c++ way
>here, let me write this version which I deem readable because I understand it, since i've been using this language for years
>never mind other solutions like >>57637034, which seems concise and short
>but since I don't know the language or its syntax, its unreadable
>my version is more readable
>duurrrrrr
>>
>>57637382
>elegance
What does this mean?
>simplicity
A switch case solution in any language with few symbols is probably the most simple. C/C++ would be pretty OK.
>>
>>57636725
>>57636755
Not an acronym.
>>
>tfw you realize you've been discussing fizzbuzz with /dpt/ for over two years now
I feel dumb.
I shouldn't get involved.
>>
Using json to set up an item menu in my gaem, and using another json file to store data about items and shit. It's boring but not like I have much else going on in my life I guess
>>
>>57637306
"kys" is a short way of meaning something
as a haskeller, I take offense in people doing things the long way, when the short way is much easier to express, and still makes sense, and isn't obsfucated
>>
>>57637450
I don't care gandpa. It doesn't matter to anyone now.
>>
>>57637455
kek
>>
>>57637473
"kys" is literally only used by faggots
stop using haskell, it's too good for you
>>
>>57637489
just because its used by faggots, doesn't mean its not a good way to express sentiments

just in the same way that just because an apple has a worm, it doesn't mean that the worm is in principle, part of the apple
>>
>>57635912

I want to make a c++ plugin for gimp that lets you edit a height map while rendering it in openGL

would I be able to just import GLFW, OpenGL, and GLM inside of a Gimp plugin and make an new openGL context window?
>>
>>57637353
>C++ has the most readable FizzBuzz.
>what is python
for i in range(1, 100):
s = ''
if not i % 3: s += 'Fizz'
if not i % 5: s += 'Buzz'
if s: print(s)
else: print(i)
>>
>>57637522

Almost assuredly not.
>>
>>57637517
>Just because its used by faggots, doesn't mean its not a good way to express sentiments
You can tell the people who use it are faggots BECAUSE it's not a good way to express sentiments
>>
Do people actually post non third grade tier stuff in this general?
>>
>>57637522
Probably (if you deal with initialization and shutdown yourself).
Try it.

Worst case you would have to fork the process.
>>
>>57637353
Here is the equivalent Haskell

fizzBuzz n = evalState $ do
when (n % 3 == 0) $ log "Fizz"
when (n % 5 == 0) $ log "Buzz"
whenM (null <$> get) $ log (show n)

where log s = modify (++ s)
whenM mb a = mb >>= (`when` a)

main = mapM_ (putStrLn.fizzBuzz) [1..100]
>>
>>57637531
Or even more better
for i in range(1, 100):
s = ''
if not i % 3: s += 'Fizz'
if not i % 5: s += 'Buzz'
print(s if s else i)
>>
>>57637542
how else would you express disdain in a three letter manner?
>>
>>57637409
>being this buttmad no one uses your stupid obtuse language
>>
>>57637554
It happens
>>
>>57637571
(You)
>>
>>57637576
please walk me through the parts of the post which expressed "buttmad"
>>
>>57637554
(You) first, anon
>>
The last time I write a fizzbuzz was months ago. Please be gentle /dpt/.
#include <iostream>

class FizzBuzzMachine {

public:
FizzBuzzMachine ();

int &n ();

void step ();

private:
int _n;

};

inline FizzBuzzMachine::FizzBuzzMachine () : _n () {}

// inline const int &FizzBuzzMachine::n () const {
// return this->_n;
// }

inline int &FizzBuzzMachine::n () {
return this->_n;
}

void FizzBuzzMachine::step () {
if (this->_n % 15 == 0) {
std::cout << this->_n;
} else if (this->_n % 5 == 0) {
std::cout << "buzz";
} else if (this->_n % 15 == 0) {
std::cout << "fizz";
} else {
std::cout << this->_n;
}
std::cout << std::endl;
this->_n++;
}

int main (void) {
FizzBuzzMachine machine;
machine.n () = 1;
for (int i (0); i < 100; i++) {
machine.step ();
}
return 0;
}
>>
>>57637353
Will that even compile if you're using string as an identifier?
>>
>>57637567
whoops

should be

flip evalState ""
or
(`evalState` "")

That's setting the initial state to ""
>>
>>57637585
5 chars, but if it doesn't make me sound like a faggot...
>>
>>57637570
Even better
for i in range(1, 100):
s = ''
if not i % 3: s += 'Fizz'
if not i % 5: s += 'Buzz'
print(s or i)
>>
>>57637603
Ok it works, my bad.
>>
>>57637382
>elegence
>simplicity
>haskell
Well now I've heard everything.

Go back to drawing arrows all over the place. Leave the real coding to the experts
>>
>>57637603
Not him, but I would assume so. It's not std::string.
>>
>>57637628
Apparently it works even if you're using namespace std and use string instead of std::string.
>>
>>57637567
this is too imperative
pls reconsider your usage of haskell in this manner
>>
>>57637625
this is the same faggot who writes 1000LOC in C++ for something that can be abstracted in haskell to only 100LOC
>>
>>57637642
Oh I guess because types and variables are seperated in C++
>>
>>57636876
Help me friends
>>
>>57637654
I don't care how many lines of code there are. If your code is just a bunch of arrows, then it's unreadable garbage
>>
>>57637654
Cool. What kind of platform are you developing for that has to compile and run the code?

That's the only reason LOC would matter.
>>
>>57637667
geniuine advice
If you have any choice at all, don't learn java.
>>
>>57636876
just learn spring
>>
>>57637657
You're right. The declaration
string int;
also works.
>>
>>57637678
> If your code is just a bunch of semicolons and nipple braces, then it's unreadable garbage
>>
>>57637667
Learn as little as possible about java, waste of time.

It's just another OOP GUI framework. So just learn Spring.
>>
File: spain-fs8.png (582B, 402x402px) Image search: [Google]
spain-fs8.png
582B, 402x402px
post your programming environment
>>
>>57637478
It does a better job than pretty much every other language in terms of performance and efficiency to write and read, sans C. But it still is easier to write and read than C.
>>
>>57637678
>durr I hate notations
I bet you hate integrals and sigma notation
codemonkey galore
>>
>>57637706
>582 B
>>
>>57637678
These are all in the Haskell standard library.

>>=
>=>
<=<
=<<
*>
->
$>
=>
>>
<<
<*

Ask me about one and I can tell you

-- not in but should be
=>>
=>=
>>
>>57637706
>low fidelity color coded IDE
Cool anon. I'm happy you found a solution despite being legally blind (I'm assuming).

How do you debug?
>>
>>57637706
My retard free room where I can program silently.
>>
>>57637706
Bane?
>>
>>57637722
he hates unreadable notation like >>57637729
i mean those are ridiculous
>>
>>57637725
what about it?
can you do better without lose colors?
>>57637736
what you talking about?
>>
>>57637729
>"<=<"
What does fish mean?
>>
(map #(["FizzBuzz" %1 %1 "Fizz" %1 "Buzz" "Fizz" %1] %2) (range 1 101) (cycle [1 2 3 4 5 6 7 7 6 5 4 3 2 1 0]))
>>
>>57637695
>>57637722
>>57637729
>haskell kiddies who never programmed anything more than fizzbuzz think this is readable
>>
using System;

class Program
{
static void Main()
{
for (int i = 1; i <= 100; i++)
{
if (i % 3 == 0 && i % 5 == 0)
{
Console.WriteLine("FizzBuzz");
}
else if (i % 3 == 0)
{
Console.WriteLine("Fizz");
}
else if (i % 5 == 0)
{
Console.WriteLine("Buzz");
}
else
{
Console.WriteLine(i);
}
}
}
}


Why not just do it the pleb way? I literally find it more readable than a lot of the solutions here.
>>
>>57637783
>== 0
>>
>>57637767
Reverse kleisi composition.
Composes two monadic functions (b -> m c) and (a -> m b) into a function (a -> m c)

e.g.

f = print <=< replicateM 3
main = f getLine
>>
File: xkcd.png (44KB, 740x633px) Image search: [Google]
xkcd.png
44KB, 740x633px
>>57635912
>xkcd in the OP
>>
>>57637755
They're just symbols, like in every other programming language in existence.

C has '%'; does it mean 'percentage'? No.
C has '&'; does it mean 'and'? No.
C has '*'; does it mean 'there is a footnote at the bottom of the page'? No.
> ahh the horror
>>
this is a valid haskel program

 1337<=< 1337
:^) >> 666 << (^:
*><* >>
>>
=>=
return
>>
>>57637687
I have no choice, employer says I have to

>>57637703
So I don't need to become an indepth java expert to be an expert in spring? Ok thanks, I'll just buy the latest Spring into Action book and read that
>>
>>57637791
"Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”."

Just the fist google result I got.
>>
File: Tux.png (50KB, 626x313px) Image search: [Google]
Tux.png
50KB, 626x313px
>>57637706
Best one out there.
>>
I'm writing a quick formatting language for text files.

For example, my program transforms this :
:FB. TODO LIST

:U. Introduction (No Symbol)
:UI. Part 1 (I Symbol)

:B. A check list
:C. This
:C. is
:C. a check list

:A. Some blabla with margin

Anyway, take care.

:FB. PS: Anon


to this :
+------------------------------------------------------------------------------+
| TODO LIST |
+------------------------------------------------------------------------------+

Introduction (No Symbol)
~~~~~~~~~~~~~~~~~~~~~~~~
I. Part 1 (I Symbol)
~~~~~~~~~~~~~~~~~~~~

+--------------+
| A check list |
+--------------+
* This
* is
* a check list

Some blabla with margin
Anyway, take care.

+------------------------------------------------------------------------------+
| PS: Anon |
+------------------------------------------------------------------------------+


Pretty useless, but fun.
>>
>>57637808
yes but C tries to not have 6 million of those
>>
>>57637791
>Using '!' on a non boolean
Please leave your bad practices at the door, thanks.
>>
>>57637813
>java expert
You don't have to be a Java expert to write any user facing code.
So yes, just learn Spring.
I'm not sure what the best way to learn is. Maybe books are fine if you trust the author.
>>
fizzbuzz = [putStrLn x | x <- f [1..100]]
where
f [] = []
f (x:xs) | x `mod` 15 == 0 = ["FizzBuzz"] ++ f xs
| x `mod` 5 == 0 = ["Buzz"] ++ f xs
| x `mod` 3 == 0 = ["Fizz"] ++ f xs
| otherwise = [(show x)] ++ f xs

am i hired?
>>
>>57637815
the point was that, == 0 is the same as !
>>
>>57637791
it's not good form to use 0 as a boolean value. what if you switch to a language that doesn't have 0 as true?
>>
>>57637837
>returns [()]
imagine if in C++ you could return std::vector<void>
>>
>>57637837
ofc your not highered

wtf is even the thing you wrote
>>
>>57637858
it tells if a number is even or odd
>>
>>57637849
>>57637858
b-but it werks
>>
File: sample-input.png (43KB, 420x255px) Image search: [Google]
sample-input.png
43KB, 420x255px
>>57637817
Reminds me of *roff.
https://en.wikipedia.org/wiki/Troff
>>
>>57637755
>don't you guys just hate those unreadable notations
>now, if you excuse me, let me decode this nice little readable snippets
>char (*foo)[]
>int (* duck[3]) (int)
>i = 0x5f3759df - ( i >> 1 );

(you)
>>
>>57637837
>writes haskell
>am i hired?
By definition you're not.
>>
>>57637876
>char (*foo)[]
That's easy to read.
>int (* duck[3]) (int)
I agree that's dumb.
>i = 0x5f3759df - ( i >> 1 );
I don't even see how you can complain about this.
Is the assignment tripping you up?
>>
>>57637837
nope.
you didn't compartmentalize the io and pure
what if I want to do something with the pure and do my own IO?
your IO is intertwined with the pure, and this company doesn't tolerate that
>>
>>57637898
>this code violates our company purity policy
t. hitler
>>
>>57637837
even more, you repeated yourself too much
haskell is about abstracting repetitions away
> ++ f xs
>4 times
>>
>>57637912
>hitler
I suggest you read a history book.

Hitler was very fond of haskell
>>
>>57637866
Didn't know this thing. Thx
>>
>>57637837
shouldn't it be

fizzbuzz = [putStrLn $ f x | x <- [1..100]]
where
f | x `mod` 15 == 0 = ["fizzbuzz"]
| etc
>>
>>57637912
hitler was a visionary and wanted the best for his people
the jews and the globalists didn't like unity because it threatened their power
I suggest you read a book and stop spewing what you've been fed in the public school
>>
>>57637929
Were concentration camps some sort of proto-monad?
>>
>>57637897
my point is that every language has it syntax and semantics
and you can't attribute "hard" semantics to just haskell
so stop bashing on it
>>
>>57637970
Yes but there's varying degrees of hard.
Haskell has a lot of stuff.
>>
File: this_didnt_happen.jpg (12KB, 292x173px) Image search: [Google]
this_didnt_happen.jpg
12KB, 292x173px
>>57637946
not unless proto-monads are a hoax
>>
>>57637990
NSFW
>>
>>57637985
Only because you haven't learned it.
Perl looks like crazy gibberish to somebody who doesnt understand it, but it makes perfect sense to somebody who does.

Are you the same kind of tard who says Emacs is hard to use because you have to learn a few unorthodox commands?
>waaah I have to hit ctrl+x s to save! why isnt it just ctrl+s! waaah!
>>
>>57637933
Why is "fizzbuzz" wrapped in a list?

Also, why not separate the list-generation and the printing i.e,
fizzbuzz = [f x | x <- [1..100]]
where
f | x `mod` 15 == 0 = "fizzbuzz"
| etc

main = putStrLn . unlines $ fizzbuzz
>>
>>57637985
haskell's not that bad
stuff like crazy operators and standard library functions is basically just familiarity
>>
>>57638014
>Only because you haven't learned it.
No it has a lot of stuff regardless of if i know that stuff or not. This is a more interesting assement >>57638033
because it points out that not all of it is required to read haskell code.
>>
>>57638021
sorry yeah the shittiness of his code confused me. i didn't expect so much would need changing so just changed the part i thought was off
>>
>>57637791
>>57637839
! is evaluated before % so you'd have to write
if(!(i%3))
so you might as well just use ==0;
>>
File: 1479552443257.jpg (52KB, 1024x768px) Image search: [Google]
1479552443257.jpg
52KB, 1024x768px
Why is it so goddamn hard to train an XOR deep neural network? I can get it to train an AND or OR network just fine, but I can't for the life of me get XOR to work.
>>
>>57637531
>if not i%3
i%3 is an operation, not a true or false statement. It performs arithmetic, why would it "not be" or "be"? You mean to say "if the return value of the modulo function where i and three are its parameters returns zero." Then it's readable.
>>
>>57638044
i think pattern matching, being that it's not common in imperative languages (and is recent in those that do have it), might be unintuitive at first but could be learned
>>
>>57638064
xor needs more neurons than and/or

u sure you have the right setup
>>
I took a programming course in C (data structures) once and the TA tried to fail me a few times because he didn't understand why I was writing !ptr instead of ptr == NULL.
>>
>>57638064
http://www.bogotobogo.com/python/python_Neural_Networks_Backpropagation_for_XOR_using_one_hidden_layer.php
>>
>>57638073
`if i%3 == 0` is perfectly valid python as well if you consider it more readable
>>
>>57638091
I'm running 2 wide, 5 deep, not counting bias neurons
>>
>>57638102
>why I was writing !ptr instead of ptr == NULL.
Why were you writing that?
>>
>>57638102
NULL is not necessarily 0 so it doesnt necessarily mean it's false?

htough i wouldnt see hed go as far as to fail you
>>
>>57638102
because
NULL == ((void*)0)

and not
NULL == 0
>>
>>57638133
those are literally the same thing.
>>
>>57638133
This is not true. There's no such guarantee.
>>
>>57638088
standard pattern matching is easy
however, reverse pattern matching is hard
>>
>>57638142
>>57638147
you're right, my bad
>>
>>57638150
>reverse pattern matching
you mean like copatterns/cocase?
>>
>>57638161
Well we're not both right.

There's a difference. Not in compiled code but type mismatching warnings trigger in one case and not the other.

But there are environments where NULL is just a 0 define.
>>
what are monads?
>>
File: 11.png (27KB, 608x422px) Image search: [Google]
11.png
27KB, 608x422px
>>57638190
on my PC, they're both true
>>
>>57638204
some misappropriated category theory concept that was shoehorned into haskell because otherwise they wouldn't be able to write files, print to the screen or do any useful work on a computer.
>>
>>57638204
in Haskell

a datatype and implementations for the functions >>= and return
>>
>>57638179
its when you do stuff like
Just x = lookup "something" table
>>
>>57638221
What colorscheme is that?
>>
>>57638221
Yeah but he's not saying both statements are true or both are false or anything. He's writing code where he shouldn't. He's saying that NULL is (presumably always) defined to be a ((void*)0). And not a integer 0.

But that's not true.
For what you're writing it doesn't matter.

But !ptr isn't perfect because some platforms allow addressing to 0. Also we haven't defined if it's C++ or C. For instance
int* x=NULL;

is legal C but it'd be illegal C++.

There's tons of small things like that that doesn't matter whatsoever until it confuses you.

Regardless this is all very picky stuff.
>>
>>57638281
https://packagecontrol.io/packages/1337%20Color%20Scheme
>>
>>57638316
>is legal C but it'd be illegal C++.
Assuming NULL is (void*)0 to be clear.
>>
>>57638316
>int* x=NULL;
>is legal C but it'd be illegal C++.
Why is it illegal in C++?
>>
>>57638276
oh you mean something like logical programming where the compiler works it out?
>>
>>57638342
C allows implicit casting from void pointers, C++ doesn't.
>>
>>57638329
god bless you anon
>>
File: IncredibleEncryptionenrypted.png (858KB, 512x512px) Image search: [Google]
IncredibleEncryptionenrypted.png
858KB, 512x512px
can you decode this picture
>>
>>57638433
it says ">>57638433 is a faggot"
>>
Java's I/O is confusing me. Why are there so many I/O classes for reading and writing? What are the differences between them all? Stuff like PrintWriter, FileWriter, FileInputStream, BufferedReader, FileReader, FileOutputStream.
How do you know which one you should use?
>>
>>57638433

Note: posting pictures that are actually data is a bannable offense under rule 17, despite that being a stupid rule.

Just so you know.
>>
>>57638459
Yes, Javo I/O is fucking ridiculous.
Just use whatever works.
>>
File: IncredibleEncryptiondecrypted.png (661KB, 512x512px) Image search: [Google]
IncredibleEncryptiondecrypted.png
661KB, 512x512px
>>57638444
no it's this
>>
>>57638459
It's 21 years of encapsulation obsessions and legacy code.
Pick literally any of them and it'll do the job.
>>
>>57638526
its impossible to know what the original picture was, retard
>>
>>57638344
It's done at execution time.
showAge :: String -> IO ()
showAge name
| Just age <- someLookupFunction name = putStrLn $ name ++ " is " ++ (show age) ++ " years old"
| otherwise = putStrLn "Holy shit learn to spell, asshole"
>>
File: file.png (1KB, 447x26px) Image search: [Google]
file.png
1KB, 447x26px
>>57638526

Is it literally just all the pixels shuffled, or is there some rhyme & reason to it? I figured it was data-as-colors, but running file on the result got me nothing interesting, as you might expect.
>>
I'm trying to learn Vulkan. Why are all the hello triangle examples almost 1000 lines long?
>>
>>57635945
I was just thinking about this today.
What if you cast the int to a double, divide it by 2 cast it back to a int, double it and check if it's the same as n. Would that work?
>>
>>57638588
... this is just regular pattern matching
>>
>>57636149
Why not just
bool iseven(int n)
{
return (n&1) ^ 1;
}

? It avoids branch prediciton miss as well, since there's no branches, and it uses less data for the functions
>>
>>57638599
Because you do a lot of setup for things Opengl did for you.
Command buffers notably
>>
>>57638588
wait, you can have <- and = on the same line?
>>
>>57638588
can you explain that first guard
>>
Are there any non-deprecated two-way hashing algorithms in MySQL?

I'm not storing anything life important like passwords, just trying to throw off nosy average-joes from figuring out how a code is generated so they won't be able to replicate a valid one.
>>
>>57638707
it just lets you pattern match on something that isn't a parameter
>>
>>57638697
>>57638707
https://wiki.haskell.org/Pattern_guard
>>
>>57638726
yeah, I forgot = is what you want the guard to return
>>
>>57636956
>>57637174
*look simpler
Functions don't make it run faster, that's plain stupid. that was a typo
>>
Anyone here use Azure? I'm trying to run an Runbook but the "Start" button is greyed out. Any ideas?

I'm thinking permissions issue (enterprise subscription) but i'm not sure.
>>
>>57638883
publish the runbook first, then you can start it.
>>
C# -> C
or
C -> C#
>>
>>57638904
C -> More C
>>
>>57638897
FUCK.

thanks
>>
>>57638915
That's a hidden option in every single one of them
>>
>>57638487
What's an example of good I/O? What's C#s like?
>>
File: random.png (8KB, 491x195px) Image search: [Google]
random.png
8KB, 491x195px
>>57638904
Haskell has nothing to say
>>
>>57638943
>example of good I/O
Nothing a standard library of a language does.
>>
>>57638954
nobody asked it though mate...
i need an answer form a human, not a niche programming language
>>57638904
anyone?
>>
>>57638433
this is literal child porn
>>
>>57638988
thank god nobody can decrypt it
>>
>>57638988

Fact: By generating every 512x512 image in existence, you will, invariably, generate a large amount of child pornography.

This CANNOT be allowed.
>>
>>57639029
even in 0 bit colour?
>>
Any beginners guide for embedded programming with C or asm ?
>>
File: S-1228080-www.kaifineart.com-4.jpg (189KB, 650x919px) Image search: [Google]
S-1228080-www.kaifineart.com-4.jpg
189KB, 650x919px
>>57639051
NEW THREAD
>>57639051
NEW THREAD
>>57639051
NEW THREAD
>>57639051
NEW THREAD
>>57639051
NEW THREAD
>>
>>57639029
and certain combinations of muscle contractions can send you to prison for life. really fucked up
>>
Dear /g/:
HOW DOES I CODE??!???

Thanks
>>
>>57639029
It's practically not feasible to generate that.
>>
>>57639263
K&R
Thread posts: 326
Thread images: 18


[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.