/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Other urls found in this thread:

bloomberg.com/news/articles/2017-04-03/new-h-1b-guidelines-crack-down-on-computer-programmer-jobs
github.com/ksimka/go-is-not-good
twitter.com/SFWRedditImages

C wasn't great
ML would have been okay
or maybe LISP too, who knows

Currently banging user's mom

how can i remove all occurrences of '0x' from a string using python? e.g. if it was 0abx i'd want 0abx, but if it was 0xab i'd want ab. not real familiar with regex

nth for reipmlementing Haskell in Scala

Haskell is creaking at the seams. We need a language with dependent types and without unsafe functions.

I'm a shit programmer Sup Forums.

Scala is unusable as Haskell
Scala is more unusable as anything else though

str.replace("0x", "")

I don't even know Python lel.

Repost and define what you mean by "split the tuple".

Some example inputs and expected outputs would be nice too.

>you heard her laugh
TIME TO KILL MYSELF

Don't do it user, you have so much to live for!

...

I'm good at C++ and wasn't bullied at all.

If I print the List I get
((throwing,a),1)
((competitive,basketball),2)
((which,two),1)
((regulated,variations),1)
((team,with),1)
((be,advanced),1)
((game,wins),1)
((by,bouncing),1)
((disruptive,physical),1)
((through,time),1)
((foot,high),1)
((not,permitted),1)
((exceedingly,popular),1)
((indoor,sport),1)
((offensive,and),1)
((developed,to),1)
((points,are),1)
((how,the),1)
((at,the),1)
...

What I want to do is format the List into a triple touple with(String,String,Int) instead of the double touple with a nester touple of ((String,String),Int))

theList.map { case ((word1, word2), count) => (word1, word2, count) }

def p():
print "p"

def r():
print "r"

def i():
print "i"

def n():
print "n"

def t():
print "t"

p()
r()
i()
n()
t()

Why would you do this?

>not using a macro to generate those functions

DOGGO

print ("""
P
R
I
N
T
""")

Hi /dpt/, I'm working on a university assignment in C, which contains the following pieces of code.
data* func(){
data* all_data[100] = {NULL};
...
return all_data;
}

This function raises a compilation warning to do with returning the address of a local variable.
I'm aware that all_data is my array name, but an array head is just a pointer, so why isn't returning it okay? My program runs just perfectly. Should I cast it to (data**) before returning it or something? I just want to silence the warning.

The array is only valid for the block it's defined in. So as soon as you leave the function, the pointer will point to invalid memory.

This is not true. I return the pointer and everything works just fine. The pointers the array is populated with are generated via malloc so they also stay the same.

I'm not sure but unless you use a different storage specifier, then your all_data will be overwritten on the stack after another function call. Pass all_data pointer to func() to avoid this or use malloc to reservere memory on the heap instead of the stack.

>This is not true. I return the pointer and everything works just fine.
That doesn't mean that it's not undefined behaviour. Try calling the func, then some other function, then use the result.
>The pointers the array is populated with are generated via malloc so they also stay the same.
That doesn't matter. The array itself is local to the function.
Allocate that using malloc.

Try doing data* all_data = (data*) malloc(sizeof(data)*100).

I have done. My entire 600 line project relies upon this one function working at the start, and it does. All the data I read in using func (it's not actually called that) is stored properly and all calculations done with it work exactly as expected. I even have a set of given outputs that I've tested against which are identical.

I think this was what I was after. I'll try it and post again if it doesn't help. If not, thanks.

im ok at ruby and i was bullied every year, which made me stronk

just stopping by for my monthly shitpost quota
still haven't got a captcha without "calle"

There is a reason you are being given a warning. The all_data array is located on the stack, and so when the function is returned, subsequent function calls are allowed to write over it. Returning a pointer to it only ensures that whatever code is using that buffer cannot be guaranteed consistency.

Do this:
data **all_data = calloc(100, sizeof(data*));

Is there a reason besides bad luck that horrible Python got picked up by academia/sci, while best girl Ruby got picked up by douchey brogrammers and Rails pajeets?

One was stuck in Japan, the other Yurop

This is why C is not for pajeets.

Every time I see anyone calling others a "pajeet" I automatically know:
1. user is an underage fuckwit
2. Has no real argument
3. Failure in life

you're allocating all_data in the stack and it is deleted after the function returns.

Thanks alot user.

can pajeet make a sum of all primes below 2000000 program?

>C is not for pajeets
goddamn i'm sick of this meme. pajeet is literally all over every popular language. there are C pajeets, C++ pajeets, (most famously) java pajeets, ruby pajeets,....
the only languages still untouched by poo hands are lisp, FP languages, Rust

bloomberg.com/news/articles/2017-04-03/new-h-1b-guidelines-crack-down-on-computer-programmer-jobs

cont...
I took a random screenshot of C solutions to a 'hard' hackerrank bit manipulation problem.
what do you notice?

>tfw university professor teaches C
>100% pajeet with deep, strong and profound indian accent
>looks and smells like shit
>"C is the best language, all other languages are based on C"
And Sup Forums makes fun of pajeets. I wonder if most Sup Forums are actually self loathing pajeets

Does anyone know how to make a foobar plugin in 2017 visual studio?
I can't seem to find the right information to get anything to work here.

hackerrank's made for pajeets anyways. look at who makes all the questions

>AndrewMiT
>india
top lel. On a side note, how will C pajeets ever recover?

>getting this triggered "pajeet"
wew

You don't need to use regex for that.

as I said, there doesn't seem to be many Indian functional programmers. even hobbyists. Pajeets gravitate towards whatever is in demand / marketable.

b t f o

I bet there are no Mathematica pajeets

>tfw just signed up in pajeetrank
Add me up, Sup Forums chan @Culpreet_Pajeet

who does use mathematica when matlab is out there?

>implying a symbolic mathematics environment competes with a numerical analysis package

How many people need to submit for a language before they release a leaderboard? Seems like a good way to curb my autism.

I want to port Opera to MIPS32. The leaked 12.15 source code has already been ported to ARM, and I'm assuming ARM ASM will be easier to learn than x86. So my main question is will I be able to learn MIPS ASM and just what I need of ARM ASM to port it to MIPS, or will it be more viable to just learn both ARM and MIPS ASM?

People with an actual brain lmao.
>yfw Mathematica is excellent for what it does while Matlab has dozens of better alternatives

>is a chen poster
>has a brain
choose one

>Every time I see anyone calling others a "pajeet" I automatically know
I make broad generalizations about broad generalizations.

>doesn't like Chen
Confirmed brainlet. All past, present and future opinions discarded.

>To complete this challenge, you must save a line of input from stdin to a variable, print Hello, World. on a single line, and finally print the value of your variable on a second line.
>import std.stdio;

void main(string[] args)
{
string inputString = readln();
writeln("Hello World.");
writeln(inputString);
}
>Wrong answer
Well fuck you too

>Frogposting
D(ead)lang users confirmed for cancerous, yet again.

Might need a chomp after readln
t. cancerous meme poster

Are you offended by my white supremacist frog?

Yes, you necrophiliacs really are cancerous meme posters.

No no no, I was calling you the cancerous meme poster
Easy mistake to make when you're retarded

>cancerous
He posted D, not C

You clearly said
>t. cancerous meme poster
How is that not an admission of guilt?

Because it's not

exactly

>print "Hello, World." on a single line
>prints "Hello World." instead
even pajeets can follow directions better than you

You missed
>and finally print the value of your variable on a second line.
>second line

This

I didn't miss that, mouth-breather.
It isn't the issue.

>I didn't miss that, mouth-breather.
Sure you didn't. Any other reason you are so angry? :^)

you need to improve your shitposting game. Here's a complimentary (You), sport.

top kek

I except your defeat

you're tryin too hard m80. Now you don't even deserve a (You).

>dozens of better alternatives
which ones? octave? scilab? python? heh

kys pajeet lover

>heh

>final week of first programming class of comp sci where there's anything due that's not the final
>actually look through the discussion section (needed for participation credit)
>there's like four people posting there

I wonder if this class cleared out. It wasn't a hard class at all.

Participation credit is what? 5%. Only people who do it are those who want an A+ instead of A.

yeah you'd be surprised at how many people can't even comprehend simple loops, conditionals, recursion, etc...

>write a few sentences once per week
>get half a letter grade, guaranteed

I don't imagine that most people who skip that are getting As. Certainly, the B and C students need it.


I can only see it as lack of effort/intimidation. If you can't manage-

if (milk > 0)
Drink;
else
Place on grocery list;

while (clothesonbed = true){
fold clothes;
place in drawer;
}

-how do you manage to live?

Programming a raycaster in Javascript for fun.

Other people have done it, but I'm trying to avoid simply following a tutorial. Working through the geometry on my own.

I have the basics working (a 2D grid the camera can move around), and differently colored walls appear in the "order" they should in the first person ("3D") view. So, I have a room you can walk around in, and know where you are. The wall height is still messed up.

It's a neat project.

Have you read your SICP today?

People are just lazy. Anybody can figure out loops and conditionals. I'm living proof of this.

>Go BTFO
github.com/ksimka/go-is-not-good

Press F for respect

Nope.

tech/l/oli/g/y

>no OOP
But that's not a bad thing.

i knew that from the moment it came out

flags, globals, inheritance

Anyone here use R?

Made a Django App.

Behind the scenes it scrapes car selling web sites and their prices. Then runs some machine learning algorithms over the data and generatimg rules to predict prices.
In thr web interface prices are compared and cars with prices too low can be found.

I'm evaluatimg now if I should use Heroku or AWS or somethimg different.

(All for my portfolio, it's also a lot of fun).

What library are you using to scrape the data?

Better would be:
Anyone here use R? Here's my problem ...

a

R is garbage. Found your problem.

lxml for the smaller sites.
The bigger ones have API's.