/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

ecere.ca/
pandas.pydata.org/pandas-docs/stable/indexing.html
twitter.com/SFWRedditGifs

Dear /dpt/,

What are the programming languages you'd say you know well? Something you'd put on your resume, and you'd would feel comfortable doing the interview exercises in

C

Proper animu macro

Ada, C, Verilog

Why must you people act like elitists when it comes to langs?

Python

Re-implementing Lisp in Haskell.

>What are the programming languages you'd say you know well? Something you'd put on your resume, and you'd would feel comfortable doing the interview exercises in
C, Java, C#, PHP, ASM

C, C++, Lisp

>follow instructions in book
>"Hello world!" app wont run
>didn't write a single line, just chose empty activity in Android IDE, emulating Marshmallow on a Nexus 6P

please help.

C, OCaml, Python, probably Java too

Holy shit why is nobody talking about this esoteric language!
ecere.ca/
>C ABI
>cross platform(desktop platforms, android, js trough emscripten)
>open sores
>OOP for the simple minded

OCaml, C & C#

Can anyone point me in the direction of a tutorial that will help me parse this data using Python pandas?

Why not just use C++ and pretend you have C with classes at that point?

C, C++, OCaml and Matlab

>convert to csv
>import pandas as pd
>pd.read_csv('filename')

>C ABI without shitty fully retarted sepples name mangling
>actually designed unlike sepples
>no templates shitting up the lang
Looks way better than sepples.

How does it feel knowing there's no job lined up for you once your current companies kicks you out?

Is this impressive?

Most new langs have a c abi, are OS and are multi-plat.

Right, I've gotten that far.

The issue I'm having is getting the data out of a cell with specific parameters. This data is airplane performance data, where the columns represent weight and the rows represent altitude. So at 240000kg and 21,000ft the plane is burning 8420 kg/hr and flying 402 kts. I'm trying to figure out how I can feed pandas and weight and an altitude to get my fuel burn and speed.

bretty gud, actually.
I'll be laughing at you cucks when I have thousands of more job opportunities than you could ever wish for.

Java is the only correct answer GOD you are all such plebs

Even if I knew Java I would still not put it on my resume because I'd be too embarrassed

>>no templates shitting up the lang
Just because C++ gave them a stigma doesnt mean theyre bad.
Templates are great.

Learning new languages is fucking easy

try to write library in your new lang and use it from C nigger.

//Original version
void parse(char** tokens, char* buffer)
{
char* tok = strtok(buffer, " ");
if(tokens[0] != NULL)
free(tokens[0]);

tokens[0] = (char*)malloc(strlen(tok)+1);
strcpy(tokens[0], tok);

//Rest of function is irrelevant
}


//Updated version
void parse(char* cmd, char** args, char* buffer)
{
char* tok = strtok(buffer, " ");
if(cmd != NULL)
free(cmd);

cmd = (char*)malloc(strlen(tok)+1);
strcpy(cmd, tok);

//Rest of function is irrelevant
}

Reposting.

First version works fine, if I print tokens[0] back in the calling function it spits out the correct string.
Second version does not. Printing the cmd char* inside the parse function works fine, all the way to the end of the function
Attempting to print it in the calling function does not work.
If I don't check to see if it's NULL, valgrind spits out
Address 0x0 is not stack'd, malloc'd or (recently) free'd

If I do check to see if it's NULL, it'll print whatever conditional statement I put in.

so:
Before parse
>NULL
Inside parse
>"Command"
After parse
>NULL

See above

Why in the world would i do that, ivan?

D is a better language

Continuing my quest to become a grand Lisper. I changed Racket with Clojure and HtDP with Brave Clojure.

Java is pure.

[spoiler] Ada [/spoiler]

>df = pd.read_csv('filename', index_col='WGT')

And use pandas.pydata.org/pandas-docs/stable/indexing.html to index your col and row

What relevant software is written in Lisp?

>go to their forums
>community is basically dead

no thanks

clojure is not lisp.

Pure shit

How do I solve this?
Do I have to save all past abundant numbers?
How do I know that 24 is a sum of two abundant number if I haven't "remembered" that 12 is one?

Or maybe I should just go backwards from 28123 and always check each summand?

undergrad who thinks he knows a couple of languages but in reality he knows 0 detected

Why is it not a lisp?

>use it from C
literally pointless

you would because most software dev jobs are all in java

Good thing I'm not a shitty programmer who can't afford the luxury to be selective with where they apply to

>ada
>new lang

It's a Lisp, but it is not Lisp.

bold claims my dude

I hit empty activity in android studio, but when I try to run the hello world app it gives me these error messages.

Did I install something incorrectly?

That's strange, it seems like your char * is going out of scope on return. What does your function call/calling code look like? Do you leak the malloc'd memory as well?

for you

help yourself m8.
Apparently it doesnt like the "parent" strings

if that's copy pasted, then probably different versions

>this is the kind of shit C cucks have to deal with for the most trivial problems

Python, C++, Haskell, and C in that order. SystemVerilog as well, but that's not very syntactically verbose and requires more knowledge of FSM design then anything.

Has there ever been a language called Lisp which is not a dialect?

name one useful software you wrote and show proof

Why isn't it, again?

char* cmd = NULL;
char* args[MAXARGS];
char buffer[MAXLINE];
int i = 0;
for(; i < MAXARGS; ++i)
args[i] = NULL;

while(fgets(buffer, MAXLINE, stdin) != NULL) {
buffer[strlen(buffer)-1] = '\0';

parse(cmd, args, buffer);

//If I omit the conditional, it segfaults
if(cmd == NULL)
printf("cmd is NULL\n");
}


And it looks like yes, I lose whatever gets malloc'd and copied on crash. So it's hanging out there somewhere

I'm retarded

printf("%s\n", cmd);

is what will cause a segfault if I skip the conditional

I wrote bubble sort in clojure
(defn bubble-sort [vector]
(defn bubble [vec vec2 bub]
(let [f (first vec)
rest (rest vec)]
(if (empty? vec)
(conj vec2 bub)
(if (> bub f)
(recur rest (conj vec2 f) bub)
(recur rest (conj vec2 bub) f))
))
)
(defn bubble-iter [vec count]
(if (= count 0)
vec
(recur (bubble (rest vec) [] (first vec)) (- count 1))))
(bubble-iter vector (count vector)))

finally found nice c++ book, gonna fall for c++ meme. with me luck /dpt/

this book sucks

Good luck my man

Knowing a language != knowing the syntax

You better know the in and outs of the language, have a few projects written in it, know the standard library and the common 3rd party libraries, know the standards for good code, and have something to show for it

A month of work

I can think of two ways. First is a map, keeping track of all abundant numbers seen so far. Then, for the current number, after checking if it's abundant (and adding it if so), walk down all values i in the map. If (curNum - i) is in the map, add curNum to the running sum and continue. Another way is only look for abundant numbers, again keeping them in a map. When you find a new one, add it to all other abundant numbers in the map, then add that to the running sum. Might need to have a set for uniqueness checking though (or divide by 2 at the end or something).

How do you format if statements with really long conditions?
if (thisShitIsReallyLong() || thisShitIsLongToo() || wowThisCodeIsSoSelfDocumenting() || jesusFuckingChrist()) {
// stuff
}

if (thisShitIsReallyLong()
|| thisShitIsLongToo()
|| wowThisCodeIsSoSelfDocumenting()
|| jesusFuckingChrist()) {
// stuff
}

Check the styling guidelines that you're using

I inherited a legacy codebase of a million lines of spaghetti code.

What do? I'm trying to not kill myself here.

haskell
fmap or $ sequence [thisShitIsReallyLong, thisShitIsLongToo, wowThisCodeIsSoSelfDocumenting, censoredThisOne]

>using a language that encourages camel case instead of underscore-separated words

This is the truly horrifying part

if(thisShitIsReallyLong() ||
thisshitIslongToo() ||
...) {
...
}

first option is what I was thinking about, too.
I'll just first find all abundant numbers til the upper limit and then work my way to the solution. Thanks for your thoughts anyways

AutoCAD.
Emacs.
Witcher 2 (naughty dog games).
Something in Hubble uses it.

Yes. The original LISP.

does it work if you change your parse definition to char * parse(char ** args, char * buffer); and thus in the while loop would look like cmd = parse(args, buffer); ?

Yes. McCarthy's original Lisp.

GIMP but people hate it.

>Witcher 2 (naughty dog games).

How do I know the rest of your post isn't bullshit

I'm currently finishing off the client side of some server software.
Not gonna lie, I feel really happy now the cryptography algorithm is fixed. Could have it ready for launch tonight.

Java, C#, Scheme, OCaml, maybe F#
I would put others on a resume but I'd need to review a little bit if I was gonna do interviews for a job that involves them

My bad. Uncharted, not Witcher.

naughty dog games did use Lisp at least back in the Ps2 days where they wrote their own dialect, compiler and shit just to make crash bandit or w/e. There's a whole blog about it.

Yes, that works without issue. Although in reality this function already has a return value so that's not an option.

It's clearly handling it by value and not by reference, but I can't imagine why the hell it would. Unless it's expecting it to be just a single character, and not an array of characters?

the style guide says to avoid lines longer than 80 characters but not how to handle long if statements.

...

yeah I remember reading them optimizing for 4x cd read speeds and largely making their level design according to those hardware limits.

i skimmed through Accelerated C++(too old), Stroustrup books(can't apprehend those, seems like academic gibberish to me), C++ primer(too much info) - all those also have bad typography (the versions i copied at least). The Gregoire one is the best i found so far(i'm not very smart and don't have much time to dive deep), its 2014 and has comparisons to C and C++14 coverage. Probably gonna proceed with Effective Modern C++ after i finish this one. Have a better book advice?

thanks user

Good bye Gandalf
1946-2003

C, C++, C#, Clojure, Chicken

I've done it this way

#include
#include
#include

bool is_abundant(const long& number) {
long sum = 0;
for (long i = 1; i < number/2; ++i)
if (!(number % i)) sum += i;

return (sum > number ? true : false);
}

bool check_if_sum(std::vector* abundants, const long& number) {
int i = 0, j = abundants->size()-1;
long sum;

while (i at(i) + abundants->at(j);
if (sum == number)
return true;

if (sum < number)
++i;
else if (sum > number)
--j;
}
return false;
}

int main(void) {
std::vector* abundants = new std::vector;
for (long i = 1; i push_back(i);

long final_sum = 0;
for (long i = 1; i

>I changed Racket with Clojure
Why? Curious since I've been contemplating whether I should learn Racket or Clojure.

I bet y'all who mention C++ but don't mention it first would get fucked with template questions

I used """Rust""" to make a Discord self-bot that displays my currently playing music over on spotify as a game

is uselessness a side effect?
asking for a friend

You're passing the pointer to cmd by value. That is, the 'char* cmd' creates a temporary cmd pointer equal to the pointer you've passed to the function parse.
You want a reference to this pointer. A pointer to pointer will solve this for you.

no.
useless languages have no side effects.

I started checking out Rust the other day to see if it lives to all the de hype. The impression I got was that it tried to look like C but with conscious restrictions "since it's hard to write real C".

Is this a reasonable approximation of Rust, or should I keep looking into it?

you'd be losing that bet then.

Ya, I think it should be parse(&cmd, args, buffer); It's been forever since I've worked in C, Python and C++ have made me weak ;;