/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: zhbqwHt.jpg (640x476, 37K)

Other urls found in this thread:

stackoverflow.com/questions/4110731/how-to-get-the-screen-refresh-rate
twitter.com/SFWRedditVideos

f x y > (f x y) > f(x, y)

>reddit memes
kill yourself

x `f` y

uncurry f (x, y)

Attached: 1550522493947.png (644x800, 15K)

(f_pntr)(x, y)

Please use an anime image next time. Thank you.

>Le eban reddit brograbber maymays
Jesus christ, what a fucking awful OP.

Attached: 1527040650343.png (1600x1200, 1.8M)

push y
push x
call f

> 2k19
> still using 32bit x86
mov rdi, y
mov rsi, x
call

f x $y

can someone just make a new thread please

Attached: 1548580923499.png (1024x576, 325K)

just a prank bro, it was pseudo code
it's been a while since i last used assembler

let's try it

You can't spell trust without Rust.

You can't spell Crap without C.

You can't spell "I hate my life and I'm gonna kill myself" without Go.

im gonna kill MSYS .elf

You cant spell untrustworthy without rust.

Attached: 1553481268558.jpg (330x381, 73K)

Attached: 1547634828628.png (963x832, 669K)

Impressive

currying
(define f
(lambda (x)
(lambda (y)
( ... ; x captured in this scope

f(y(x))

Attached: 1534364746502.png (600x563, 80K)

f(x)(y) fgt

Attached: shelly.webm (1440x1080, 2.9M)

fx.fy.x.y

Attached: 1546675903433.png (640x923, 860K)

that's not the same function

>cuckime
Fuck off

I like how the reddit "/dpt/" is filled with nothing but shitposts. really shows how much you fags actually contribute here.

>not having currying as a part of your language

Attached: Homer.png (512x384, 347K)

(f) x, y

Car car = new Car();
car.f(x, y);

f -> x -> y

>install Signal for Desktop (tm)
>literally a chat client with 3 contacts and no messages
>300mb RAM
*yehaws*

lisp niggas be like
((f(x(y))))

f = new -> caller -> f
call -> f -> x -> y

x y f

void f(int x, int y){
...
}

x;y;f;!

>currying as a part of your language
please kindly do the needful

C noob question here.

I'm going through step by step trying to make a function that will do calculations with each element in my array. My array needs to be filled with numbers it gets from a txt file. Before I go through building my function I just wanted to make sure my arrays were filling properly with my end file loop so I wrote the printf statement in my EOF loop.

Why is it that this loop only prints one thing at a time and makes me hit enter in order for it to get the next thing? Did it fill the cells of the array properly or is it only filling the cells everytime i hit enter?

int main()
{
int day, month, id, i=1;
char c;
double hours_used;
int id_array[10];
double charges_array[10];
double cost;
FILE*infile = fopen("usage.txt", "r");
FILE*outfile = fopen("charges.txt", "w");

fscanf(infile, "%d %d", &day, &month);
printf("day: %d month: %d\n", day, month);

while ((c = getchar()) != EOF)
{
fscanf(infile, "%d %lf", &id, &hours_used);
id_array[i] = id;
charges_array[i] = hours_used;

printf("ID: %d hours used: %lf\n", id_array[i], charges_array[i]);

i++;
}

LOL (laughing out loud) nice programming meme OP here's one I found myself, this is my first post on this web site so be nice :)

Attached: ht1h18yqhom21.jpg (500x626, 82K)

Lost

Attached: 1554184654876.jpg (960x942, 64K)

Fuck this stupid invalid reddit thread. Why did you morons keep bumping it for the last 10 hours?
Anyway, here is the real continuation of the proper /dpt/ thread:

Can I get a good book/tutorial/primer on databases? I am doing a quiz program and I need to save user data, and it seems like a good time to delve into this subject. If I need to go really deep, that's fine. I'll probably need to be competent at databases anyway.

Attached: 1542170673244.jpg (619x519, 36K)

Learning Python in college and have a project I'm stuck on. How do I get good at Python?

This thread doesn't have to be lost, someone please answer his question.

What's the project about?

reminder that Nim is best lang

```
CarFactory theCarFactory = newCarFactory();
```

Attached: 1552695536906.gif (480x270, 1.35M)

wow, it seems I've forgotten how code tags work.
CarFactoryProxyBuilder theCarFactoryProxyBuilder = newCarFactoryProxyBuilder();

excellent meme

don't you need a proxy builder for your carfactoryproxybuilder

i'm too high for this fucking thread

weed is bad for you

Stop bumping this retarded thread, you retards.

Weed will turn you into an actual schizo.

>tfw you're learning C and you write your first makefile and you can never look back

Attached: comfy.png (331x347, 33K)

I need more programming challenges moooarrr

Attached: 1553314904149.png (3840x2160, 1.61M)

go fuck yourself nigger

first you should do those that you posted

Is there a way to make signals be sent to the parent in bash? For example, I have a bash script that runs imagemagick command in a loop and when I press ^C the script doesn't terminate but only that command.

You are using getchar (reading stdin) instead of getc. You program will crash eventually because you are not testing for EOF with your infile.
Also try to check for error when opening a file, this is a good habit. Also don't forget to fclose your files.

Attached: black women are disgusting.png (1187x757, 230K)

did you know that niggers a objectively bad at programming?

Attached: nimmas.png (1317x1652, 425K)

Get ready for that new license today javafags

I'd wrestle with her.

read that in homers voice

Jesus christ, this reddit cancer is STILL here. The fucking state of this website.
Anyway, here is the real /dpt/:
Fucking let this cancerous shit die already.

wp(f, R) ; R := (x ; y)

cringe

>animefags so butthurt that they can't get an anime OP on a PROGRAMMING thread
unironically shows just how far the standards of Jow Forums have fallen.
this kind of reeing would be instabanned back in 2011.

Most of these "animefags" are actually false flags to make anime posters look bad.

I'm going fucking crazy Jow Forums why is this code calling itself endlessly? I've been reviewing it for over an hour now and I thought this should be a simple problem.

const digital_root = num => {

return `${num}`.length > 1
? digital_root([...`${num}`].reduce((a, b) => a + b)) : num;
}

This is supposed to find the digital root of a number, basically do the following:

digital_root(456) = 4 + 5 + 6 == 15 = 1 + 5 == 6.

Add the digits up, get the result, if it's not a single digit add the answer's digits up, repeat until you find the root.

Where the fuck is the error here? It should convert the number to a string, which is converted to an array, then reduce the digits and keep doing that till it's length is equal to 1, then just return the current num.

FUCK.

>Mern stack
>No job, most of them are java ones
>Going for java
>Having a bad time because i don't really like it.

feelsbadman.

Learn to code (twice).
int digital_root(int n)
{
while (n >= 10) {
int nn;
nn = 0;
while (n > 0) {
nn += n % 10;
n /= 10;
}
n = nn;
}
return n;
}

`${num}`

>`${}`
>num is a number
>you aren't concatenating

why?

Put into a template literal makes it a string.

Oh holy fuck I figured it out. Jesus christ I didn't put the unary operator in reduce for each variable so it treats them as numbers and not strings in the array that gets passed.

int i[] = (0, 1, 2, 3, 4, 5);

Anyone have any creative ideas as to how to implement this in an IOCCC entry?

bumping for seething animefags

1..2..3

Attached: 1512155031222.jpg (948x1200, 456K)

How about you stop doing programming challenges and program something useful instead?

what those are useful

Which parts of C++ are useful for embedded stuff?

all of it
or do you mean relative to C?

The C part.

Realistically speaking what can be done in terms of new versions to improve te horrible speed of pic related without breaking every shit created with it?

Attached: 42112442.png (512x512, 12K)

anyone know a lightweight cross-platform sepples library for getting the refresh rate of a display?
SFML can't do it, SDL can kinda do it but it sucks
Would it be easier just to do it myself?

>refresh rate of a display
you mean the fps? there is a library in sdl2 that can do that

>you mean the fps?
i meant the refresh rate
>there is a library in sdl2 that can do that
i know, it sucks, please fully read posts before replying to them

precompile it

pypy way

the refresh rate is a constant value, why not look into your operating system api
here is one for win32: stackoverflow.com/questions/4110731/how-to-get-the-screen-refresh-rate

Trying to achieve something like this in Python:
[[1], [2], [3],
[1, 1], [2, 2], [3, 3],
[1, 1, 1], [2, 2, 2], [3, 3, 3]]


Is it possible with list comprehensions?
Currently I have a double for loop which does it fine, but I wanted to dick around with syntax some more.

>look into your operating system api
I was hoping just for some plug n play library, but it looks like thats not happening
Windows is easy enough, I found one for linux but it's through xorg, but that's probably as good as its gonna get

I know the basics of C and used that for a university course with TI microcontrollers and some other ancient platform whose name I can't remember. Now I'm getting into AVR for hobby projects (yes, trough arduinos, shame on me) and see objects/classes/methods being used in libraries. Just wondering if it's worth it pick up a real textbook on C++

x y f

(f ∘y) (x)

Sorry! Old thread here. >

never done python before, but would something like
[i.append(i[0]) for i in lis]

work? Idk if append returns the list. Youd also have to figure out how to do base case.

c++03