/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1539861378163.jpg (2428x1720, 1.02M)

Other urls found in this thread:

geeksforgeeks.org/tarjan-algorithm-find-strongly-connected-components/
boost.org/doc/libs/1_65_0/libs/graph/doc/strong_components.html
urn-lang.com/
fennel-lang.org/
repl.it/repls/SuburbanMinorRecords
catb.org/~esr/faqs/smart-questions.html
en.wikipedia.org/wiki/Probable_prime
twitter.com/SFWRedditVideos

FIRST FOR LUA

how many hours do you spend in front of the computer?

Attached: 1553694742945s.jpg (226x249, 6K)

strongest

Attached: luabutts.jpg (573x892, 113K)

n^th for c

What a beautiful programming language :^)
She is literally the moon :^)

Attached: 573352-istock-892604000.jpg (1100x616, 43K)

All of them

JavaScript rocks!

Attached: js-rocks.png (1000x494, 368K)

will this be a comfy /dpt/
guess not

Attached: 1549107746765.jpg (227x222, 13K)

Write this JS closure in your language
const genID = (i => () => i++)(0)

I want to Lisp or Haskell. Suggestions?

both they're quite different

My interests are primarily learning more about mathematics in an interactive way. I hated math growing up, but after I discovered programming, I was able to learn concepts much more quickly, because I was able to actually see it in practice. I also would like to build neat things with a functional paradigm, maybe games, purely to develop myself as a programmer (I don’t care about efficiency or whether it would be better to do it in C++ or something)

(define genID ((lambda (i) (lambda () (begin (set! i (1+ i)) i))) 0))

both sort of do that different ways
for lisp look at SICP
for haskell it's all category theory and plt memes

First for Python!

You don't even need to use the begin form here.

let mut gen_id = (|mut i| move || { i += 1; i })(0);

you're a glow in the dark nigger
int genID() { static int i = 0; return i++; };

Attached: 1553022396361[1].jpg (490x578, 54K)

thanks, didn't know that

William Kennedy telling me that in go, behind the scenes, when you're defining your receiver as as pointer, then you have this kind of conversion:
func (d *Data) foo(){ ... }
is converted to:
(*Data).foo(&d)

I don't get, why do you have to dereference the class via (*Data). Why can't golang just call it as Data.foo(&d).
I just can't think of any explanation but mr Kennedy is simply mistaken.

Taking a little break from programming and sketching out some UI changes I would like to make. Adding some bevels and other 90s shading here and there, and trying to align everything nicely.
I usually just go straight to C++ when I want to make UI changes, so this is a bit different from what I'm used to. Porting GCC has been really exhausting so this is a nice change of pace.

Attached: Screenshot at 2019-03-27 18-51-26.png (1920x1080, 658K)

I need to implement Tarjan's SCC algorithm and a couple of related things, in sepples, is there a decent library that can help (should I maybe use boost.graph or something) or is it easiest to just write it by hand?

what for? some programming competition?

geeksforgeeks.org/tarjan-algorithm-find-strongly-connected-components/

still understanding the different python datamodels. also implementing some classes(writing on my own some examples, e.g. cinema and a bank). maybe a bit numpy(linalg)

>for school
make the graph by hand since it won't have any shit you don't need.
>for work
make the graph by hand since it won't have any shit you don't need.
>it's slow
look at a graph library's implementation and realize that they're probably actually using adjacency matrices or some shit that actually fit in memory

boost.org/doc/libs/1_65_0/libs/graph/doc/strong_components.html
do it by hand if you want to learn how to do it

does 'lambda' imply 'begin' or is that only 'defun' in common lisp?

Doesn't work if you want to generate 2 different Id sequinces

Is one more or less bloated or easy to get started with?

did you saw the static keyword?
int a = genID(); // 0
int b = genID(); // 1

urn-lang.com/
fennel-lang.org/

Attached: Konata-is-Hyped.jpg (1600x1000, 291K)

God damn I'm getting tired of this shit, once again I mistyped a member name in Javascript, and no point of linting and shit told me about it, instead it silently returned undefined, which then silently got converted to false due to binary operators, which then made the rest of the program work, except this one small part didn't work as expected and it took me an hour to figure out why. Im starting to think I'm not intelligent enough for js, I need a type system to hold my hand.

I just ordered a copy of K&R yesterday.

What am I in for?

Attached: 佐藤日向_092.jpg (1080x1080, 71K)

I dunno about lisp but you can use stack to install haskell and cabal

>What am I in for?

2019 - 50. C is obsolete programming language for the programming techniques of the past.

fag lispers OUT. lua's natural pascal syntax is beautiful the way it is.

Y U NO WURK

class Dice:
def __init__(self, sides):
self.sides = sides

d1 = Dice()
d1.sides = int(input("How many sides?"))

print(d1.sides)

I have spent every waking hour in front of the computer today and I indent to keep going.
Only break was the 30 min trip between home, work and then back home.

you need to add a default constructor
if you define your own constructor the default one is no longer provided

Because you didn't give it a value for sides.

>programming techniques of the past.
What did he mean by this?

d1 = Dice(int(input("How many sides?")))

you declared sides in the constructor so you have to pass it when you instantiate Dice

6/6 hours so far. My gf is coming over to play some PS4 soon, so I'll get some variety in my day!

he thinks evolution can't go backwards

Does she have big tits?

Yeah, it's that way for many special forms in Scheme.

Wow, that Photoshop clone you coded is beautiful, keep going user!

Please be respectful of user's girlfriend user.

writing a package manager Jow Forums, ant tips?
how can I make local "~/" binaries pathed to usage with bash?

I meant no disrespect

are you joking? that's GIMP

:P
......hmm. Maybe I should make a painting app actually. I'll put that on my todo list, thanks user!

i thought i was doing this for d1.sides. the example i am referencing did it like this.

this is still causing the window to immediately close upon opening.

does your gf have a feminine bepis?

Attached: fug1.jpg (457x332, 34K)

>this is still causing the window to immediately close upon opening.
?
the code is correct. run in the terminal

but it's not asking me to input anything.

his(her) gf(female) has a penis (female)?

Attached: 1550168108341.jpg (225x350, 30K)

are you using python 3? 2.7?
repl.it/repls/SuburbanMinorRecords

3.7

i was using 2.7 but decided to get with the times

does it work now?

huh... i take one line of whitespace out and it works.

but thank you. ive been ree'ing over this for too long now

Thanks for your visit, and I hope to see you soon!
Best regards,
Tim

Bump

gimp 2.10 is sexy as fuck

Attached: gimp-2.10.jpg (1916x1041, 234K)

why is regex in sepples broken

see this in codebase rage/no?
var ahead = inputSafe[index++];

>Taking a little break from programming and sketching out some UI changes I would like to make.
gorgeous icons desu, but make them vectors so they can be displayed just as beautifully at say 8192*8192 and 48*48

no problem imo

catb.org/~esr/faqs/smart-questions.html

depends on the context, is more explicit to use
inputSafe[index]
index++;

I have a question:

I am trying to sample card combinations for 2 players. Each of those card combinations has a different probability of being sampled and once a card combination was sampled for player 1, player 2 can not be dealt the same combination.

For example:
player1: [c0: 0.5, c1: 0.1, c2: 0.2, c3: 0.1]
player2: [c0: 0.2, c1: 0.2, c2: 0.3, c3: 0.1]

Once c0 was sampled for player 1, the probability of c0 for player 2 changes to 0.

Is there a fast way to do this? Right now I have several O(n) steps, n being the number of card combinations.

Thanks user! That's not a bad idea, although I have zero experience drawing with vectors, but how hard can it be?
That said, I don't really have any vector drawing primitives in my OS right now so I'm gonna put this on the TODO list, but I will definitely get around to it eventually, as it would make a great reason to improve my painting code.
I wonder what format would be good, maybe SVG? That would give me an excuse to start working on a DOM tree module.. could go places.

Have they fixed the problem where you cant scroll smoothly yet? That shit made it impossible to use.

The language is C++, but I can also implement my own language independant algorithms or data structures.

is c0 a card or a combination?
any reasone you can't just choose one for p2 and retry if p1 already has it?

the way windows does it is just have a 256x256 version for high res display.

c0 is a holdem card combination of 2 cards, for example A of clubs + A of diamonds.

I can also sample 2 individual cards if that is faster.

I can just sample a combination for player 2 and retry if it's the same, but in the end that might be slower, I don't know.

Let's say I have
std::vector constructHugeVector()
{
std::vector ret;
//here we add a gazillion elements to ret
return ret;
}

std::vector myHugeVector = constructHugeVector();

Is my understanding correct that ret will be copied after constructHugeVector() returns? And that if I do return std::move(ret); instead, it won't be copied and instead myHugeVector will directly "take ownership" of the memory assigned to ret?

>I can also sample 2 individual cards if that is faster.
However the user does input probabilities for the combinations, so I would have to translate them to probabilities for each individual card.
The problem with that would be, that the probability for the second card changes depending on the first card that was sampled.

You are correct on both counts.

That makes sense. I actually quite like the look of "low-DPI" user interfaces with 16x16 and 32x32 as the staple icon sizes. There's something so crisp about it

Attached: windows95_9.gif (640x480, 17K)

>I have zero experience drawing with vectors, but how hard can it be?
me neither; there should be tools to convert your raster images to vectors
>I don't really have any vector drawing primitives in my OS
no priority on this tbqh as you can just export different sizes of it for whatever your use is (bigger sizes for desktop icons, smaller ones for window interfaces, shit like that)
>I wonder what format would be good
I do not know enough about vector graphics outside of SVG

I don't know what you mean; I've never used photoshop
for gross scrolling I use the scroll wheel which is usually enough depending on what my zoom level is. for fine adjustements, I use a mouse and the scroll bar itself

In theory, yes, in practice I can see the compiler figuring that you want to move and eliding the copy. Not in general, but for types from the standard library where it knows their copy constructors don't do anything special.

how do the probabilities change? if a card is taken, does it's probability get divided up among the rest of the cards?

Alright thanks anons

Also just noticed I obviously have an out of place template parameter in my call to constructHugeVector() for no reason but you understand what I meant so

You have 10 seconds to prove that NP != P.

You should be able to solve this.

Attached: solve_this.png (244x275, 77K)

In NP you have like many turing machines in parallel and shieet, right? Or they're like random which is equivalent and shieeeet? But in P whitey only allows one machine and it can't be random, gotta do exactly what massah says

So all em NP machines and shiet obviously can do more than the P one, see watcham saying?

starting when

>if a card is taken, does it's probability get divided up among the rest of the cards?

Yes.

aah, I never understood the solution until now.
Thank you user!

How can I go about writing a method like BigInteger probableprime myself in java?
I opened the source code and looks complicated desu

Attached: m3glb7edoumezzblhi9z.gif (220x307, 219K)

What is the point of using C++ if you're going to write spectacularly inefficient code with it?

it is complicated
en.wikipedia.org/wiki/Probable_prime

Most people think that P != NP, but that is not really a proof.
Also nondeterministic turin machines could be faster that deterministic ones and P could still be equal to NP. You just have to find a polynomial time algorithm, it can have a much higher constant factor and it would be ok.

None. In the industry, you're supposed to switch to Sepples when you want something more performant than a Python, prototype. And you won't do it in C because it's a closed-source project and you wanna control your teammates' idiocy by shoving them public interfaces everywhere.

>implying turing machines are the best you can do
>implying we won't be programming on hypercomputers

idk if this is sarcasm or not
I just want someone to help me with my homework
I did the rest so either way i get partial points..

Attached: 1553133921919.png (231x234, 4K)

Present a mathematical model of a hypercomputer.
When Turing created the turing machine there were no physical computers, it was just a model. So far we haven't even find stronger theoretical models, we aren't even talking about implementation.