/dpt/ - Daily Programming Thread

old thread: What are you working on, Sup Forums?

Other urls found in this thread:

en.cppreference.com/w/cpp/string/basic_string/basic_string
nano-editor.org/
pastebin.com/QsrDBJ8c
pastebin.com/HWyS2CvK
cplusplus.com/files/tutorial.pdf
twitter.com/NSFWRedditGif

Can someone explain dot products to me?
Someone suggested a math-heavy website to learn some linear alg and I didn't get any of it.

First for PHP compiled to Java

kill yourself

fuck all of you faggots

>Posting literal fag shit
Delete this thread and kill yourself.

Ignore hasklel threds.
SAGE hasklel threds.
Report hasklel threds.

What problem are you having with understanding them, user?

how do I plot serial data using matplotlib?

the dot product is the proyection (or shadow) of x over the direction y or the same way, the projection of y over the direction x.

If > 0 then you have an acute angle, = 0 then the vectors are ortogonal and if < 0 an obtuse angle. Also you can create hyperplanes to delitmit zones thanks to the hahn banach theorem, which is useful on optimization for branch & bound

How do I convert chars to strings in C++?
Because right now, I feel like I'm wasting memory on creating essentially the same of both.
Either that, or taking an inputted string, and changing it after it being inputted. Is that possible?

>Can someone explain dot products to me?
In what context?
Algebraically it's just a simple reduce operation of two arrays of numbers.
Geometrically you can think of it as a way to measure the 'separations' of two vectors or projecting a vector onto another (say you wanna know how 'far along' a vector is along another direction).

You can create a string in C++ by passing a char array to the str function, like this:

char arr[ ] = "OP is a fag";

string str(arr);

It's not an array though. It's just one character. Would it still work?

Yeah, I think so. Though I have to wonder why you're storing a single char as a string.

I'm basically taking a user's input (One letter), and then based on the type of letter they picked, convert said letter into a word, or string. Right now, I'm using two chars, and two strings, both with the same names, just that the chars are in lower case, while the strings are in upper case.

It might help if we could see the code, but yeah I don't think you need duplicates of all your variables.

int main()
{
int result;
char user1, user2, le = 'y';
string USER1, USER2;

while(le == 'y' || le == 'Y'){
cout > user1;
cout > user2;

switch(user1){
case 'p':
case 'P':
USER1 = "Paper";
if(user2 == 'r' || user2 == 'r'){
USER2 = "Rock";
result = 1;
}
else
result = 2;
break;
case 'r':
case 'R':
USER1 = "Rock";
if(user2 == 's' || user2 == 'S'){
USER2 = "Scissors";
result = 1;
}
else
result = 2;
break;
case 's':
case 'S':
USER1 = "Scissors";
if (user2 == 'p' || user2 == 'P'){
USER2 = "Paper";
result = 1;
}
else
result = 2;
break;
default:
cout

Literally just look in the docs.
You should always keep a tab of the docs next to your Sup Forums tab when you program, next to your stackoverflow tab.

en.cppreference.com/w/cpp/string/basic_string/basic_string
>2) Constructs the string with count copies of character ch. The behavior is undefined if count >= npos.
char x = 'X';
std::string s = std::string(1, x); // count=1; one copy of character
std::cout

Why would people shill Vim/Emacs over Geany?

Thanks, but that just looks less readable than my existing code. Thought there was some more automated way to do it.

Why would people use anything other than GNU nano?

>GNU nano
It's not GNU anymore. It's just 'nano'.
>Why would people use anything other than GNU nano?
Severe lack of features.

nano is bloat

Why would some no-name shitty VS-clone "IDE" be better than Emacs?

The way to do it would be to have a function that takes in a character abbreviation and outputs a string, e.g.
string get_hand_name (char c) {
switch (c) {
case 'r':
case 'R':
return "Rock";
...
default:
return "";
}

Then be like
char user1_c, user2_c;
string user1, user2;
...
cin >> user1_c;
...
cin >> user2_c;
user1 = get_hand_name(user1_c);
user2 = get_hand_name(user2_c);
if (user1 == "" || user2 == "") {
std::cout

nano-editor.org/

vim and emacs are bloated
geany has GTK bindings, which makes it bloated by design

>vim and emacs are bloated
>useful software
>!! BLOATED!! REE
Have fun ricing your gentoo install, asshole. Do you have a job yet?

>Also what you probably want to do is have seperate values representing rock / paper / scissors, so you don't have to constantly check cases.
>A common C idiom is to define them as numbers.
>int ROCK = 1;
int PAPER = 2;
int SCISSORS = 3;
int INVALID = 0;

int parse_move (char inp) {
switch (inp) {
case 'r': case 'R':
return ROCK;
...
default:
return INVALID;
}
}
>
>A cool advantage to this is you get to utilize string indexing
>const char* moves[] = {
"-invalid", "Rock", "Paper", "Scissors"
};
int main () {
int user1 = parse_move(user1_c);
...
std::cout

Well, apparently I was going off of some mis-reported news articles from awhile ago.

vi comes with my minimal install. nano does not. nano is bloat to my workflow because now I have to remember how to use vi and nano, and since i have to use vi to configure my network-scripts every 2 years when I install a nix I have to remember how to use vi. So I just use vi(m?).

tl;dr I don't always have nano. I always have vi so anything I don't use (eg nano) is bloat to my disk and my muscle memory.

>VS-clone
Do you suffer from severe autism?

>int ROCK = 1;
>int PAPER = 2;
>int SCISSORS = 3;
>int INVALID = 0;
No. Just no.
enum {
INVALID,
ROCK,
PAPER,
SCISSORS,
};
or
#define INVALID 0
#define ROCK 1
#define PAPER 2
#define SCISSORS 3

How the fuck is haskell so fucking hard to learn even if you know a shit ton of math

Anyone have experience how to work it?

>muscle memory
>tfw making the transition from vim to emacs
>muscle memory is in shambles
>pause for 5 seconds trying to remember if $ or ^ takes you to the end of line
>accidentally press C-x in vim and the terminal freezes up

He's a beginner. It's easier to understand int variables than learning a new syntax (enum) or using shitty defines. He'll learn those things later but more important than whatever laundry list of advantages enum has to toplevel variables, is just understanding the idea and purpose behind it.

>He's a beginner
That doesn't mean that you should give him misinformation.
There are several very large disadvantages to using an int variable, including NOT being able to use it case labels, which is very fucking important.

>Everyone and his wife's son knows C
fuck why am I so dumb

>including NOT being able to use it case labels, which is very fucking important
Fuck I didn't realize that.
C++ can eat a dick by the way

>tfw you're about to become a wage-cuck

I've failed Sup Forums, I've yet to find a way I can become self-sustaining from my CS Degree.

cuz C is for shitters who only make console apps and fizzbuzzers

What in particular?

>Falling for the CS meme.
Top kek.

...

pastebin.com/QsrDBJ8c
Here is how I would do it.
Could use some cleanup but, w/e.

Same with python :~)

Shouldn't you have a CharLowercase function?
Also use methods from cin instead of _getch() to be more I D I O M A T I C

I use _getch because it doesn't emit it to the console (no reading the other's entry) and you don't need to press enter.
Moving more into functions, like user input (and therefore lowercasing), should be done but I didn't feel like doing it, so I didn't.

Linux doesn't have _getch(), and cygwin doesn't support it either last time I checked.
Yes, I know it's annoying to have to type enter but it's honestly much better for everyone involved, for instance you could pipe a file into your RockPaperScissors program to do automatic testing.

I mean I just wanna learn it because I put so much time into it, but tutorials in the C book are tough for my scrub brain

What don't you understand?

pastebin.com/HWyS2CvK
Refactored
*nix support

Happy?

The programs that I copy per every lesson don't do what they describe, or atleast what with my minimal knowledge expect them to

What book is that even?

Yep! Looks great

The C Programming Language 2nd Ed.

Post the question you're having trouble with.

Is that the R&K one?
I think that's a notch too hard for beginners.

If you don't mind switching to c++ for the basics and foundation you could try this book
cplusplus.com/files/tutorial.pdf

source?

make a program that AWOOOOO~'s

I feel like making a youtube channel with programming tutorials, but I don't want to make all the mistakes that other people make like making their videos hard to digest at 1 hour in length, scarecam, being indian, etc.

How do I make programming not boring to look at?

lots of anime and emacs

by doing text tutorials on a good looking page with a nice font

video tutorials for programming cant be good

me on the left

qt

#!/bin/sh
aplay awoo.wav

I'll come back with something

Yeah it is
I hope to not switch so soon, but I'll give this a try

senpai pls keep me warm

How should I go about writing a script that uses the thread watcher and waits for multiple (You)'s and "samefag" and then hides one of the (You)'s and takes a screenshot, and then uploads the screenshot as a reply and posts it?

@57535954
this is pathetic as fuck i dont even know where to begin with this post

not even gonna (You)

Regex

roast me senpai

A Compiler

class Awoo{
public static void main(String[] args){
System.out.println("AWOO!!! :^3");
}
}

Spend my night getting stupid stack rewinding for Windows working, only to realize that either the IDE or the virtual machine are broken.

Haven't bothered to fix anything yet. VS and MASM are goddamn retarded.

how to find a large volume of relatively simple github projects to contrib to ?

By not plenking, you retard.

pls, , , don't criticize my typing.. way to judege a book by the front

Someone who does not know about proper spacing probably has major lapses in his overall education and does not deserve others attention. Judging a book by its cover is completely justified.

I don't know what the fuck am i doing.

>am I doing
Your English is terrible, and so are probably your programming skills.

There's no evidence that they don't know about these things. They could just be pretending to be retarded, etc. It's one thing if someone spouts some truly incomprehensible shit, but insulting someone isn't useful here, nothing comes of it.

>They could just be pretending to be retarded
Then they don't deserve attention either.

Nobody deserves anything, so that's a non-argument.

hey dude chill, out some people need, some casual, grammar,.

>insulting someone isn't useful here
Welcome to Sup Forums, you fucking faggot.

You deserve to be shot in your head while the ambulance drives over your bleeding corpse and explodes right above you.

Learn English or disembody yourself. Your choice.

Hey Dude Just Chill Tf Out Lol Xd

hey Sup Forums
Over the course of about 6 months, I've made a program, by myself.
I need to present it tomorrow at Uni as a side project, to show my programming initiative.
It's C++.
It is a huge bunch of header and cpp files, and I made it so I can use it to make games in the future.
It's features:
It handles keyboard and mouse input events (I made my own KeyDown KeyHold and KeyUp events)
Debugging to a .txt log and console.
Handles loop time (eg, 50 main loops per second) If it goes over, it logs it to the .txt and console
It handles the loading and drawing of images (strictly 2D)

The only thing I've used externally is SFML.

Essentially you copy and paste all the .h and .cpp files into a new project, and code in the given methods, store data in the ProgramSpecificStorage class, etc.
I never plan on distributing it, because it's just for my shitty use.
But to get extra marks at Uni, I've decided to show it.
Problem is, I don't know what to call it. It's got a name, but I don't know WHAT it is/what to refer to it as in my submission.
Is it an engine? (No UI for coding, it's entirely just files, so probably not)
Is it a framework? (Probs not)
Is it a library? (You can't import it. You have to code IN one of the class' methods)
WHAT IS MY PROGRAM?

>EVER RECOMMENDING THE GARBAGE PREPROCESSOR

kill yourself you neet idiot

>Le pre-processor is bad
Fucking sepplesfags

>It's C++.
Worthless

it is

Souce?????

Just like you and your opinion. Kill yourself, shit stain.

i'd just call it a framework anyway

Not him, but any program written in C++ is worthless.

You have one dot, you have another dot.
You now have two dots.

I guess GCC, GDB, Clang and LLDB are worthless then.

Yeah! fizzbuzzes are what matters.

Kono Joukyou de Otouto Route ga nai no wa Okashii!

You can only say that when you actually had to honor different calling conventions in your code because you had to program it in assembly.

And then you wouldn't sad that GCC is worthless. But C++? Just give me the template system for C and keep all the other retarded shit for yourself.

Yeah I think this is my best option right now.
I mean after reading the definition, it doesn't ENTIRELY fit, but it's not that bad.