/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

lambdaladies.com/
yegor256.com/2017/02/21/say-no-to-google-recruiters.html
github.com/mk-fg/python-pulse-control
en.wikipedia.org/wiki/The_Manga_Guides
github.com/bitemyapp/learnhaskell
cs.nott.ac.uk/~pszgmh/pih.html
twitter.com/NSFWRedditImage

First for Lambda Ladies!

lambdaladies.com/

First for shitposting

If I wanted to start learning C++, where should I start??

Nth for APL.
∇ x ← affine (A b c g); v X V T M i
x←0⍴⍨⍴c⋄T←⍉A⋄M←-A
→0/⍨∧/0≤V←M+.×X←c+.×⍨⌹T+.×A÷[1]×⍨v←b-A+.×x⋄⎕←(∣i),x-←i←X×g×⌈/(V

Continuing my fun with linear types

int main()

Read a book.

>placing the function return type and the function name on the same line

>not writing in the thinking man's language

int
main(argc, argv)
int argc;
char* argv[];

>man
Sexist.

What you think, dpt?

public class apples {
public static void main(String[] args) {
tuna tunaObject = new tuna();
System.out.println(tunaObject.toMilitary());
System.out.println(tunaObject.toString());

tunaObject.setTime(13, 27, 6);
System.out.println(tunaObject.toMilitary());
System.out.println(tunaObject.toString());
}

}

public class tuna {
private int hour = 1;
private int minute = 2;
private int second = 3;

public void setTime(int hour, int minute, int second){
this.hour = 4;
this.minute = 5;
this.hour = 6;
}

public String toMilitary(){
return String.format("%02d:%02d:%02d", hour, minute, second);
}

public String toString(){
return String.format("%d:%02d:%02d %s", ((hour==0||hour==12)?12:hour%12), minute, second, (hour < 12?"AM": "PM"));
}

}

Make your objects immutable, faggot.

How important is it to know algorithms for job interviews for example being able to implement different sorting algorithms in your language of choice within a given time frame?

immutability was mistake

fn plusone(bar: i32) -> i32 {
return bar + 1;
}

yegor256.com/2017/02/21/say-no-to-google-recruiters.html

How do you return a char*?

What esoteric programming language is this?

What's the best language choice?

Rust for the low-level base, with a lisp interface on top?

>Rust for the low-level base,
C

Just say what you want to do, and someone might give a meaningful suggestion.

static char *
function(...)
{
...

>having function return types

Does anyone understand this and why it's not working?

>Running blocking pulse operations from pulse eventloop callbacks or other threads while loop is running is not supported by this python module. Supporting this would require threads or proper asyncio/twisted-like async code.
>Workaround can be to stop the loop (raise PulseLoopStop in callback or event_loop_stop() from another thread), doing whatever pulse calls synchronously and then resuming event_listen() loop.

I have this and it's not working. When I raise PulseLoopStop, it just exits (as expected I assume). Does anyone know how they exactly meant that? How can I raise that exception, do something and then call event_listen() again?

import pulsectl

pulse = pulsectl.Pulse()
def do_this(event):
raise pulsectl.PulseLoopStop
print("test")
pulse.event_listen()

pulse.event_mask_set('all')
pulse.event_callback_set(do_this)
pulse.event_listen()


This is the module I'm using for controlling PulseAudio. I'm a beginner and this has no documentation whatsoever.
github.com/mk-fg/python-pulse-control

>using a language created before memory protection was invented

Why if I input 6 for example it prints 6 two times and then 5,4,3...?
int p, n;
scanf("%d", &n);

p = 1;
while ( n > 0) {
printf("%d\n", p * n--);
}

return 0;

doesn't java let you do %p for am/pm? (and it'll be locale-aware for non-americans)

Why do people argue over C and Rust? It really doesn't make any sense.

Ikr, Rust over C is such a no-brainer...

C

>printf("%d\n", p * n--);
Don't do that

PROGRAMMING CHALLENGE

Make a £sd calculator. It must be able to add, subtract in £sd, multiply and divide by decimal fractions. Lowest coin is farthing.

So far, we have a solution in APL and J!
What other languages will present Sup Forums later?

Some Kotlin and it's fun

thinking women are also allowed, if you can find them

This is homework.

auto plusone(int bar) -> int {
return std::plus()(bar, 1);
}

>using a language for brainlets made by mentally fragile twinks
I need something stronger, more robust.

Start with C.

If you were trying to be funny, it didn't work.

How many times did you post this already?
Nobody is going to do your homework for you.

Try Pajeets for some $$$ if you're that desperate

>our code of conduct bans sexist jokes
I take it you posted your site here?

why would I use rust I'm not making a web browser

it doesnt tho user

>buffer overflow: the language
>robust
This is hysterical.

>embedded python
why do this to yourself?

Someone's frustrated he can't make any friends...

>he

My friend wants me to program for him for his UE4 game, but i have no experience with UE4. Anyone here know if blueprints is even usable to make a game? Or would I just be coding in c++ anyways?

>pointing out insecure shit in your code should be a compiler job not a linter job

It's not homework.

>auto
>-> int
for what purpose

worst day of my life? when they changed GCC development to C++

C++ is a meme

muh consistency

You can use both interchangeably, IIRC.

for the cancer.
but you aren't complaining about the explicit template initialization of a totally useless template, in this context, that returns a temporary function with known types just to not type '+'?

(I should've left the return type off..)

If I do something in blueprint, can I easily grab the code for it in c++?

hello
made a program recently?

I want this book.

Is there a good book to get started?

sure, start with k&r2 and ignore the haskell meme.

what's your experience level?

>tfw no anime programming books

Rust shitters sure do have a hard time letting go.

en.wikipedia.org/wiki/The_Manga_Guides

0

Not him, but I just started reading The C Programming Language.

Are they actually good.

I started on LYAH but both that and RWH are pretty out of date now; that was over a decade ago and AFAIU they weren't updated to new standard lib changes &c. You could still use them if you don't expect every code snippet to compile out of the box

Can't wage for stuff github.com/bitemyapp/learnhaskell except maybe Byorgey's course which IIRC was pretty good (cis194)

I don't know. I vaguely remember skimming some pages of manga guide to databases (or was it statistics or something else); it seemed pretty neato. You can definitely learn from them though obviously you don't want to use it as a substitute of your usual textbooks.

Is this okay? It seems to work, but I don't know if this endless while-loop is a good solution.
Can anyone spot something crucially wrong with this? Maybe performance issues (too much CPU usage)?

import pulsectl

def do_this(event):
events.append(event)
raise pulsectl.PulseLoopStop

def wait(pulse):
pulse.event_mask_set('all')
pulse.event_callback_set(do_this)
pulse.event_listen()

pulse = pulsectl.Pulse()

while True:
events = []
wait(pulse)
print(events)

>over a decade

over half a decade*

PI = atan(1) * 4;
ONE = tan(45 * PI / 180);

PI = atan(ONE) * FOUR;
ONE = tan(QUARTER * PI);
FOUR = floor(ONE + PI);
QUARTER = ONE / FOUR;

Apparently this is good cs.nott.ac.uk/~pszgmh/pih.html

fag

Are microkernels a sensible design?

Does it really make sense to put the memory manager in userspace?

Is Rust going to replace C and C++ as time goes on?

You cant use ONE and FOUR etc before you define them user

Almost as cryptic as modern c++

>zhe is triggered
Fuck off back to hackernews

Rust is a dead language, it's dead on arrival. Everyone pushing it is just triggered that ZHE is not in control of the ISOC++ community.

Can someone explain to me how scope works in C++? This is a problem I had with GLM due to stupidity, but it seems like weird behavior to me.
I had:
void somefunction(){
glm::mat4 t;
t = glm::translate(t, glm::vec3(5.0f, 5.0f, 0.0f));
std::cout

What's wrong with it compared to C or C++?

What kind of brainlet language are you using?

>people would rather shit on other people for using another language instead of discussing what they're actually working on

Thanks user

Sweet, I might pick up Databases and Calculus, a refresher is always good, especially when I remember nothing whatsoever.

why not
double pi() {
double x, y;
long int n = 666980085;
int q = 0;
for (long int i = 0; i < n; ++i) {
x = (double)std::rand() / RAND_MAX;
y = (double)std::rand() / RAND_MAX;
if (pow(x, 2) + pow(y, 2) < 1) {
q++;
}
}
return 4 * (double)q / n;
}

I don't see the problem here. You're declaring t inside otherfunction.

>666980085

glm::mat4 t = glm::translate(t, glm::vec3(0.0f, 0.0f, 0.0f));

how is that 't' for translate getting there, other function?

I'm trying to guess how to use jsoup to download chinese cartoon titties from some booru.

How often is batch mode used in actual projects?

Worth reading?

no, learn Haskell instead

But I am also using it to initialize itself when I give it to glm::translate, which shouldn't work. And the contents from the 't' which should have been gone once somefunction was done were instead apparently spilled over.

It should have been from nowhere, but see above.

Codeacademy any good?

You're hitting uninitialized memory.
It just happens to be the case that the memory for the new t is the memory which held the old t.