[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: 360
Thread images: 28

File: DPT.png (389KB, 934x1000px) Image search: [Google]
DPT.png
389KB, 934x1000px
Old thread: >>57034830

What are you working on /g/?
>>
File: 1466043564877.jpg (475KB, 852x973px) Image search: [Google]
1466043564877.jpg
475KB, 852x973px
1st for C
>>
File: hime c.png (1MB, 1280x720px) Image search: [Google]
hime c.png
1MB, 1280x720px
Second for cargo cult programming!
>>
3rd against OOP
>>
New to C, but need to write some library bindings. What's a good code style standard to slap into clang's formatter?
>>
In Java, how can I promt a loop to start again after user input? Making the high/low game, works fine, but I want to promt the user to play again or quit after playing the game once.

        while (guess !=number) {
/* Prompt user to guess the number */
System.out.print("Enter your guess:");

/* Read user guess */
guess = Scanner.nextInt();

/* Check if guess is high/low/correct */
if (guess<number) {
System.out.print("Too low, guess again" +"\n");
}
else if (guess>number) {
System.out.print("Too high, guess again" + "\n");
}
else {
System.out.print("Correct! The number was" + number);
}
}

So, after this loop is finished, I want to ask the user "Do you want to play again? Y/N". So if user input = Y, the loop starts again. If the user inputs N, I just do a print("Thanks for playing! Goodbye";
>>
>>57040541
do
{
game();
boolean playagain = doYouWantToPlayAgain();
} while(playagain);
Syso("kthxbai");
>>
>>57040512
kernel style
>>
I'm having troubles understanding nestled for loops in C. Like this one where it prints out a grid of dots.
int main()
{
char grid[10][10];
int i,j,row=10,col=10;

for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
grid[i][j] = '.';
printf("%c ", grid[i][j]);
}
printf("\n");
}

return 0;
}
The variables i and j always have the same value, so it's useless to declare both of them.
I could just have used only 'i' in the printf function The only reason I'm using the second one is to make the inner loop go 10 times, am I right?
>>
Would it be worth it to make a container class that's just with a vector of smart pointers without the smart pointer syntax?
>>
>>57040711
>am I right?
Maybe I did not understand what you wrote, but it seems to me that you got it wrong. The goal of nested loops here isn't to iterate 10 times over the same row, it is to iterate once over every cell.
>>
>>57040711
>The variables i and j always have the same value, so it's useless to declare both of them.
Incorrect.

It goes
i: 0, j: 0
i: 0, j: 1
i: 0, j: 2
...
i: 1, j: 0
i: 1, j: 1
i: 1, j: 2

Also please don't use j as a variable name. It looks too much like i. Don't use l either.
>>
File: gridok.png (6KB, 516x452px) Image search: [Google]
gridok.png
6KB, 516x452px
>>57040232
Thanks

>>57040505
This might work.

Currently im calculating the final transformation matrix from multiple other transformations, and apply that to my point set to rotate.
I have to break up the transformation to the steps you linked in, in order to work. Not sure if theres a pretty way to do that, but ill go with the way that works but is ugly.
>>
>>57040771
>Also please don't use j as a variable name. It looks too much like i. Don't use l either.

This, also I' pretty sure you can declare the them in the for statement.

 
for(int row=0; row<10; ++row)
{
for(int col=0; col<10; ++col)
{
grid[row][col];
}
}
>>
How do i stop c++ code from compiling if RTTI has been disabled?
Is there a #define or something for that?
>>
>>57040999
witnessed.

If you use in your code a typeid expression or a dynamic_cast, your compiler will throw an error.
>>
>>57040829
>This, also I' pretty sure you can declare the them in the for statement.
you can't in C.
>>
>>57041011
So dynamic_cast won't even compile if RTTI is disabled?
>>
I think I blew my job interview today /dpt/

I passed all the problems with flying colours (one was a fizzbuzz lol) but I ran into friction when we were talking about paradigms

long story short I said something like "I don't understand why anybody still uses OOP. It's a guaranteed recipe for failure" and the interview ended shortly after that

maybe I'm overthinking it and it's just a coincidence. what do you think my chances of being hired are?
>>
>>57041039
>bringing /g/ memes to an interview
Have you not learned anything anon?
Also i hope you don't actually thing that about OOP.
>>
>>57041037
http://stackoverflow.com/questions/7687041/dynamic-cast-with-rtti-disabled
>>
>>57041046
>i hope you don't actually thing that about OOP.
I do
I'm not a pajeet
>>
>>57041039
vast majority of business uses exclusively OOP.
>>
>>57041039
Saying something like that in 2016 to a potential employer is kind of stupid.
>>
Uh, you absolutely can.
>>
>>57041039
Don't sweat it. That job probably wasn't worth it if the people there are stuck up about such trifles.
>>
>>57041039
Did you at the very fucking least research that company's tech stack ahead of time and make damn sure they aren't using any OOP? Otherwords what an awkward thing to say. "Yeah actually I hate java it's the worst programming language ever." "Uhm sir if we employ you you would be working with java..."
>>
>>57041039
>"I don't understand why anybody still uses OOP."
Look up why business use OOP.

The company almost certainly uses OOP for everything, because almost every business does. Saying edgy shit like that will not get you hired.

Certainly OOP is shit, but don't shit where you eat as they say.
>>
File: 1437788038563.png (116KB, 1515x663px) Image search: [Google]
1437788038563.png
116KB, 1515x663px
Started c++ and asm in uni, we're using intel syntax, which (maybe) just werks in VS, it seems g++ uses AT&T syntax, so I read I can use this way to use intel syntax with it. I'm not really sure what i'm doing, but this doesn't compile with

"Error: operand type mismatch for push"
and the same with pop.

#include <iostream>

int main(int, char**)
{
int a = 10;
__asm (
".intel_syntax noprefix\n"
"push eax\n"
"mov eax, dword ptr[a]\n"
"add eax, 5\n"
"mov dword ptr[a], eax\n"
"pop eax\n"
".att_syntax\n"
);
}


Is this the right way to do intel syntax in g++? Am I doing something stupid? Should I just say fuck it and boot up a VM with VS in?

Thanks lads
>>
>>57041039
>>57041058
You're not gonna make it.
>>
>>57041205
Read the manual.
>>
File: IMG_20161012_055208169.jpg (3MB, 4160x2340px) Image search: [Google]
IMG_20161012_055208169.jpg
3MB, 4160x2340px
This maybe?
>>
>>57041267
>the manual
intel manual?
g++ manual?
whatever compiler g++ calls for asm manual?
uni course manual?
>>
>>57041290
Maybe linux is not for you.
>>
>>57041307
Mate i've been using linux for the past 2 years just fine. I asked a simple question as I've never done assembly before and the course seems windows focused, now you just act like a dick instead of answering the question or not answering, fuck off
>>
>>57041325
>Mate i've been using linux for the past 2 years just fine.
That would be impressive if I didn't know that Tom Hanks managed to survive on an isolated island without knowing how to make fire.
>>
Just looking for opinions on this briefly.

I'm writing this macro thing for a client that needs to run in Excel. I really haven't used any advanced methods in VB/A, but I'm thinking I might want to try a recursive search for this.

VB supports recursive calls and stuff, right? Without becoming even more cancerous?
>>
>>57041390
Jesus christ, are you the same anon that's always asking about VBA?

Have you stopped and considered that their problem could be solved in another way?
>>
>>57041205
well... firstly... it should be
int main(int argc, char** argv)


I know very little about Assembly. Only briefly touched on it using MIPS x64 for a Comp Architecture class, but I know that C code is wrong...
Try fixing that first.
>IDK if it was a typo, but I hope so, because I don't even know of languages that allow you to name a type without a variable name...
>>
>>57041423
Yeah, coming from C that's what I did too, idk why the fuck it works but I guess you are meant to do that if you don't actually use the parameters, that's just what my lecturers code had in, maybe he's retarded, maybe not.
>>
>>57041423
>well... firstly... it should be
no
>>
>>57041423
>that C code is wrong
You're not even wrong.
>>
>>57041418
I'm not always asking about VBA. I've asked a couple times before.

This is an extremely informal project, and I haven't even spent 15 combined hours on it yet (for the program). My client is fully aware I go to college full-time, and she hasn't really seemed to have any issues with my timeframe, since she had much slower and more difficult to get in touch with people before.

I at least keep her updated and get things done when I'm not cramming 3 weeks of homework done over a weekend...

I already mostly solved the RegExing merger, for the most part. Just gonna need to clean it up a bit at the end.

I was just wondering if this thing can use recursive functions without raping the machines.

The thing will need to search ~10-15K records and scan matches for ID across 3 tables, which might ultimately cost ~6M times if I ran it linearly.
>>
File: 1471397567615.jpg (19KB, 343x354px) Image search: [Google]
1471397567615.jpg
19KB, 343x354px
How are you supposed to deal with local decryption without leaking your decryption method and/or keys?

For instance if I wanted to just distribute a blob of data without someone knowing what's inside it? For reference I was wondering how people manage to keep something a secret in video game file formats and maybe other real world practical things.
>>
>>57041475
if the data is meant to be usable by the end user/custommer then you don't because that would be just security through obscurity since the client would need a way to decrypt the data anyway
>>
>>57041443
eh, what are you talking about?

unless you're suggesting he use:
int main(void)?

>>57041436
Well, did you get it to compile after changing it?

Also, I just looked it back up again.
Your array has several strings but no commas.
>>
>>57041457
All I can say is test.

I'm not exactly sure what you're doing, but you'd be surprised what you can do with DAX. It's usually extremely computation-efficient, too.
>>
>>57041475
>keep something a secret in video game file formats
They don't.
If it can be decrypted by the end-user's machine, they can figure out how to do it, with or without your program.

If you change your demands to "I want only a SPECIFIC PERSON to decrypt it", then you can use something like PGP.
You encrypt using their PGP public key, and they are the only ones that can decrypt, because they have the private key.

Keep in mind that this is meaningless if a person that you don't want to decrypt the file has access to the key.
>>
Generate new invite link for Discord, please.
>>
>>57041495
Alright, I'll just give it a go and see if it doesn't fuck me in the ass with errors.

probably later, though
>>
>>57041490
>eh, what are you talking about?
i'm just saying that unnamed parameters are legal iirc
>>
>>57041475
>How are you supposed to deal with local decryption without leaking your decryption method and/or keys?
You can't. Video games just make up their own bullshit encryption format so that it at least takes someone a ton of time and effort to figure it out and make a decrypter. It doesn't stop anyone from actually doing it though. It's just a matter of making sure the juice isn't worth the squeeze. If you application is high profile enough (major MMO, photoshop, etc.) it'll get broken eventually though.
>>
>>57041516
shit, really?
I've never once been told to use unnamed parameters...

How do you access them, then?
>>
>>57041530
you don't, that's the point, if you don't need to use the parameter but have to keep the function signature then you can just omit the name so that the compiler doesn't tell you to fuck off when you build with -Wunused
>>
>>57041516
I literally never learned something new about C that made me like it more.

Everything I learn about C or C++ just seems like another potential way to fuck up your code, without providing functionality as a trade-off.
>>
>>57041487
>>57041503
>>57041517
Good to know, thanks. I figured it would be impossible, I had to deal with something like this before when dealing with API keys, I had to put a server between so the client made requests to my server which made authenticated requests to the actual remote server so that my credentials were not taken by users. I couldn't think of a way to keep the keys secure and local.
>>
>>57041537
oh....

heh.

Why might you need to keep the definition, while simultaneously not accessing the parameters?

Is there any kind of problem just leaving the params named and then not using them?
>>
>>57041475
>leaking your decryption method
That should be irrelevant for a secure cryptosystem.
https://en.wikipedia.org/wiki/Kerckhoffs%27s_principle


I'm not sure what you mean with the rest of your question.
If you want someone else to know what is the content of an encrypted data is you would have to give them access to the key.
>>
>>57041559
>Why might you need to keep the definition, while simultaneously not accessing the parameters?

well since we're talking about C++ (based on his headers) then yeah
say you have some sort of an UI widget class then individual widgets that inherit from it and some key callback that passes the key and the modifiers
now if it's just a button, you don't really care about the mods, so you omit the mods param from the input event, but for something like an input box, you'd want to know whether, say, shift was pressed to append an upper case letter
>>
You have abstract/virtual classes/interfaces
class Entity { ... }
class Damageable { ... }
class Tamable { ... }


You have concrete classes
class Player : Entity, Damageable { ... }
class Cow : Entity, Damageable, Tamable { ... }
class Item : Entity { ... }
class Minion : Entity, Tamable { ... }


You have somewhere a list of all Entities that are in the game
QuadTree<unique_ptr<Entity>> entities;


The question is, when you want to drop a nuke somewhere and find all entities that are Damageable, how do you do it?
Lets assume QuadTree has a method that returns an iterator over entities that are inside a circle.
for (Entity* e : entities.inCircle(0, 0, 100))  {
if (e ???is instanceof??? Damageable) ((Damageable*) e).dealDamage(9001);
}


Now obviously you can use dynamic_cast and RTTI to find out if e is instanceof Damageable, but that is considered bad design.
What other options are there?
>>
>>57041596
hmmm, I guess that makes sense.

But, he used unnamed parameters for main().
That's ALSO legal?
>>
>>57041629
yes, if you don't need to access the command line arguments then that's completely fine, long as the signature checks out (int, char **)
>>
>>57041617
You could use a template instead of a class for the Damageable and Tamable.

Or, you could include the field as a bool in the Entity class.
>>
File: BzmDP_yCEAAvXdx.png:large.png (703KB, 1024x768px) Image search: [Google]
BzmDP_yCEAAvXdx.png:large.png
703KB, 1024x768px
>>
Anyway of uploading apps directly to my iphone without Appstore? Jailbreak or something?

Also wondering if something like this is possible on Android.

Kinda want to make something for myself to use.
>>
>>57041636
Hmmm, that's very interesting.
>>
>>57041650
I think you need to root the device if it's Android. Depends, though. I know there's a setting on my Kindle, though, that allows me to install 3rd party apps
>>
>>57041666
you dont have to root, just allow 3rd party apps

i have no idea with iphone ive never owned one, surely there's some kind of app testing mode or w.e though
>>
>>57041642
A template how? Can you write a short example?

As for the field, that would mean every time you need to add a new abstract class, like Namable, Glowable, whatever, you need to modify the Entity class which seems like a bad idea because it breaks modularity. I'd say an EntityType enum (DAMAGEBLE, TAMABLE, GLOWABLE, ...) would be better and than you have unordered_set<EntityType> in every Entity and check via that. But that also seems like a bad idea because you need to construct unordered_set for every entity, and if you create loads of entities (like bullets) it will be slow.
>>
>>57041642
>Or, you could include the field as a bool in the Entity class.
Someone post the OOP screenshots with Pets and number of legs.
>>
>>57041650
you can side load with xcode
>>
>>57041617
Keep a list of Damageable entities.
>>
>>57041695
>>57041696
he asked for other options.

I didn't say that was a good one unless those were the only classes he needed at all.
>Which I just looked at what he listed, and that does not appear to be the case...

>>57041695
Regarding templates, I've only used a few Interfaces in Java for a couple things. I don't have any real experience with C++ templates.
Most of my programming at the moment is web, actually

Here's the wiki page though:
https://en.wikipedia.org/wiki/Template_%28C%2B%2B%29
>>
I am depressed and try to learn sicp with python in mind.
Foremost I want experience. How to think about coding until I am comfortable, then branch out.

Since the college uses java in majority of cs courses, what might be the best way to transfer there?
I have no idea, but am working out a plan that need the input
>>
>>57041751
What are language you speak from birth?

I undernot can stand you.
>>
>>57041705
I thought of that and its actually a pretty good idea. Something like
QuadTree<unique_ptr<Entity>> entities;
QuadTree<shared_ptr<Damageble>> damageables;
QuadTree<shared_ptr<Tamable>> tamables;


But it has a couple of drawbacks. First the obvious one, you need a structure for each abstract class which means insertion would be done via a templated add method and you would need to add the same entity to multiple structures. For deletion you would need to delete it from all structures. So add/delete would be a bit slower and you would require more memory for storage.
Another drawback is you can't really make smart bombs or spells or whatever which only deal damage to entities that are Damageable but not Tamable. You would need to check if the entitity exists in tamables, which for a tree is logn. Of course you could also have unordered_set which adds more structures just to make things faster.

>>57041740
I know what templates are and how to use them, i just don't know how they could be used to solve this problem.
>>
>>57041205
after a decent bit of googling I found two bits which work, not sure which is prefered. Also, the teachers code worked fine in VS, but in G++ I had to change push and pop eax, to rax.
Idk. I also seem to need to use global variables in g++ whereas in VS it was fine with local ones.

#include <iostream>

int a = 10;

int main(int, char**)
{
asm ("push rax");
asm ("mov eax, dword ptr[a]");
asm ("add eax, 5");
asm ("mov dword ptr[a], eax");
asm ("pop rax");

__asm (
"push rax\n"
"mov eax, dword ptr[a]\n"
"add eax, 5\n"
"mov dword ptr[a], eax\n"
"pop rax\n"
);

std::cout << a << std::endl;
}
>>
>>57041786
>after a decent bit of googling I found two bits which work, not sure which is prefered. Also, the teachers code worked fine in VS, but in G++ I had to change push and pop eax, to rax.
>Idk. I also seem to need to use global variables in g++ whereas in VS it was fine with local ones.

VSC++ has a notoriously shitty compiled. That's why everything is inconsistent all over the place. I'm surprised your teacher is making you usse windows at all, let alone VS. Assembly classes should be taught using GCC in the year of the lord 2016 desu senpai.
>>
uint32_t tag = *(uint32_t*)&"RIFF";
>>
>>57041806
I think he mainly encourages it probably because people are retarded and it's very easy to debug in. He seems OK with any dev environment as long as it has a decent debugger (t. vim user), but this ASM seems to be very non portable (Hah!). Will just give him an email I guess.

We're also learning c++ to be "low level", and that we should use c# unless we really need performance, with that preface I'm not sure why we're not just doing C, ah well.
>>
>>57041617
>>57041778
class Entity {
public virtual Damagable* as_damagable() {
return nullptr;
}
};

class Player : public Entity {
public override Damagable* as_damagable() {
return dynamic_cast(this);
}
};

>>
File: IMG_2060.jpg (2MB, 3000x2000px) Image search: [Google]
IMG_2060.jpg
2MB, 3000x2000px
>>57041288
here
>>
>>57041853
Forgot that Player also inherits from Damagable and you should use static_cast instead.
>>
>>57041778
oh, actually, it appears I was wrong.
I was confusing the term, because in Java there's a separate thing called an interface.

In C++, it appears you would have to make it a pure virtual class or use multiple inheritance.

See, in Java, you can make a class that IMPLEMENTS several "Interfaces", and interfaces don't store data usually, just functions.
That's where the whole "leggable" joke comes in.

So, class Person extends Entity implements Leggable, Damageable

I was under the wrong impression that that's what a template was in C++, since I've only ever read a small amount about those.

Try multiple inheritance or virtual classes, then
>>
 uint32_t samplesPerSecond; //a 'sample' is a waveform sample defined per channel 

Is this comment understandable?
>>
>>57041819
I hope you don't do this.
>>
>>57041906
Sorry. It's the best i could come up with.
>>
>>57041039
>"I don't understand why anybody still uses OOP. It's a guaranteed recipe for failure" and the interview ended shortly after that
It's not a coincidence. Someone who didn't know a lick of programming could have gotten the job over you because you are a mongoloid who didn't bother to look up interview interaction skills. A shining example of why you should filter or skip over all paradigm arguments on /dpt/.
>>
>>57041853
>>57041863
That.. is actually a very good idea. I don't like the fact that every time you add a new abstract class you need to add a virtual function to the Entity class, but it's better than messing with enums or relying on RTTI.

>>57041884
Yeah i've written loads of java code before. But even in java the question still applies since the instanceof operator is considered bad design.
You can think of Damagable, Leggable whatever as interfaces. And when you have a List<Entity> you can use instanceof to see if this entity is Damageable, but like i said, this is considered bad design.
>>
>>57041962
You should probably be using an ECS. Have an Entity class. Add components of types Damagable etc to the entity. Then just check if entity.hasComponent(IDamagable). There's no need to be messing around with virtual classes.
>>
>>57041962
>That.. is actually a very good idea.
Every time I'm faced with a design problem I listen to https://vimeo.com/66226198. Especially the part at 4:55.
>>
>>57041895
the fuck is a "waveform sample"?
you don't sample the shape of a signal, you sample the signal
>>
>>57041819
Aaaaaaand here goes another violation of the strict aliasing rule where
memcpy(&tag, "RIFF", sizeof(tag));

would have worked perfectly.

Moreover the "RIFF" literal is 5-byte long, not 4.
>>
File: snip.png (5KB, 407x68px) Image search: [Google]
snip.png
5KB, 407x68px
Hey, anyone here who can help me?
Pretty basic stuff I'm sure, but i have to create a function who can take a list of lists and make those into a single list, without using the 'List.concat' function.
I'm guessing I have to use List.collect, but I'm having trouble writing the actual code. Some guidence could help i think. Pic related, writing f sharp
>>
Language trivia time.

What language has all of the following features?
>Call by Name
>Dynamic scoping
>Exceptions
>Can choose to pass by reference or value
>Multiple return values
>Abritrary destructuring
>Everythings is just lambdas under the covers
>Dynamic typing
>Global variables only
>>
>>57042036
I think the point is to make it yourself, not to use existing functions, but

List.collect (fun x -> x)
or
List.collect id
>>
>>57042036
I don't know F#, but I assume haskell is somewhat similar, you would do it like so

main :: IO ()
main = print $ concat' [[1],[2,3],[5,6]]

concat' :: [[a]] -> [a]
concat' [] = []
concat' (x:xs) = x ++ concat' xs

concat2' :: [[a]] -> [a]
concat2' = foldr (++) []
>>
>>57042036
You could also

open List
fold append empty
>>
>>57041423
>well... firstly... it should be
>
int main(int argc, char** argv)

You don't need to broadcast the fact that you don't know C.
>>
>>57042016
Guess. But what's the advantage of doing it like that? Furthermore, how do i do this
if(*(char*)&"RIFF") //dostuff
?

>Moreover the "RIFF" literal is 5-byte long, not 4.
I know. Zero terminator is cast away with the pointer cast.

>>57042005
Aren't those the same thing? I'm not sampling to color or the taste or the smell of the signal, am i?
>>
>>57042118
if(*(char*)&"RIFF"==tag)

even
>>
auto x = * ((she*) new he())
>>
>>57042118
>>57042141
memcmp?
>>
>>57042148
reinterpret_cast is more appropriate in this case.
>>
>>57042152
Oh, thanks. That works.
As you can maybe tell, i'm not so used to the C parts of C++ standard lib.
I still don't see the advantage of doing that, though.
>>
>>57042065
>>57042065
Thanks a lot for some quick input. This did work out, although i thought what I had to write had to be longer. I am allowed to use some 'List.' functions to help make this code including 'collect'.
Can you try to explain me how and why this works? The part in the ()
>>
>>57042148
Looks like a memory leak.
>>
>>57042183
auto *it = reinterpret_cast<Boy*>(new Girl());
>>
File: bison_colgate.jpg (91KB, 428x450px) Image search: [Google]
bison_colgate.jpg
91KB, 428x450px
Rate my high/low game.

https://repl.it/DuKK
>>
>>57042213
[Person *p = new Girl();]
is more elegant.
>>
>>57042240
Bipedal b = new Girl();
>>
>>57042240
auto it = reinterpret_cast<std::unique_ptr<Boy>>(std::make_unique<Girl>());

Is more elegant.
>>
>>57042205
fun x -> x is the identity function, that returns its argument

collect (or >>=) takes its argument, and calls the function with every item in its second argument (giving back a list of lists), and then concatenates the result.
effectively
collect f xs = concat (map f xs)

the type of
fun x -> x
is
forall a. a -> a

if we require that it is
a -> List b
then it becomes
List a -> List a
which fits collect

since it returns its argument, the collect function simply ends up concatenating
collect f xs = concat (map f xs)
f = id
map id xs = xs


collect id xs = concat (map id xs) = concat xs


but you should look at >>57042080
>>
>>57042231
It's ok, but you call playGame() twice, so once the user has entered no to exit the game, they have to play it once more. Also, instead of checking for "Yes" and "yes", you can just convert the input to lower/uppercase and check for just "yes"
>>
>>57042231
No means no.
>>
>>57042293
Thanks, I'll work on it
>>
>>57042259
Just a mess of unnecessary code.
>>
>>57042231
Line 11
-        {System.out.print("Welcome to the High/Low game!" + "\n");}
+ {System.out.println("Welcome to the High/Low game!");}

Line 20
-            if (kb.nextLine().equals("yes") || kb.nextLine().equals("Yes"))
+ if (kb.nextLine().toLowerCase().equals("yes"))


Line 25
-        playGame();
-
-
+


Line 32
-        Random Random = new Random();

scanner = new Scanner(System.in);

/* Use RNG to pick a number between 0 & 100 */
- int number = Random.nextInt(100);
+ int number = new Random().nextInt(100);


Line 49
            if (guess<number) {
- System.out.print("Too low, guess again" +"\n");
+ System.out.println("Too low, guess again");
}
else if (guess>number) {
- System.out.print("Too high, guess again" + "\n");
+ System.out.println("Too high, guess again");
}
else {
- System.out.print("Correct! The number was " + number + "\n");
+ System.out.printn("Correct! The number was " + number);
}


Also, scanners don't need to be in those scopes.
>>
>>57042318
It's also present in many code bases unfortunately.
I don't think the compiler's smart enough to optimise it out.
>>
>>57042259
- auto it = reinterpret_cast<std::unique_ptr<Boy>>(std::make_unique<Girl>());
+ auto he = reinterpret_cast<std::unique_ptr<Boy>>(std::make_unique<Girl>());
>>
>>57042319
Thanks, appreciate it
>>
>>57042187
>I still don't see the advantage of doing that, though.
It's not that type punning (what you did) gives an advantage over using memcpy, but it's just not safe to do that in C. Unless you want to interpret anything as an array of bytes (from any type to char */unsigned char *), the strict aliasing rule tells that two pointers of unrelated types cannot alias, such as in your case a uint32_t * and a char * cannot both point to "RIFF".
The true advantage of this rule is that compilers can make assumptions and get rid of unnecessary copies when pointers of different types are involved, as long as the rule is observed. Otherwise, dereferencing a type-punned pointer is undefined behavior and can lead to unexpected results if such optimizations are activated (basically -O3).

So pretty please, when you are about to type-pun an area of memory in C, use memcpy/memcmp instead. It's correct, it's safer and you can activate -O3 optimizations without worrying.
>>
>>57042338
That'll be $264 payable in two weeks.
>>
>>57042187
You need to read section A.6.2 paragraph 4 of the undefined behavior of pointers.
>>
>>57042360
>The true advantage of this rule is that compilers can make assumptions and get rid of unnecessary copies when pointers of different types are involved, as long as the rule is observed.
I didn't know this. I don't quite see how an optimisation like that would work, or what the behavioural consequences might be, but i will change it to memcmp.

I'm glad i posted on /dpt/ today.
>>
>>57042274
Thanks, that is useful. I also think that i'm supposed to do it more like >>57042080, but i haven't really heard of haskell. It looks like pattern matching is going on, i will try to write it more like this
>>
>>57042336
- auto he
+ auto xe
>>
Pls rate, would this get me hired?

#include <stdio.h>
#include <stdbool.h>

int main(int whatever, char **fuck_you) {
for (int i = 1; i <= 100; i++) {
bool printed = false;

if (i % 3 == 0) {
printf("Fuck");
printed = true;
}

if (i % 5 == 0) {
printf("Butt");
printed = true;
}

if (!printed) {
printf("%d", i);
}

printf("\n");
}

return 0;
}
>>
File: 432.png (80KB, 500x421px) Image search: [Google]
432.png
80KB, 500x421px
My graphics card keeps making a buzzing noise.

I've heard you can't fix it either.
>>
>>57042454
>dpt
k
>>
>>57042454
you can try running it hard like with an uncapped game menu or furmark or something and you can also put glue on the capacitors and it might help

but just get a new graphics card faggot
>>
>>57042454
>>>/g/sqt/
>>
>>57042487
It's only a year old and it's a 980ti.
>>
>>57042444
not as straightforward as if/else

also
>i++
>not ++i
faggot
>>
File: ffs.png (441KB, 1048x587px) Image search: [Google]
ffs.png
441KB, 1048x587px
What animes, which may or may not be related to programming, are you watching, lads?
>>
>>57042513
if/else fucks you up when you're asked to change it to also print something when it's a multiple of 7
>>
>>57042512
idk maybe you could put foam in your case to dampen the sound or if it's bothering you too much sell it and get a pascal card
>>
>>57042513
>++i
full retard
>>
>>57042536
i++ should only be used when you use the initial value like foo[i++]
>>
>>57042425
>I don't quite see how an optimisation like that would work, or what the behavioural consequences might be
I read plenty of articles on the subjects, but on the subject of optimization, it gets really technical and my communication skills get really poor at this point. Some links if you're curious though:

http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html (especially the last part which talks about strict aliasing)
http://cellperformance.beyond3d.com/articles/2006/06/understanding-strict-aliasing.html (if you're not afraid by assembly)
>>
>>57042525
Rewatching Psycho Pass right now. Ready to donate my brain to the sibyl system.

Current season: Lesbians on ice and sangatsu.
>>
>>57042548
++i should never be used unless you need the resulting value.
>>
>>57042558
Thanks. I'll check those out.
>>
File: 1476277586959.png (133KB, 840x960px) Image search: [Google]
1476277586959.png
133KB, 840x960px
>>57042525
the burger election
>>
>>57042569
[citation needed]
>>
>>57042587
K&R, kiddo.
>>
>>57042575
I wish
>>
Why is Xorg allowed to switch the processor mode, read/write to IO ports, access PCI devices and other hardware, despite being a user space process?
Is this some linux-xorg specific hackery or can any userspace program gain access to such privileges?
>>
>>57042594
Not that guy, but can you explain?
Why it strictly *cannot* be used?
I don't see any reason other than a convention.
>>
>>57042799
Prefix ++ identifies you as a C++ programmer who never learned C. That alone settles the issue.
>>
>>57042816
postfix ++ identifies you as a newfag babby who barely knows how a for loop works
>>
>>57042525
- Mahou Tsukai no Yome
- Mahou Shoujo Ikusei Keikaku
- Yuri!!! on Ice
- WWW.Working!!
- Keijo
- Shuumatsu no Izetta
- Drifters
- Brave Witches
- Kiitarou Shounen no Youkai Enikki
>>
>>57042504
He didn't ask a question.
>>
>>57042816
lol, I use postfix, I'm used to it, and again, it's a more widely adopted covention.
I'm just curious why you think It should "never be used unless you need the resulting value"?
>>
>>57042722
Usually Xorg runs under root and integrates with the kernal via modules.
>>
>>57042836
>K&R are newfags
Good post.
>>
>>57042594
What page?
>>
Anyone got an updated challenge image? let's start a challenge.
>>
How does one learn to program (from 0) a website?

Most of what I've found are html/css tutorials, but from what I've seen, and for my intents and purposes, I'd have to learn mysql, php or asp (or both?), possibly javascript...

It looks so complex, and I don't even know where to start.
>>
File: 1476281753057-870117213.jpg (3MB, 5312x2988px) Image search: [Google]
1476281753057-870117213.jpg
3MB, 5312x2988px
Is this still relevant for assembly programming basics
>>
File: 1460752551846.png (138KB, 237x270px) Image search: [Google]
1460752551846.png
138KB, 237x270px
>>57043001
>website
not
a
program
>>
what does this syntax really mean?
I think I know but not 100%

(z is an int)

 if (z & (z-1) == 0)
return true;
>>
>>57043001
>>>/g/wdg/
>>
>>57043001
We can't help until you tell us what your "intents and purposes" are. You won't need mysql unless you have a database and you won't need php unless you have a server. Javascript is a very easy language to learn.
>>
>>57043032
bitwise and
basically checks if z-1th bit of z is set to 0
>>
>>57042985
Not that anon but I want to know so I'm looking. I bet it's in this section.
But there are situations where one or the other is specifically called for.
For instance, consider the function squeeze(s,c), which removes all occurrences of the character c
from the string s.
>>
>>57042985
Each which contains a for loop after the introduction of postfix ++ in chapter 2.8. Why do you have to ask? Don't you know K&R by heart?
>>
>>57043029
>A computer program is a collection of instructions that performs a specific task when executed by a computer.
>>
>>57043048
>>57043036
>>57043029
Thanks, I'll check that thread. Didn't know I shouldn't be using this one.
>>
this sentence is a program
>>
>>57043032
both z, and z - 1, must be equal to zero, for return true to be executed
>>
>>57042884
at the time of writing, they were newfags, and the book is learning material for newfags
>>
>>57043072
Ignore him, anon. You can post web dev questions here.

That thread he linked to is a dead thread, it's slow as fuck and you'd be waiting ages for a reply.
>>
>Heretic people all over the world have claimed that this inconsistency
>is ... well ... inconsistent, but all right-thinking people know that
>(a) K&R are _right_ and (b) K&R are right. Besides, functions are
>special anyway (you can't nest them in C).
>>
#define enz(x) do { int r; if ((r = (x))) { rv = r; goto cleanup; } } while (0)

#define enull(x) do { if (!(x)) goto cleanup; } while (0)
>>
>>57043127
>First C version 1972
>First K&R edition 1978
hmm
>>
>>57043078
but how is that possible? is it just faulty code?

that's what is confusing me.
>>
Learning automated testing of web pages using python.
>>
>>57043134
you can nest them in based gnu C
>>
Why is working with email outside of using SMTP to send stuff such a gigantic clusterfuck? I've never experienced something so awful in terms of writing automation.
>>
>>57043032
It means that z is a power of two or 0. Fucking retards itt don't know anything.
>>
>>57043078
not true
for z=4
4 & 3
that is
100 & 011 == 0
>>
File: 1451744468455.jpg (3MB, 3634x2569px) Image search: [Google]
1451744468455.jpg
3MB, 3634x2569px
Is UWP worth the time investment?

Or are corporate business apps going to stick with Windows 7 Enterprise shit for the next 10 years?
>>
>>57043076
Actually it could be, if you wrote a compiler/interpreter for it.
For example, 'this' declares variable in this case named 'sentence' and 'is' assings a value to it, in this case a string 'a program'
Sounds logical, 10/10 would write in.
>>
>>57043166
Enjoy your exploits.
>>
>>57043176
this confuses me, new to this syntax.
can you post some info on what the fuck this is really doing? turns numbers into binary and then compares by subtracting?
>>
>>57042558
>http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html
So i read this, and especially the last part, about Violating Type Rules. But i still don't understand.

>For example, this rule allows clang to optimize this function:
float *P;
void zero_array() {
int i;
for (i = 0; i < 10000; ++i)
P[i] = 0.0f;
}


int main() {
P = (float*)&P; // cast causes TBAA violation in zero_array.
zero_array();
}

I don't understand why this causes a problem.
>>
>>57040421
given that I want to acces a piece of hardware (lets say a keyboard for example, nothing too complicated) directly on my computer who is responsible for the acces of the device ? is it the kernel, ( the OS ?) or can I use low level languages such as C with pointers or something in that direction for example to acces the device ?
>>
>>57043231
>For example, this rule allows clang to optimize this function:
float *P;
void zero_array() {
//...
}

>into "memset(P, 0, 40000)".
>>
>>57041475
Video game files are usually just resources such as textures and sounds mashed together into made up formats.
>>
>>57043231
The loop cannot be optimized if the value of P might change during the loop.
>>
>>57043176
>>57043157
ah fuck I forgot it only had one &

then im not sure, whatever & does, when the
formula z & (z - 1) is executed, it must equal 0 for true to be returned
>>
>>57043211
It would have to be the other way around. You say X is int, not int is X. And the "a" would probably indicate that it's a class. So "this is a program" would be "Program this;" in OOP terms. Or "Program this = new Program();". Only issue is that it would be weird for an OOP language to not use "this" as a reserved keyword, but since your language is English-like anyway maybe it could use "me", or "my" when referring to fields/properties/whatever.
>>
>>57043175
thank you anon, makes sense now.
>>
>>57043229
>turns numbers into binary
First off, all numbers and actually everything in the computer is a binary. What differs is how it's interpreted.
I'll assume you know binary (if you don't, not hard to find resources). & is a bitwise operator which performs AND bitwise operation on two numbers.
And what it does is perform AND on every bit of two numbers. What is AND? AND is an operation which results in 1 if two operands are both 1, and 0 otherwise.
Take my example above.
4 in binary is 100
3 in binary is 011
so when you AND those two you get a number which has ones only where both of these have ones, which in this case results in 000.
Another example
10 & 9
10 in binary:
1010
9 in binary:
1001
there is one place in which both of these have 1, and the result is:
1000
which is 8
For more info google bitwise operations.
>>
>>57043076
#define this main
#define sentence (
#define is )
#define a {
#define program }

this sentence is a program
>>
Whats the best IDE for making java/iOS apps on win10? Or should i just use win10 for c# VS projects?
>>
>>57043316
He's right.
think of & as multiplication of 0 and 1.

for conversion, that has to do with the various powers of the number 2
>>
>>57043263
But the value of P still can't change during the loop, can it? If i don't change it inside the loop.
Except of course if i do it from another thread, but then, i could still do something like
float* Q;
//.
//.
//.
P = Q;
which is legal, isn't it?
>>
>>57043344
P = &P

P[0] = 0

P = ?
>>
>>57043316
Now I really got it, thanks to all anons for the help.

Need to work on my bitwise operations.
>>
>>57043291
Hmm, that makes sense. I would like to see what would happen if /dpt/ had united and created a programming language
>>
>>57043337
>iOS apps on win10?
I don't think you can. You need xcode. Because Apple is retarded. So stick to C# with VS.
>>
>>57043357
what?
>>
>>57043386
P[0] = *(P + 0) = *(&P + 0) = *(&P) = P
>>
>>57043337
If you really want to stick to windows (sigh...) xamarin is the way to go
>>57043375
what is xamarin
>>
>>57043363
>/dpt/
>"every language is shit" /dpt/
>united
It would be the shittiest shitpile of a language ever.
>>
>>57043375
I figured they would nigger it all up. Would you recommend using OSX just to do iOS development? Or can i achieve the same functionality using C# or F#? I would prefer to use Java though
>>
>>57043177
Hard to say.

It's extremely new, but remember that Microsoft is pushing Windows 10 to be their "last OS".

Either way, most of the time investment in programming UWP applications is learning how to do MVVM properly.

From there, it's pretty easy to write WPF, UWP, or Xamarin stuff, because they all rely heavily on that design.

Personally, I'm pushing myself into Xamarin right now, and I'll move to UWP soon. It's worth noting that many huge enterprise apps are already in WPF, so your MVVM knowledge is helpful there for quite some time.
>>
>>57043398
Still don't see the problem.
>>
>>57043410
>>57043337
Xamarin lets you develop for iOS, OSX, Android, and WinPhone in Visual Studio pretty easily.

It comes with a pretty nice Android and WinPhone emulator that support breakpoint debugging.

Note that you will need an iPhone or Mac to debug and test the iOS part of the application; you can build the iOS part, but Apple kept some components.
>>
I have a few days to implement a Skip List in java that I've never done before. Should I be worried?
>>
File: zen_flowchart.jpg (29KB, 500x769px) Image search: [Google]
zen_flowchart.jpg
29KB, 500x769px
>>57043864
>>
>>57043864
What college do you go to?
>>
>>57043896
>unecessary branch
>possibly 2 unnecessary branches
>poor branch prediction
this is the opposite of zen
>>
>>57043918
UCF
>>
>>57043955
This is the abstraction interface. Details of optimization is left up to each implementer.
>>
>>57043989
So you're saying it's exactly the same except with 2 additional dynamic calls, with potentially no locality whatsoever?
Brilliant
>>
File: 3N0WPfx.gif (172KB, 800x336px) Image search: [Google]
3N0WPfx.gif
172KB, 800x336px
High/Low game v2.0

https://repl.it/DuKK/1

Basicly the same, added a goodbye message, cleaned up the code a bit.
>>
>>57044049
OOP/10
>>
>>57044049
Welcome to the High/Low game!
Enter your guess: 1
Too low, guess again
Enter your guess: 2
Too low, guess again
Enter your guess: 4
Too low, guess again
Enter your guess: 8
Too low, guess again
Enter your guess: 16
Too low, guess again
Enter your guess: 32
Too low, guess again
Enter your guess: 64
Too high, guess again
Enter your guess: 48
Too low, guess again
Enter your guess: 56
Too high, guess again
Enter your guess: 52
Correct! The number was 52
Would you like to play again?
>>
I made a fizzbuzz code in Go:

package main

import (
"fmt"
)

func main() {
for i:=1; i <=100; i++ {
switch {
case i % 15 = 0:
fmt.Println("fizzbuzz")
case i % 3 = 0:
fmt.Println("fizz")
case i % 5 = 0:
fmt.Println("buzz")
default:
fmt.Println(i)
}
}
}


Here's the output:

tmp/sandbox874579258/main.go:10: cannot assign to i % 15
tmp/sandbox874579258/main.go:10: i % 15 = 0 used as value
tmp/sandbox874579258/main.go:12: cannot assign to i % 3
tmp/sandbox874579258/main.go:12: i % 3 = 0 used as value
tmp/sandbox874579258/main.go:14: cannot assign to i % 5
tmp/sandbox874579258/main.go:14: i % 5 = 0 used as value


What's wrong?
>>
>>57044092
you used = and not ==
>>
>>57043344
This is legal, since Q aliases P and are of same type. Beware though, because you are now forbidden to use both P and Q as arguments of memcpy (source and destination are "restrict", which means the areas they point to shall not overlap).

>>57043447
Again, this has to do with the assumption of no overlap.
If you assign &P to P, then P points to itself. Yet, whether the strict aliasing rule is assumed by the compiler or not, there will be two different results in the loop.
Without, P[0] = 0 will overwrite P, then the program will reload P (which now points to address 0), then execute P[1] = 0, which will obviously invoke demons from the pits of NULL and that's exactly what you expected.
Assuming the rule, the loop will be optimized to memset(P, 0, 40000) and you'll be surprised, because the instruction doesn't quite actually do the same. Instead of invoking the demons of NULL, it just erases everything from &P to &P+10000, and God knows what will happen next.
>>
>>57044101
It works, thanks!
>>
Is dereferencing a pointer which was derived from a null pointer UB?
>>
>>57044092
You're using go.

By the way, can you change it to also print "wizz" if i is a multiple of 7?
>>
>>57044088
Riiight, I get what you're saying. Should probably add something like
{System.out.println("Guess a number between 1-100);}

so the user knows the boundaries when guessing the number.
>>
>>57044176
Yes, I think that would be helpful.

Better would be to store the maximum in a static const value somewhere and then refer to it in both the message and the random number generator.
>>
>>57044110

Ok. So if we go back to my original shenanigans
>>57041819
>>57042118
What eldritch horrors might the compiler invoke for this undefined behavior?
>>
>>57044049
Here are some improvements.
https://repl.it/DuKK/2
>>
>>57044140
Yes I think it must be.
>>
>>57044171
I don't know if this is a serious question, a test, or a joke so here's my code

package main

import (
"fmt"
)

func main() {
for i:=1; i <=100; i++ {
switch {
case i % 15 == 0:
fmt.Println("fizzbuzz")
case i % 3 == 0:
fmt.Println("fizz")
case i % 5 == 0:
fmt.Println("buzz")
case i % 7 == 0:
fmt.Println("wizz")
default:
fmt.Println(i)
}
}
}
>>
File: anal beads.png (29KB, 1445x361px) Image search: [Google]
anal beads.png
29KB, 1445x361px
>>57043896
>>57043955
I really need more work to do when I'm at the office.
var currentUniverse = new Universe();
currentUniverse.humans.Add(new Human()
{
Name = "Prakesh Kumar Singh",
CurrentLife = new Life()
});

currentUniverse.humans
.First(x => x.Name == "Prakesh Kumar Singh")
.CurrentLife
.problems
.Add(new Problem() { Description = "can't take the poo to the loo", HasRemedy = false });

var me = currentUniverse.humans.First(x => x.Name == "Prakesh Kumar Singh");

WriteLine(
$@"It looks like I, {me.Name}, {me.CurrentLife.problems[0].Description}, but I
{(me.CurrentLife.problems[0].HasRemedy ? "can do something about it" : "can't do anything about it anyway" )}, so
I {(me.ShouldHumanWorry ? "shouldn't worry too much about it." : "shouldn't worry too much about it. :)")}");
>>
>>57044297
You missed out the cases when it's a multiple of 7 *and* a multiple of 3 or 5.
>>
>>57044310
DESIGNATED OBJECT-ORIENTED LINES OF CODE
>>
>>57043072
don't listen to >>57043131, you might get answers in /dpt/ too but most people in here don't have in-depth knowledge about web dev, /wdg/ is much better for web dev imo
>>
>>57044310
>need to recreate the entire universe for your code to make sense
sasuga OOP
>>
>>57044331
>>57044346
that's more like FP-style C# (but C# is disgusting of course), he's putting a bunch of shit in one line like in haskell
>>
>>57044381
>ignoring complaints entirely
>>
>>57044333
But I do webshit for work so I know quite a bit about it, and I never lurk /wdg/ because it's dead.
>>
>>57044401
>I do webshit
>I never lurk /wdg/
gee i wonder why it's "dead"
>>
File: anal beads.png (26KB, 603x519px) Image search: [Google]
anal beads.png
26KB, 603x519px
>>57044381
We want to be just like our big brother Haskell-oniichans, anon.

C#: the language with no paradigm.
>>
File: -_- .png (6KB, 447x207px) Image search: [Google]
-_- .png
6KB, 447x207px
>>57044346
Maybe all of the OOP fags should get together a just have one massive shared object library the encompasses every single concept, idea, or type of thing that exists in the universe.

That way, we don't have to write a class ever again.
>>
File: asd.png (6KB, 340x117px) Image search: [Google]
asd.png
6KB, 340x117px
All the encryption connoiseurs here on this thread, tell me why this sucks.
I want to learn more about encryption so I'm trying to make a simmetric cypher on python3. It reads byte by byte and I'm working that out but meanwhile I try to generate a key that is: as big as the file, and has entropy I use a password.
First I though feeding the password as a seed to a random number generator like a good one (unless you use c++'s <random> with gcc on windows and realise you either torture yourself with mingw-w64 or use msvc), so I could have generated keys on the fly, now transferring the key is no problem.
Then I sha512 that password. If the length in bytes of the sha512 is inferior to the amount of bytes on the file, then we need a bigger key.
So what we do to make this key bigger and not having any other source for entropy rather than the hash of the password?
Well, concatenate the password with the previous hash of the password, and then... hash that.
That, until you have a big enough key.
So it works but now I'm not sure if what I'm doing is dirty as fuck.
The generated keys can be super big and still vary a lot from password to password without noticeable patterns.

The main problem with simmetric is the sharing of the key. But if I generate my key with a good source of entropy, why worry?
Also the method would be doing XOR over every byte of the file and every byte of the key.
So I'm just going to paste the code and just tell me...
Is this just fucking dirty as fuck? Cause I know it's not safe. Real encryption algorithms are nothing like a simple XOR. I just do it for learning.
>>
>>57044267
>https://repl.it/DuKK/2
> 57 lines
Why not use python?
https://repl.it/X3G
>18 lines
>exactly the same functionality
>>
>>57044486
>https://repl.it/X3G
sorry, this one: https://repl.it/X3G/5713
>>
>>57044469
Does universe derive object or does object derive inUniverse
>>
Just into my first semester of programming, but I don't want to wait 4 fucking years for a job. I just want some Junior Dev job to start and like 30-50K a year to start. What languages should I target and how long should I expect before I can start to work in the industry if I actively try to create shit?
>>
>>57044520
OOP transcends our concept of a universe.
>>
>>57044486
>18 lines
Why not use GolfScript and do it in 17 characters, half of which are random unicode characters not found on your keyboard?
>>
>>57044572
is that a yes or a no or a null reference
>>
>>57044565
Why would you even go to college?
>>
>>57044586
Universe inherits
System.Object
:^)
>>
>>57044470
nobody?
>>
>>57044607
Does object inherit from objectable
>>
>>57044565
Look at jobs posted near your area and find the most common language. You should really choose what you want to do though: Web, desktop/enterprise-y shit/systems programming/embedded programming

That's a programming exercise unto itself so if you're a cheeky bastard, you can say in the interview why you decided to choose this language ("Because I wrote a thing that said this was the most common language in my area").
>>
>>57044607
System.Object
inherits
Jon.Skeet
>>
>>57044629
this still isn't funny you fucking faggot
>>
>>57044602

I more or less have to go to college at this stage or quit college and work some awful minimum wage job. But I'm actively looking to try and get out into the programming industry as quickly as possible but I've only coded in HTML/CSS and some Javascript so I want to know what should I study and then ontop of that whats the time expectation
>>
>>57044330
What should I have done then? A new term such as wizzbuzz, or prioritize 7 over 3 and 5?
>>
>>57044049
Your code is awful and you should feel awful.
https://repl.it/DuKK/4
>>
>universe
>OOP stealing yet another type theory term
>>
>>57044629
>>>/stackoverflow/
>>
Confirm if I've got this right:
If I build a Clang AST from my own invented language I don't need to write anything to do the intermediate code or backend, as LLVM does that for me.

Seems too good to be true.
>>
>>57044647
Pick one of the following (ordered respectively by # of jobs, give or take):
>Java
>C#
>Python
>C++
>C

Pick both:
>SQL
>Javascript

Time frame: no clue. Depends on how many companies you apply for, how well you dress and how non-autistic you are.

You could crash-course a few languages and have a comfortable $40k+ job within six months.
>>
File: 1468472224634.jpg (61KB, 990x557px) Image search: [Google]
1468472224634.jpg
61KB, 990x557px
>>57044664
>muh monads
>muh lambdas
>muh universes
>>
I still dont understand why people use anything other than C++ with C coding optimizations ?
Everything else is bloated slow piece of shit
>>
>>57044688
>>muh good ideas
>>
>>57044659
You mean you don't know?
>>
>>57044704
Yes, that's my first or so functional program.
>>
>>57044696
sounds like your algorithms are shitty
>>
>>57044696
Because "slow" is relative, and nowadays, you're either focusing your entire effort on speed, or you don't really care.

Protip: the vast majority of applications don't need a "fast" language, outside of a few specific components.
>>
Reminder that even if you're writing an application that is I/O or network bound, writing efficient code will lead to reduced power consumption instead of increased performance.
>>
>>57044717
You need to consider the cases separately and combine the results.
>>
>>57044696
i use C++ for gaymes but you really don't need it for normie tier shit apps, you can use java and it will still be many times faster and more energy efficient than those poorly written javascript """"apps""""
>>
>>57044758
Could you please give me an example?
>>
>>57044717
Also I'm sorry for being mean to you.
>>
>>57044688
>putting muh before lambda
>implying functions aren't literally the most basic and useful thing in programming
>putting muh before monad
>implying monads are complicated or obscure
>>
>>57044774
I don't know go but here's an example in C, you can see how it can easily be extended: >>57042444
>>
>>57044794
>>implying monads are complicated or obscure
no, they're just shit
>>
>>57044808
>i don't understand it therefore it's shit
>>
I'm having a hard time understanding file input/output.

Say I'm making a games that loads levels from a file, how can I be sure that they load properly across different computers?
>>
>>57044770
True, but using general abstract algorithms (for ex PLINQ/LINQ in C#) is way slower than writing it yourself using basic for loops
>>
>>57044808
How can an abstract mathematical concept be shit?
>>
>>57044647
Have you looked into coding bootcamps?
>>
>>57044795
Isn't this what I did? I just don't know how I should prioritize this.

Should I print 21 and 35 as wizz too?
>>
>>57044808
You've never mapped over a structure?
You've never collapsed a two-layer structure into one layer?
You've never introduced single values into a structure so it can combine with other structural values in these ways?

Because that is literally what a monad is. It's nothing more than that.
>>
>>57044582
But it's not only 3 times shorter.
It's also 3 times more readable.
>>
>>57044841
>You've never mapped over a structure?
no, why the fuck would i
>You've never collapsed a two-layer structure into one layer?
no, why the fuck would i
>You've never introduced single values into a structure so it can combine with other structural values in these ways?
no, why the fuck would i
>>
>>57044862
If you've ever used a list data structure, you have.
>>
>>57044839
More like this?

package main

import (
"fmt"
)

func main() {
for i:=1; i <=100; i++ {
switch {
case i % 15 == 0:
fmt.Println(i, ": fizzbuzz")
case i % 7 == 0:
fmt.Println(i, ": wizz")
case i % 3 == 0:
fmt.Println(i, ": fizz")
case i % 5 == 0:
fmt.Println(i, ": buzz")
default:
fmt.Println(i)
}
}
}
>>
>>57044862
If you've ever written a for loop that does something to an array, you've mapped over a structure.
>>
https://www.youtube.com/watch?v=pXpoPVcLkXk
>>
>>57044839
Yes.

3 -> fizz
5 -> buzz
7 -> wizz
15 -> fizzbuzz
21 -> fizzwizz
35 -> buzzwizz
105 -> fizzbuzzwizz
>>
>>57044820
haskell has fusion for this
>>
File: Selection_581.png (9KB, 373x90px) Image search: [Google]
Selection_581.png
9KB, 373x90px
>>57044635
>>
>>57044820
C# and haskell and any FP shit is fucking trash only useful for smug fedora tipping
>>
>>57044899
package main

import (
"fmt"
)

func main() {
for i:=1; i <=130; i++ {
switch {
case i % 21 == 0:
fmt.Println(i, ": fizzwizz")
case i % 35 == 0:
fmt.Println(i, ": buzzwizz")
case i % 105 == 0:
fmt.Println(i, ": fizzbuzzwizz")
case i % 15 == 0:
fmt.Println(i, ": fizzbuzz")
case i % 7 == 0:
fmt.Println(i, ": wizz")
case i % 3 == 0:
fmt.Println(i, ": fizz")
case i % 5 == 0:
fmt.Println(i, ": buzz")
default:
fmt.Println(i)
}
}
}


This?
>>
>>57044947
Feels good being Oracle's bitch.
>>
>>57044947
Are you retarded?
>>
File: anal beads.png (17KB, 519x375px) Image search: [Google]
anal beads.png
17KB, 519x375px
>>57044947
>grouping C# and Haskell

Say that to my face fucker and not online and see what happens.
>>
>>57044970
>>57044974
>>57044982
>samefagging
>>
>>57044982
Okay, where's your face fucker at?
>>
>>57044982
it's trash
>>
>>57044999
>999
woah nice
>>
>>57044999
All 3 of those posts are within a single 60-second period.

Who the fuck is going to quickly hop on three IPs just to respond to your dumb bullshit?
>>
File: iceland.jpg (252KB, 601x900px) Image search: [Google]
iceland.jpg
252KB, 601x900px
Realistic non complete newbie project for Python, for a guy coming from C++ ?

Can someone give me something, nothing too big, I have 4 days off of work that I can focus on this thing.
>>
>>57044966
Now make it say bizz for multiples of 4 (and fizzbizz for multiples of 12, etc.)

Do you see the problem yet?
>>
>>57044982
rules = [(3, "Fizz"),
(5, "Buzz"),
(7, "Wizz")]

rule (n, s) x | x `mod` n == 0 = s
| otherwise = ""

run rules x =
case rules >>= (`rule` x) of
"" -> show x
s -> s

main = mapM_ (putStrLn . run rules) [1..150]
>>
>>57044966
Oh, and I think you need to move the 105 case to the top.
>>
>>57045046
Should I make constants?
>>
>>57045029
fizzbuzz
>>
Hey /g/, trying to get ready for some interviews. Haven't touched java in years. I'm thinking this isn't the proper/formal way to create a method like this? Should I keep it in the same class as main and make a new object within the main? What is the absolute proper way to arrange this. Code works I just want it to follow the OOP cluster-fuck that employers expect.

public class StringCompression {
public String compress(String s)
{
int counter = 0;
char currentChar = s.charAt(0);
String compressedString = "";
for(int i = 0; i < s.length();i++)
{
if(currentChar==s.charAt(i)) counter++;
else
{
compressedString += currentChar + "" + counter;
counter = 1;
currentChar = s.charAt(i);
}
}
return compressedString += currentChar + "" + counter;
}

public static void main(String[] args) {
StringCompression test = new StringCompression();
System.out.println(test.compress("aaabbbbccdddddf"));
}
}
>>
>>57045065
The number of cases you must write is quadratic in the number of rules with your current approach. The C example I linked to is linear instead.
>>
>>57045061
How horrible.
>>
>>57044881
he's only ever imported it
>>
>>57045061
bretty neat, I wasn't trying to say that C# is better, just that they aren't really comparable.
>>
>>57045061
fizzbuzz = nums $ fizz /++ buzz /++ wizz
where nums = zipWith max (map show [0..])
(/++) = zipWith (++)

fizz = 2 ! "fizz"
buzz = 4 ! "buzz"
wizz = 6 ! "wizz"
n ! w = cycle (w : replicate n "")
>>
>>57045210
nice
>>
>>57045112
No need, as the only function of the main method is to invoke the actual meat of the program. And it's also way to trivial case to be concerned with such details, and in a production intended environment that would be a service method invoked from somewhere else, and there wouldn't be a main method at all, and defenitely not near this. That would be my argumentation if I were interviewed anyway.
>>
What's a good FP language for real work? I've heard that great. I want something that I can easily integrate into my C projects.
>>
>>57045210
Alright, now we're getting borderline unreadable.
>>
>>57045239
>I've heard that great.
strike that
>>
>>57045239
cinnameg
>>
>>57045239
>C and FP only
>being a walking /dpt/ meme
>>
>>57045239
java
>>
>>57045210
What is this language?
>>
>>57045264
Haskell
>>
>>57045210
DRY, faggot.

2/10, having to manually change your rules in two places.
>>
>>57045257
How do you find out about all these hot new languages?
>>
>>57045264
trash
>>
>>57045271
looks kinda autistic, but kinda fun at the same time.
>>
>>57045299

>>57045061
is also haskell
>>
>>57045237
thanks kind anon. for some reason it's fucking weird to me that i'm calling a new object within the class just to call that method.
so even if I had multiple functions this would be okay? (meaning they follow in the same scope as the above function I made)
>>
>>57045257

>A "do nothing" statement

>Occasionally you need to write a statement in a place where you do not want to perform any action at all. Use () for that.
>>
>>57045321
in haskell this is just

pure ()
>>
>>57045239
Rust
>>
>>57045334
He said FP
>>
>>57045344
C is FP if you execute it inside the universe monad.
>>
>>57045355
>universe monad
>>
>>57045344
Rust is quite FP.
>>
>>57045389
C is quite FP.
>>
>>57045399
C is OOP
>>
>>57045417
Assembly is OOP.
>>
>>57045389
it actually isnt
>>
>>57045316
It's weird, because it's java.
The thing is, that the whole existance of this main method is based on the fact that this is an exercise/interview. A program to present a single algorithm without real world application.
In real world it would not be there.
So I would argue that it doesn't matter at all if the main method is in the same class or not.
>>
File: 1421816984921.jpg (8KB, 250x250px) Image search: [Google]
1421816984921.jpg
8KB, 250x250px
>>57045426
thanks anon. I will continue with the mysterious java ways.
>>
>>57045399
>>57045425
Rust has lambdas, algebraic data types with pattern matching, uses affine/linear types to control side effects and make things more pure, etc.

It's as FP as any ML.
>>
>>57045292
i'm forced to use it
>>
>>57045449
>still no hkts
>>
>>57045460
How hipster is your workplace if you use such hipster languages?
>>
>>57045449
>no monads
>no hkt
>no dependent types
I can't even.
>>
new thread when??
>>
>>57045466
>>57045497
So ML isn't a FP language?
>>
>>57045511
>page 7
>new thread
hmm
>>
geetting rejected by a prostitute

meh, at least ill focus on being productive
>>
>http://www-mmsp.ece.mcgill.ca/documents/AudioFormats/WAVE/Docs/riffmci.pdf
page 60
<wave-data> → { <data-ck> | <data-list> }
<data-ck> → data( <wave-data> )


Halp!
>>
>>57045527
>page 7
>actually page 8
hmm
>>
nu >>57045625
Thread posts: 360
Thread images: 28


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