/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread:

Attached: bowsette_peach_yuri.jpg (1200x3187, 1.34M)

Other urls found in this thread:

stackoverflow.com/questions/12905999/python-dict-how-to-create-key-or-append-an-element-to-key
pythoncentral.io/one-line-if-statement-in-python-ternary-conditional-operator/
twitter.com/SFWRedditImages

nth for install shen

>inb4 that clueless boomer who calls Bowsette as Bowserette

bumping this

It's Super Crown Bowser, fuck off.

I’m on mobile so I can’t see the code. But by unique in sets, u mean unique elements between 2 sets? Cause sets are already unique

Because they're minorities, user...

Attached: 1531433542511.jpg (213x296, 23K)

I'm thinking abou joining this week's #WeeklyGameJam. Theme is "glitch" which was the theme for some js13k a couple years ago that I missed but would have loved to take part in. Sadly it seems I won't have the time.

Would have made a tiny RPG with a "glitch" to execute "arbitrary code" (just not arbitrary, but from a set of instructions) as an hommage to the original Zelda game where you could actually execute arbitrary code. It would be the only way to win as well.

Maybe someone likes the idea and picks it up.

How do you all get better at programming and understanding things? I feel so loss trying to implement algorithms for class. No matter how much I look up and "understand" or break down what I need to do on paper I just can't figure out how to implement certain aspects of them. I don't want to just look at other people's code, but I feel like I'll have to soon.

Attached: 1525354073865.png (600x400, 250K)

Why aren't unions used more often? I find them to be excellent for swapping out temporary buffers without allocating

It's Kuppa Hime ffs

I meant set in a more general way, like sets of values, not necessarily unique, contained in an iterable object.
And then I want to return the elements that only appear once among all the sets(iterables)

go through clrs

So why aren't you coding in Nim right now?

FOR FUCKS SAKE YOU FUCKING NORMIE KIDS HAVE TO GO BACK TO INSTAGRAM OR WHEREVER YOU CAME FROM AND STAY THERE
TOADETTE WITH THE SUPER CROWN IS PEACHETTE
BOWSER WITH THE SUPER CROWN IS WOULD BE PEACHER
BOWSETTE WOULD BE BOWSER+TOADETTE
WHY ARE YOU SO FUCKING RETARDED WHY DO YOU HAVE TO SHIT UP THE INTERNET WITH YOUR RETARDATION
I JUST WANT THE TIMES BACK WHEN THERE WERE PLACES ON THE INTERNET WITHOUT BRAINDEAD NPC INSECRSIS THAT CLING TO EVERY BULLSHIT FAD WITHOUT THOUGHT AND THEN JUST DROPPING IT FOR THE NEXT ONE WHEN ITS AVAILABLE
WHY CANT WE HAVE NICE THINGS

>find unique elements
Sort your list and iterate over it. Is current element the same as previous? Then the current element is not unique.

When I'm stuck with a problem I usually break it down into small exercises and try to solve them is as many different ways as I can. Sometimes a solution pops up that solves the issue of the bigger problem. That's really just educational, though, takes too much time. It's fun anyways.

>Not to say that there isnt a general trend, just that its much worse in software
????????????????????
Software is having that LESS because it's already swarmed with indians and chinese doing code monkey work, while operatively speaking the software design is already oversaturated with people that have been studying it for decades during the silver ages of x86
Lowering the entrance bar more isn't going to do any more damage than it already has been done

in case this isn't pasta, -ette is just a suffix meaning "small" which means for women, ie cigar vs cigarette.

How do I learn to write a linker script?

Wait, fags are female? I don't understand that whole gender thing.

>never programmed in my life
>helloworld.c
feelsgoodman

Attached: yay.png (252x241, 105K)

yes, fags were originally made and marketed towards women. Granted men way back still rolled and smoked their own.

Is there any any to write this fragment shorter/more idiomatic?
I got a bunch of these all over my code.

if 'bar' in foo:
foo['bar'].append('stuff')
else:
foo['bar'] = ['stuff']

that's python3 btw

That final panel
>tfw you can't compete.

stackoverflow.com/questions/12905999/python-dict-how-to-create-key-or-append-an-element-to-key

are you looking for this?
pythoncentral.io/one-line-if-statement-in-python-ternary-conditional-operator/

This is it. Thanks.

unions are used extensively in code like the linux kernel to avoid violating strict aliasing rules

there's literally nothing wrong with this
only faggots chose syntactic sugar over raw speed and power.

Because you can make a buffer pointer point to any type you want just by saying it's so. The only real point is either 1) if you want to document how your API that accepts only a finite number of types, or 2) you're doing a coercion that breaks strict aliasing rules and you need the compiler not to fuck you over.

This is what I want to do

Attached: hUq9n.jpg (200x193, 6K)

C Hash is sorta neat innit

I just gave you the fucking answer, use your brain to realize how to apply it

>linux kernel
>caring about c standard
top kek

>calculate the difference set between the first two sets
>take that difference set and calculate the difference between that and the next set
>repeat until you're out of sets

>not worrying about when your compiler is going to pull the rug out from under you

Now build a program that checks if a string is a palindrome. (Hint: strtok) This can help you get started with the C standard lib, chars and strings, strcmp vs ==, get/puts vs scanf/printf and more.

Attached: ayo.jpg (680x598, 54K)

It's shorter but it relies on lists being mutable. It also does only one query into the dictionary, if that's of any importance.
foo.setdefault('bar', []).append('stuff')

Is brainfuck interpreter good C project for someone wanting to get familiar with C, having decent (work) experience in higher level languages?

what do
$ cat main.cr
puts "Hello World!"
$ crystal build --link-flags="-static" main.cr
/usr/bin/ld: cannot find -lpcre (this usually means you need to install the development package for libpcre)
/usr/bin/ld: cannot find -lgc (this usually means you need to install the development package for libgc)
/usr/bin/ld: cannot find -levent (this usually means you need to install the development package for libevent)
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `cc "${@}" -o '/home/owner/main' -static -rdynamic -lpcre -lgc -lpthread /usr/lib/crystal/ext/libcrystal.a -levent -lrt -ldl -L/usr/lib -L/usr/local/lib`
$ gcc -lpcre
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../lib/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status
$ ldconfig -p | grep "libpcre.so "
libpcre.so (libc6,x86-64) => /usr/lib/libpcre.so
libpcre.so (libc6) => /usr/lib32/libpcre.so
$

I forget to specify that the program should intake arguments as "palindrome("string")", so you'll have to figure out how to break up the input to get your string value by itself.

it literally tells you, you brain-dead mongoloid.

but I have the library installed
$ ld -lnotexistinglibrary
ld: cannot find -lnotexistinglibrary
$ ld -lpcre
ld: warning: cannot find entry symbol _start; not setting start address
$

sorry

caring about the compiler and caring about the c standard are two very different things. linux is not even compatible with anything else than gcc.

please stop reinducing my desires to be a little hirl thanks

Attached: 1537596328640-g.jpg (1280x720, 65K)

I program for a living, and I work on my own projects outside of work, for me at least, it feels like the questions I am faced with are fundamentally different than just "whats the best algorithm" or "can I solve this weird math problem".

0 The user UX and product are the bottom line, so that usually my starting place. From there I derive my data types, the backend's api, and how the data is ultimately stored. I meet a lot of programmers who seem to think of the data or their underlying state as their starting place and then they get really protective about it. Seems really problematic to me. Those kinds of people just seem to keep transforming data all the time, but never transforming it to anything closer to their goal.

1 Solving math problems and making algorithms are "small" problems. By that I mean the entire end result is something that is expressed in a singular body of code. In practice, problems are "big", as in, the solution is going to get expressed in small places all over a huge code base. Its also "big" in the sense that you will find out if you were successful in 6 months as the project matures, and not immediately when you just see if the algorithm works or not.

2 Social questions are a lot more important. Managers and designers change their mind about what they want. So building things in a way that they could be easily changed is pretty important. Building something super great that cant be changed is pretty bad in practice. Other important social questions include how to write code that is going to gel well with other developers. Like if you come up with a pretty good and standard approach to something, but your peers cant understand what you are doing, or they arent willing to read your documentation, then you arent doing your boss or your customers any favors.

So maybe thats different from your question of "how can I self improve". Im just saying these are the dimensions I think developers will have to self-improve.

give me reasons to learn C++ over other oop's.

Take your pills, Alice, repression is the gateway to eternal self-hatred.

Adam and Eve not Adam and Steve ok

Haskell.

name my band

Attached: systemprogramming.png (1256x670, 1.14M)

Andrei and the shitlangs.

Heard a joke the other day
"D: a language which has more compilers than users"

Got my lol on at that, not gunna lie

Great Ones and the Pajeets

Bjarne, unknown, Andrei, Rob

Doesn't look like John and Paul are on speaking terms

Being asked to make a currency converter for a programming class. Exchanging pounds into Euros at a rate of 1.19. And if a value under £50 is entered there is a 3% commission. I realise this code is massively shit but this is how we were told to do it. My question is how can I force the results to be 2 decimal places? I cannot for the life of me have the commission in the final statement round to 2 decimals

Attached: Noob.jpg (1861x691, 119K)

Daily reminder ....

If (hasMassiveTits && !hasACock) {
auto jizz = blowLoadOnTits();
} else {
gas();
}

if you were using a good language you could do %.2f

what will be the next thing in AI?
I know machine learning just took off commercially but the amount of data required is staggering, not to mention being hard to work with

>tfw short pinkie finger on my left hand
was i forever doomed to be an inefficient programmer?

>the amount of data required is staggering
why do you think every website and application wants to get as much data as it can from you and then some?

you can press CTRL without using any fingers on most keyboards
you can press Shift with your right hand
other left-side keys are not essential

i see three PhD and one undergraduate (probably never attended college at all). amusingly, you could tell which one is the plt illiterate by looking at the programming languages they represent.

I have always pressed ctrl with the side of my palm under pinkie

The "next thing" in AI is something "useful" where the data is easy to be gathered or generated.
If you're a researcher, you don't care about how good your dataset is, as long as it's an appropriate facsimile to a real dataset.
Just think about something that AI hasn't done yet, and consider whether the dataset is easy to generate or procure.
No, Mechanical Turk is not easy to generate or procure.

fuck i meant right hand

pressing Ctrl+A or Ctrl+Z like this is really awkward

Taking oystergene is jewish propaganda to make white race down

>one undergraduate (probably never attended college at all).
which one is it?

What?

Attached: gopherlet.png (300x441, 22K)

Are you implying something about Commander Pike, huh?

>type mismatch in function call
>100 line error from compiler
templates were a mistake

man the music recommendations based on what track you're listening to on youtube music is scary good

nothing
AI isn't a field, it doesn't exist
the recent "advances in AI" where advances in data collection and parallel computing

I don't understand the fourth panel. Is Bowsette squatting down to take a shit?

look after a mechanical keyboard with ctrl placed for the thumb (Diverge 3, keyboardio 01, ergodox ez, kinesis advantage, ...)

Attached: 91Bx7i7t4-L._SL1500_.jpg (1500x769, 283K)

If you look at typing competitions, lots of the competitors don't use their pinkies at all because they're too slow and awkward. Just start sliding your hand over more and using your ring finger.

why is bowsette not a reptile?
this is so retarded

Only like one of those lines matters, the rest is your compiler being retarded

seriously tho, whats the deal with brainded error messages compiling c++?

I'm trying to make a damage calculator for a damage in google spreadsheets, but it doesn't seem to like 3 greater then/less than arguments. What am I doing wrong here?

=if(0.4*B57>(B48>0.125*B57),(-0.8/121*(B57/B48-8)^2+0.9)*B57,"FALSE")

B57=317
B48=40

In my entire life I think I've only managed to compile less than 5 C projects made by individuals (not large teams).

Why is autotools so bad?

Standard build systems and standard dependency managers are by far the most useful features that newer languages have imo.

Your program may as well not exist if I can't execute it.

itt we being edgy and contrarian

nt is undoubtedly the best core out there
change my mind

>change my mind
Why should I?

not him, but why strtok?
int ispalindrome(char *word)
{
int length = strlen(word) - 1;
int compare = 0;
int ispalindrome = 0;

while(compare = length) {
ispalindrome = 1;
}
return ispalindrome;
}

Compilers are retarded

Also C++ semantics are retarded because of conversions and overload resolution. If it weren't for those C++ template errors would be no worst than Rust generic errors.

That variable really shouldn't be called `length`, user. Similarly what the shit is `compare`? That's all just wrong. I hate code like this. Naming is hard, but at least try. Faggot.

New to programming, what math topics is important to learn? Assuming here the person hasn't finished high school maths.

None, just logic

if you can understand turing machine and lambda calculus, then you are good.

>hasn't finished high school maths
>>>/global/rules/2

Discrete maths, linear algebra. Maybe just the latter.

change
>if(0.4*B57>(B48>0.125*B57),
to
>if(and(0.4*B57>B48, B48>0.125*B57),

you can't chain relational operators like this
assume x1, x2, x3 are of type NUMBER, and that relational operator > takes two NUMBERS and returns BOOL
x1>x2>x3 => (x1>x2)>x3
x1, x2, x3 are of type NUMBER, but (x1>x2) is of type BOOL
so it compares BOOL to NUMBER, even thought you gave three values of type NUMBER; apparently spreadsheets doesn't like that, and for good reason

computer science ≠ programming