/dpt/ - Daily Programming Thread

Old thread: What are you working on Sup Forums?

Other urls found in this thread:

blog.hostilefork.com/where-printf-rubber-meets-road/
twitter.com/AnonBabble

...

can artificial intelligence shit post better then me? would it?

Please do not use an anime image next time. Thank you.

Daily reminder to not abuse greentext and to always ask people who abuse greentext whom they are quoting!

yes i can

>be me
>new green text meme
>dafuq is this shii
>keyboards missing buttons
>just took my sleeping pill
>learned about switch case default
>

Who are u quoting?

Whomst was the original source of this phrase?

>encouraging off topic spam
Sent ;)

>be me

Hey, just curious who you're quoting? I don't see that message anywhere in the thread.

>encouraging off topic spam
I didn't say that.
>Sent ;)
What exactly did you "send", user?

>new green text meme
What are you going to mean by this?

I'm going to assume the answer is "no" but:

In C# I can use reflection to refer to any class file that exists in the solution. So if I have 20 class files called "Problem_XX" I can use reflection to dynamically call those files overloaded functions without having to hardcode anything.
e.g. Problem_01 and Problem_02 and etc have a method called Run() and I can just use reflection to take an input of, say, 02, to find and run Problem_02.Run()

I ASSUME there's no similar way to do this in C?
The reason I want to is so I don't have to constantly update and hardcore a driver file when writing exercise problems.

>In C#
Stopped reading right there.

Kill yourself

Your life is wrong and needs fixing.

He kinda has a point though...

Type.GetType(string) and InvokeMember might do what you want.

will someone do my homework for me...I have an folder on mega and there is ten problems, could someone possibly do them for me so I pass my classes?

Wait, nevermind, I didn't read, but the answer is no, you can't do the same in C.

What language?

>>be me
>who are you quoting?

javascript
there is no web shit, just little games and shit

Javascript is /wdg/

But why would you have javascript homework if it wasn't webshit?
Also see

it's an intro to computer science and all of it is scripts like a guessing game or converting numbers and random numbers

Which one's better?
long long factorial (int f)
{
if (f == 0) return 1;
else return f * factorial(f-1);
}

long long Factorial (int n)
{
long long F = 1;
for (int i = 1; i

Still learning how to use vim + tmux

Thank you for using an anime image.

...

>Non tail call recursion for a linearly scaling algorithm
Definitely the second.

int64_t

man's C syntax gets awful when you get into the lower level stuff, example i found on the internet:
>#define DEV_REG (*(unsigned char *)0x80000000)
what the fuck is this shit

1 - Nobody. He is a retard.
2 - Nobody. He is a retard.
3 - Post 4 - Post 5 - Possibly post
6 - Nobody. He is a retard.

macros and headers are trash

Did that poster say "Non tail call recursion for a linearly scaling algorithm". If not, why are you quoting it?

t. butt boy

what's the most elegant way to assign str1 to the longest string of two strings, and str2 to the shortest string of two strings in python?

it's simple as fuck, you brainlet. it's a hardcoded memory address that probably has some significance on the target platform, being cast to an "unsigned char*" so that it can be dereferenced, and thus used (almost) as a normal variable.

I'm not sure I understand what you're trying to say.

I don't even know what this means

rude

I am quoting reality.

sorry bb ily

It's a table meant to answer the invalid in this case (as half of the posts were actually quoting people) question "who are you quoting?".

I'm saying you're a butt boy.

fucking idiot
stick to python

and before you say it, doing a = min([str1, str2], key = len), b = max(.. wouldn't be reliable since the strings could be of the same length. i thought of that too

Reality can't speak or write.

str1,str2 = sorted([str1, str2], key=len)

>in python
Stopped reading right there.

Python isn't a language, it's a torture device.

Prove it.

It's worse when the header file just references another file and provides a macro/wrapper around another library function in another file and you have to go like 3 layers deep into the darkest depths of the library that was never intended to be read by mortals to find the actual source code of the function.

Example: blog.hostilefork.com/where-printf-rubber-meets-road/

Whom are you dereferencing?

Am I a shit programmer if I can't find the motivation to program very often

C is a torture device.
Not Python.

Sure
only if you will mention to your teach that you got help on at Sup Forums.org/g/dpt

The post I am replying to.

thanks lad. how do you guys learn syntax like this? just from reading books on the language you're learning? i liked haskell because you could do a lot of really elegant things like this without having to memorize quirks. is python just one of those languages with a bunch of hidden features you gotta memorize?

Real negroes program everyday for 10-12 hours

No...

Do you deny your nature?

C hash is a comfy language.

Yes, he is. Or I suppose, more correctly, I am.

Well I used to do some golfing code challenges in Python for a little while, learned some cool tricks there (I could share some). And I like to write Haskell for fun, because it's pretty much constant golf.
Destructuring syntax is invaluable (even though it fucking sucks compared to actual pattern matching). And sorting a list using len() as the key is the most "clever" solution to your problem.

It literally just means "define DEV_REG as the unsigned byte located at memory address 0x80000000". That's nothing compared to function pointer syntax.

>pointers are hard :-(

Who are you quoting??

A while back I wrote my own vectorN implementation with simd instructions and the whole everything. I was well underway into writing a generic matrix type when I found that there's a fucking library called GLM that does all that shit already.
Goddamnit Sup Forums, why didn't you tell me!?

this is why C++ was invented.

brainlet

*Rust

*Nim

C++ would use the same macro. Unless you wanted to define some struct with an overloaded = operator to wrap around the behavior of dereferencing that address, but that's... overkill.

I made a C# class with 11 inner classes that works perfectly. Should I just ignore everyone who tells me not to have inner classes?

>new

*Haskell

No, it would have a nice RAII type to allocate and deallocate the device memory in the first place with an overloaded dereference operator so you don't need to hardcode memory addresses.

The memory address is hardcoded because there's a specific hardware device mapped to that address. And allocation/deallocation is pointless if you're working with literal memory addresses.

AFAIK there isn't a PORTABLE way to do this, but you can do it. I assume you're using windows, right? You'd have to compile Problem_01, etc as dll files and load them.

Whenever I try to run the program it stops at the 3rd calculation and shits itself "bin.exe stopped working"...why?
#include
int main(void)
{
int x, y, z;
x=2, y=4, z=6;
x+=y*z;
printf("%d\n",x);
x-=y+z;
printf("%d\n",x);
x*=y-z;
printf("%d\n",x);
x/=(y/z);
printf("%d\n",x);
x%=(y%z);
printf("%d\n",x);
return 0;
}

>windows
everytime

>x-=y+z
Wft?

what the fuck is this?

For Python 3, are there any courses or texts or videos that go over examples of solutions or modules for common problems in depth? It's all very well learning the syntax, but I want to start learning how to put things together meaningfully and to make larger programmes.

use VS debugger, faggot

edx mitx introduction to programming

if you can't do that after reading pic related, you should stop now.

Do you even know how device memory works? You need to get the base address from the PCI registers and then remap it into linear address space. Nobody in their right mind would hardcode that shit. You can't assume anything about the memory layout at runtime.

Where did his post say "windows"?

>Python
>put things together meaningfully
What did he mean by this?

x-=y+z; is equivalent to x=x-(y+z);
i wanted to test results I'd yield by using the (+=, -=, *=, /=) operators

shove print statements after every line to find exactly where the problem is if you don't want to use a debugger

>bin.exe
is your first clue

kys

Are character inventory databases implemented in either of these ways or is it something else? I'm a little stumped on how you normally make a database that holds inventory and the amount

In what way is "bin.exe" the same as "windows"?
Did you fail grade school?