/dpt/ - Dailly Programmming Thread

What are you working on, Sup Forums?

Old:

Other urls found in this thread:

mitpress.mit.edu/sicp/
sarabander.github.io/sicp/
sarabander.github.io
geeksforgeeks.org/add-greater-values-every-node-given-bst/
github.com/microsoft/vscode/issues/32405
feedback.photoshop.com/photoshop_family/topics/photoshops_gradient_editor_needs_an_overhaul
twitter.com/AnonBabble

Shouldn't rust by a fag at a pride parade? Maybe give it a Mr. Robot tie in.

Don't confuse your perceptions of their communities with the languages themselves.

im fucking failing a subject this semester so ill just withdraw and learn something on my own with the free time ill get.
which programming book to read? is the wikis "god tier" collection good or are they memebooks? what to start out with?

its trying to communicate

redpill me on LL vs LR parsers

...

SICP

that meme book everyone has? aight ill give it a shot
what about the art of computer programming?

>redpill me on LL vs LR parsers
LL parsers are generally weaker than LR parsers, but easier to write by hand and more efficient, especially in terms of memory consumption. Personally, I find that hand-written recursive descent parsers are usually easier to deal with than even automatically-generated LL/LR ones.

WTF I love go now.

reminder that SICP is available for free online
>official site
mitpress.mit.edu/sicp/
>nicely formatted
sarabander.github.io/sicp/

have to make web crawler for an assignment
- in python, without 3rd party libraries
- gets starting address
- extracts links and emails
- does some verification if email is not fake (artificial rules, part of assignment)
- follow only local links, should not leave domain

I'm using the 'urllib.request' library for http client and html.parser.HTMLParser for parsing the response. Let's say I extract 'about.html' string (relative path) from some tag attribute. How can I work with this in context of the request url? Should I just concat strings to get another url or are there some functions that can do this for me?

>Rust
Unreadable
>Go
Readable

>sarabander.github.io
nice!

look at urllib.parse

Why? Did she give you your first kiss?

What does lies beyond horizont of code?

Pity about the no libraries bit. "requests"is standard practice for anything involving web requests and "furl" is the answer to your specific question about url manipulation/creation

requests is even mentioned in the official docs. don’t see that much

I'm trying to build a program where it takes the exponent of the elements of one binary search tree. Basically BST^x where the new tree shows the newly created elements. I was thinking of using a recursive function to get it to convert but been unsuccessful. I'm trying to do this in a header file. Anybody know how you can do this?

This is the code I'm using. How wrong am I? Would it be better to instead implement this outside the header file?

template
class BinaryTree
{
private:
struct TreeNode
{
T value; // The value in the node
TreeNode *left; // Pointer to left child node
TreeNode *right; // Pointer to right child node
};

TreeNode *root; // Pointer to the root node
int sum; //for conversion
public:
void convertTree(T value); //convert to pow func

};

template
void BinaryTree::convertTree(T value)
{
TreeNode *nodePtr=root;

if (root==NULL) return;

sum= pow(sum,nodePtr->value);
nodePtr->value=sum;
convertTree(nodePtr->left, sum);
convertTree(nodePtr->right, sum);
cout value

That feel when still forced to use python for webcrawling

precisely what I need, thanks user

>Templates
>Would it be better to instead implement this outside the header file?
No.

Exactly. Just like datetime recommends pytz. It's an exo-module at this point. OP's teacher is a faggot.

you can't split the definition and the implementation of templates
this is the reason for the .hpp files

searched it in qbit why is it fucking 2mb how small is it

Start by initializing sum to zero. Also it should not be a member variable afaict, it should be an automatic variable of the convertTree function.

You can, you just have to include the definition to use it.

>including a cpp
Unless you're very clearly doing a unity build, don't do this.

You can't split it off into a translation unit that you link to, no. But some C++ programmers have a regular .hpp, a .tpp or something with template definitions that gets included, and a .cpp for non-template definitions.

I've never seen a .tpp file, but I was curious if that's a thing.

I don't think it's very common but I have heard people talk about it. Of course it's not really any different than except that the definitions are put in a separate file that is included e.g. at the bottom of the corresponding header.

Freshman at University.
You guys should really have said something.

I have no idea what your function is trying to do, but it sounds like you want something like:
TreeNode* convertTree(TreeNode *root) {
return root ? new TreeNode(func(root->value), convertTree(root->left), convertTree(root->right)) : null;
}

he might be doing it in-place? i don’t know what sum is for either; i’m confused

Why would 2mb be small in this case?

>he might be doing it in-place?
Then why is he talking about a new tree and newly created elements?

Hey there I'm starting out all I know how to do are template files...

Thanks, I did that and I think I got somewhere but still not working. Now I think its just my template title that's wrong

I made some changes basically just this
public:
void convertTree(TreeNode *&, int&); //marked wrong by program

template
void BinaryTree::convertTree(TreeNode *nodePtr, int sum) //marked wrong by program
{
sum=0;
TreeNode *nodePtr=root;

if (root==NULL) return;

sum= pow(sum,nodePtr->value);
nodePtr->value=sum;
convertTree(nodePtr->left, sum);
convertTree(nodePtr->right, sum);
cout value

>void BinaryTree::convertTree(TreeNode *nodePtr, int sum)
>void convertTree(TreeNode *&, int&);
what

Sorry if I'm being confusing, I'm like half asleep already. What I mean is I first created a normal binary tree (say I input 5,6, 9 into the tree) then after the tree is initially created I want to take the exponent of every value in the tree (so I get 25,36,81).

Thank you. I'll try this out and see if it's what I want.

The sum is just there to get the new value of the node after the exponent has been applied (sum=pow(node in tree, exponent).
I'm basing this off some code I saw online where the guy does something sort of like what I'm doing. I just wasn't too sure if it could work for me but I tried it anyway.

geeksforgeeks.org/add-greater-values-every-node-given-bst/

>then after the tree is initially created I want to take the exponent of every value in the tree (so I get 25,36,81).
Do you want to modify the existing tree, or create a new tree with new values?

?
The 'void convertTree(TreeNode *&, int&);' is supposed to be within The 'class BinaryTree {};' from the code I first posted. I just posted it like that to show what I changed from the original code I posted.

I'm trying to modify the existing tree but I really don't care either way. Which ever way is easier or possible.

>I'm trying to modify the existing tree
template
void convertTree(TreeNode *root) {
root->value = func(root->value);
convertTree(root->left);
convertTree(root->right);
}

Assuming I remember C++ template syntax correctly.

Ooops. The body of the function should be inside an if:
if(root) {
// all that stuff
}

Why do you put &s in the declaration but not in the definition? that's why the compiler is barfing. You have to decide one way or another, that'll bring you one step closer to completion.

general advice: slow down

>webdevs can't even function in an IDE without fucking something up
github.com/microsoft/vscode/issues/32405

>3 months of work, not a single commit in that time
what the

every time

>i "accidentally" pressed a button that says discard
>it said: are sure to discard all the changes?
>it discarded them
>it didn't say CAUTION: THIS WILL DELETE EVERY FILE FROM THIS FOLDER IN YOUR COMPUTER.
>it deleted my files! they're not even in the recycle bin! how is this possible on windows?
>profile pic
>looks like a spic
Checks out.

I keep being attracted to Python but I never know what it is really used for. What do people use Python for?

he thought it said sauce control

Pic related.

It's a programming language. They program with it.

>I keep being attracted to Python
>What do people use Python for?
To satisfy their perverse sexual attractions and programming-related fetishes.

He's actually 100% in the right. That is complete garbage UX design from Microsoft's side.

Yes of course he should have had backups that's not the point. It's a valid ticket to raise.

Those buttons look familiar to me... Is that early Gnome 3 or am I retarded?

fake img, improper ppe

>t. Eliecer Thoms

>"this discards changes"
>it discards changes
>REEEEEEEEEEEEEE
This site is 18+

the sciences have taken to it for data analysis. most of these users are not, primarily, programmers. for me the scipy projects together with whatever ml library you want works great

>"FUCK YOU FUCK YOU FUCK YOU", etc.

Yes, very valid ticket to raise, Eliecer.

Think about it you retard.
>Have folder with files
>git init
>Discard changes

What changes have you made to the repo? What do you expect to be discarded? 5,000 files that aren't even fucking checked into the repo? Why the fuck would git even go near those files?

Completely appropriate considering how irresponsible VS Code was/is set up.

It doesn't. You are wrong on the technical facts. He did, in CLI parlance
git init
git add . # holy shit a new file! could that be a change?
git checkout -f # holy shit I put -f! is it dangerous?

>git init
>git add --all
>git reset --hard
Who would win? 5000 files and 3 months of work, or one button?

well, they made the warning much more retard-friendly.

>man presumably continues to use his computers browser which without a doubt is going to write something to disk rather than getting it out of there and running a file recovery tool from another machine.
>his files are now almost certainly lost
Can't really say I feel sorry.
And ascii/utf-x text files are so easy to find too.

Wait no, git checkout -f doesn't do that, git reset --hard does. Subtle yes. but any retard does git commit -m 'F1R5T C0MM1T' right after doing that anyway. And then whatever you do the reflog is always there.

or you know, in those three months, he could have hit c-shift-g, slammed on the keyboard for a commit msg, and then hit c-shift-p to push it.
But that's expecting too much

Yes of course. I'm just saying that instead of practically saving himself ~3 months of work he went on to yell at developers on github because he's a dummy who hasn't even heard of data recovery.
There's companies that do this stuff too of course.
I doubt what he's done has much value to humanity either way.

Thanks a lot, you've been very helpful. I get what you're doing now but one part is kinda confusing me since the program is giving me an error. This is how the class looks like again
template
class BinaryTree
{
private:
struct TreeNode
{
T value; // The value in the node
TreeNode *left; // Pointer to left child node
TreeNode *right; // Pointer to right child node
};
TreeNode *root; // Pointer to the root node

public:
void convertTree(TreeNode *); //modified it to look like this
};

I did (convertTree(TreeNode *) ) as it was the best thing I could think of but obvious that's wrong. How would be the proper way? I'm confused because since I'm saying (TreeNode *root) can't I just write the definition like void convertTree(TreeNode *nodePtr) rather than putting *root like how you did it? and replace all the roots with nodePtr? Or would that be wrong?

The code in general I didn't write and since I'm learning from it I'm just following the logic the rest of it says. And the rest of the code has the definition the way I said it (TreeNode *nodePtr) which is why I get kinda confused on why you choose to use root.

he's a spic and a pyweb dev, that's just too many unholy things to ever expect a rational, intelligent human being.

>pyweb dev
I'm not one for labels and prejudice normally but I get you on this one.

The point is that in the VS Code UI, it just says "Discard?" It's a very innocuous popup. Obviously if you know what's happening under the hood it's a different matter entirely.

It would be like a popup asking "You haven't selected anything to delete. Proceed?" and if you click yes it runs rm -rf / --no-preserve-root. Because why not, root would make sense as a default if you haven't selected any directory.

>This section describes the simplified version of the simply-typed λμ-calculus (Sλμ), to which a semantics will be given in the next section. This version is simplified from Parigot’s original simply-typed λμ-calculus, dropping the original distinction between λ- and μ-variables. Also, Parigot’s original formalization of the calculus, especially his formalization of its inference rules, is a little difficult to follow; so we employ a formalization more familiar to many. Henceforth the qualification ‘simply-typed’ will be omitted for the sake of simplicity.

it’s just a name. the pattern in recursive programs like this is that when you pass to the next level you forget about the previous ones, so the node you’re getting might as well be the root

write your own implementation. it’s really short and the hindus at g4g are only going to confuse you

This is why codes of conduct exist.

Java < Kotlin < Scala

>It's a very innocuous popup
Very innocuous: Even if I didn't know anything about VCS, I'd have second thoughts about pressing that.

>It would be like a popup asking "You haven't selected anything to delete. Proceed?"
Except it's obvious what the changes are in this instance: everything you've just staged to an otherwise pristine repository, so it's more akin to selecting everything, seeing that all your files are marked blue, not understanding what it means and pressing "discard", thinking it will discard the strange blueness from the files.

your arrows are backwards

say you have 1000 arrays with 20 integers each, and you want to build another 20 integer array composed of the elements from the other 1000 arrays where the sum of all elements is maximized without using more than one element from any array, and where each element can only be used in its "slot"
e.g.
a = {2,3,3}
b = {2,2,3}
c = {4,1,4}

the result would be {c[0],a[1],b[2]}

what would be the most efficient algorithm to do this?
sorry if this is a retarded question, but I'm not really sure how to go about it without using brute force

I see your points but I respectfully disagree. Even sourcetree which is a program specifically made for source control, with a focus on git, doesn't have a way to reset --hard in the UI. There's simply no reason for that button to be there. And especially not in a popup together with "cancel", which means roughly the same thing.

Alright then thanks a lot for your help.

his arrows are upside down

i’m not btw. he’ll probably have smarter things to say
it’s also good to tell us the error

Frankly, I think the root issue here is with git itself, and the VS Code interface just reflects it: if you git init in a folder full of files, it's enough to stage them to get them tied to the state of the repo. You don't actually have to commit anything, which I guess is kinda counter-intuitive in this situation.

Working my way through Programming: Principles and Practice using C++, just started the other day...

How do I keep myself motivated to do the boring exercises and stuff? I want to do fun stuff but I need a solid foundation first of course, but it's all so tiresome.

Ah okay, well thanks anyway.

which lc is this

lc?

Aye. You'd never see that on Rusts github page.
On the topic of support threads though
feedback.photoshop.com/photoshop_family/topics/photoshops_gradient_editor_needs_an_overhaul
This is hilarious.

>python
>ruby
>go
>php

>python ruby go php
is this a poem

It's good to learn to get through things like that. Consider it part of learning to deal with that stuff. Helps me to think of it like that.
Also if you're meticulous you can probably learn something even from basic exercises and learn to appreciate that.

Justify not using electron. You can't.

python,ruby go
everyday, i feel like death
release me now

>release me now
only 4 syllables

re-lea-se me now