/dpt/ - Daily Programming Thread

Previous thread: What are you working on, Sup Forums?

Other urls found in this thread:

facebook.github.io/react-native/
twitter.com/AnonBabble

if i declare uint16_t *__restrict__ foo, why can't i pass it to a function as uint16_t *&f

so thats it, C18 will have hyphens in variable names. whoa.

ok kid

First for assembly.

/dpt/-chan, dai suki~

Ask your much beloved programming literate anything (IAMA).

really? Finally catching up to lisp.

kys

How many test cases should I write for trivial methods like joining file paths or returning the absolute path of a file?

none

Now they just need to allow other characters in identifiers like ? and !.

...

One for any issue you have encountered, plus test cases for any potential issues.

>arguing with statist
>"muh roads"
>literally all he's got
>BTFO him with logic and science
>leaves the debate thinking he won because he called me racist for saying niggers should go back to africa
Get praxed negro lover

Ok gents I was in an interview yesterday and couldn't finish the last question I was working on because I ran out of time.
My answer was incorrect because it didn't return the proper number.
I felt pretty bad about it so I just coded it at home, and now I'll post the problem 1st in case any of you guys want to solve it.
The interview was 30 mins, 3 questions, and this was one of them.
I'll post my answer in 10 minutes.

Here's your prompt:

/*
Given a string of uppercase characters, and an array of target characters,
find the length of the longest consecutively repeating substring of target characters.

For example:
longestStreak("AABGZZZARRRRRR", ['A', 'G']); // returns 2
longestStreak("AABGZZZARRRRRR", ['A', 'G', 'R']); // returns 6
*/

Please don't bully OSGTP.

Ah, I forgot to mention, you must use the array function '.forEach'
In case u guys don't remember foreach is
[].forEach(function(element, index, array){});
// they didn't give this tidbit btw, gotta have memory!
[/spoiler]

is it convenient to develop a offline application with node.js?
I know Ruby and Python but most GUI libraries piss me off and i don't like how they look, I'm tempted to to do the job with HTML5.

package main

import (
"log"
)

const (
stack = "AABGZZZARRRRRR"
)

var (
needles = []rune{
'A',
'G',
'R',
}
)

func main() {
max := 0

for _, needle := range needles {
hits := 0
for _, item := range stack {
if item != needle {
if hits > max {
max = hits
}
hits = 0

continue
}
hits = hits + 1
}
if hits > max {
max = hits
}
}

log.Print(max)
}

2 minutes maybe?

k it's been 10 mins, here was the answer i came up with
function longestStreak(s, tar) {
var ar = s.split(''),
curs = 0,
lons = 0,
last;
ar.forEach(function(e, i, a){
if (tar.indexOf(e) == -1)
curs = 0;
else
curs = e == last ? curs + 1 : 1;

if (curs > lons)
lons = curs;
last = e;
});

return lons;
}

cool what language?

Looks like Go senpai

Go famalam.

did you get the job?

I've never used or seen Go, and it looks weird.
what's []rune and 'for _,' ?
and is := "assign if null" ?

well interview was yesterday evening, but no i don't think ill be getting a call back.
it was a 2 hour interview and i gave 2 lectures, i prepared for two, more like 2.5 days, and i was working my parttime job too so i didn't even have a full day to make the lectures...
i'm pretty salty about sinking that much time and effort into an interview. not to mention i had to drive an hour to get there, and got stuck in traffic so bad i had to turn my engine off multiple times just to sit in the road

>not formally proving your code correct with regard to the underlying architecture in a higher-order intuitionistic logic

>job interviews
>gave 2 lectures

what, where the fuck did you apply to

>:=
It's for type inference.

facebook.github.io/react-native/

Restrict is non standard C++. You are not allowed to discard it probably due to methods and class fields.

>One for any issue you have encountered
TDD is about writing tests first.

Write the specification of your procedure then the tests based on that specification.

a teaching gig. i have a few years of ta experience and have lectured about half a dozen times. still work at a job equivalent to flipping burgers though

>what's []rune
Array of UTF-8 characters
>and 'for _,' ?
_ is a placeholder variable because of muh multiple rvals.
>and is := "assign if null" ?
It's a short hand notation for a variable declaration.

nigga why not go into the industry?

Anyone here applying for the Karelia AMK Tiko exam? Any code ready?

Do you want cancer? This is how you get cancer.

ive interviewed so many times, every time it's always the same
>oh user you're so smart
>we like you, what you talked about, your personality, etc
>never get a call back
EVERY fucking time

probably has something to do with my liberal arts degree and nearing 30's age

is that a man?

i know this feel, i think the worse was when i was a jurior looking for an internship and the guy straight out told me "user I think you can do better than this, im not sure if youd like it here. are you sure you want this internship?"

neddless to say he never called back after that.

>facebook.github.io/react-native/
thank you
i just want something that is relatively easy and provides good looking results
most "classical" GUIs are difficult to make and feel simply outdated

Seriously, I've seen the absolute worst getting hired. The only thing you have to be is a smooth talker.

life is hard when youre anti social

maximum $ map length $ group $ intersect "AABGZZZARRRRRR" "AGR"

Dubs chooses what I program

a program that programs

A Calculus of Construction interpreter

Automatic music generator based on machine learning.

reroll

Le fizzbuzz meme :^)

rereroll

this

Dubs decides what it programs

Not sure if you're him. Work on that shit nigga. Travel to some far away place on your own where they don't speak your language. China for instance. Reflect on your life.
You either become more social or end up killing yourself.

it should program bots that learn from Sup Forums posts and posts back

id end up becoming a hermit

Pro tip: feed it Sup Forums

this, tay tay Sup Forums edition

Was this a language specific question?
What language is [].forEach?

It should compute safe passwords that are unable to be found, and store them in an encrypted file.

That's why you have to force yourself. Travel by bus so you have to ask for directions. Take creepshots.
Or get breast implants, problem glasses and start forking irrelevant Github repos.

It's js, never mind. Read over it.

JS

holy what

i do take a bus everywhere already, no one talks on them.

Haskell, mate. Shit's cash.

I mean asking which bus you have to take to reach your destination.

>new thread
>old thread still has 308 posts
what the fuck have you done you piece of shit

Welcome to the concept of ego, and how it affects humans. Enjoy your stay.

fuck off i'm not replying to you

you just did

Perhaps I should give you an explanation:

An array of character is just a string in Haskell, so
['A', 'G'] is the same as "AG".

'intersect "AABGZZZARRRRRR" "AGR"' returns the list in which the character of the second occur in the first, giving "AAGARRRRRR"

'group' returns that result grouped by characters: ["AA","G","A","RRRRRR"]

'map length' returns the length of each string in the that list, giving [2,1,1,6]

'maximum' find the largest number in that list, giving 6.

i = 1;
i = ++i++;
printf("%d\n",i);

You should be able to solve this.

TEACH ME

undefined
kill yourself weebposter

What the fuck? You're not me

osht nigga

I want to learn programming

3. The second statement ends after the postscript increment, making it effective

well /dpt/
I'm going over on a vacation that i don't want to, and i'm going to use that time to learn how to program on android.
I'm downloading android studio and setting up my phone so that it'd work.
But i won't be able to access the internet while i'm gone, so i'd appreciate if there are any android programming books out there that cover a great deal of it, and anything that revolves around handling Database related Data, stuff like JSon or whatever.

Error.

i = ++i++;

i = ++1;


1 isn't a variable you can increment.

Fuck computers, just enjoy yourself.
You're probably never going to have it this good ever again, neetboy.

>undefined
nope, char* can alias anything

fuck off with this ridiculous blushing, fucking autist

I'd love to, the reason i'm being deported like this is because i'm wasting too much time with people.

Don't forget to download the SDK documentation, libraries and an emulator.

It sounds like you're not painting the whole picture.

>beyond my abilities
user...

B for trying, but read some more C m8, the result of expressions such as i=5 can be more than a numerical value, think a = b = c (no it's not a special case) or *it++

this is so retarded

>a = b = c
>*it++
Just realised both my examples are out of topic

kill yourself smug fag, you got absolutely rekt on the aliasing issue

>hundred spaced indentation

No user, you are the downs.

What does DPT hate in code?

>100+ line functions
>global variables disguised as singletons and command line flags
>returning null instead of empty results

Whatever.

$ cat g.c
#include

int main(void){
int i;

i = 1;
i = ++i++;
printf("%d\n",i);

return 0;
}
$ gcc g.c
g.c: In function 'main':
g.c:7:6: error: lvalue required as increment operand
i = ++i++;
^

your mom

import task
task1 = task.Task()

What should i name my variable task1? I want to name it task, but that creates conflicts with the module name.

I know.
But i'd hate to waste my time, the vacation is going to be atleast a month or two long. so i'd hate to not have atleast got something out of it.

Lacks more brackets this m8 (cond [(test args) (body)*]*) did you come from Clojure or wh@?

How old are you?
If you really don't want to go, they can't force you to.

fuck off

obviously something that describes it like niggerTask or fagTask

task_to_do_a_thing

>other people's code
>my own code older than [CURRENT YEAR] - 2

i'm talking about the lack of error reporting. it's not like cond has a million different forms it can come in, yet it says nothing