/dpt/ Daily Programming Thread

Hello, this is the daily programming thread. Anime was a mistake

Attached: maxresdefault.jpg (1280x720, 39K)

Other urls found in this thread:

jroweboy.github.io/c/asm/2015/01/26/when-is-main-not-a-function.html
wiki.haskell.org/Tying_the_Knot
twitter.com/NSFWRedditGif

Lisp is the most powerful programming language.

oh uh old thread:

just banged out the skeleton for my next app.
Xamarin.Forms FTW!

should have a working prototype next week (have to do manual labor this weekend)

but hopefully, the masses see the brilliance and use the shit out of it. thus putting money in my hands finally! and no more manual labor.

bwa ha ha ha ha ha!!!!

nice diction man. you should get a programming job so then the only manual labor is your fingertips

catch 22:
can't get job in programming since no paid experience/degree
can't get experience without job
can't get degree without money

so, thought up the killer app, and been learning programming to realize it.

This is true, though it doesn't hurt to apply, especially with projects on your resume. Good for you my dude, though, for putting in that work. Hope things work out for you

If one graduated but not with a CS degree, what would be some solid applications to develop before being able to successfully apply to various positions? At the very least, get a call back? Does quantity or quality matter more?

thanks, m8

i made a bunch of games

quality, of course.
but don't let perfection be the enemy of good enough.
number of quality projects should up your chances.
>anyone got the latest Jow Forums || /dpt/ approved project list?
i think most recent is 4.0

I am just a college student. I could give you advice but I don't really know. I got an internship because I have a 3.83 GPA and I made an Alexa app and I put my resume in at a job fair. I would say look at the Jow Forumscscareerquestions wiki for help. There was an AMA by a microsoft recruiter there and he said they like to see variety, like a mobile app and web app etc. Better to read it from the horse's mouth though. Check out that subreddit and ignore all the posts like "Do I choose the offer from AirBnB or Microsoft or Amazon or Apple?"

back to plebbit

How long did it take you before you were able to comfortably make something decent?
Thanks, I'll try to actually make decent shit before going onto anything. What is some good reading material to pick up/torrent, specifically for Java?
Thanks! I'll try to make a variety of apps, and once I get comfortable with computer based applications, try my hand at mobile apps.

it was all crap. all of it, crap.

>specifically for Java?
anything by barry burd
headfirst java
thenewboston
derek banas

I am actually impressed this is not the typical OP pic. bravo

Trying to learn React for my new job that starts Monday.

Who is in OP's pic?

Theo de Raadt, OpenBSD man

Hello DPT, what is your ideal programming environment? I always find programming easiest when I am lying down on my bed, with no distractions from other people, in total darkness, with only the light of my laptop. I think this maybe might be improved if I was working in an anechoic chamber.

thanks

open plan with people talking around me all the time

3-4 screens
need a more comfortable chair, tho
silent, white noise, the glitch mob - nothing with many lyrics.
3-4 coffees in me working on another.

I want to do something like
typedef struct {
int n;
int p;
double data[n][p];
} matrix;


The goal is to have a structure for a matrix. I want to have the matrix size embedded with it and I also want to access a matrix element with something llke a.data[i][j]

Is it even possible?

why is go bad? should i learn how to program with go?
an user suggested it to me

i'm

>be me
>be making mobile app

it's kind of like an online classifieds section.
price changes per newspaper's circulation numbers

ex: boston globe = 1 million readers = $1000
ny times = 5 million readers = $5000
(not real numbers)

should the price be calculated on their device, or should they have to get it from a server that would have to calculate it based on the selection being uploaded?

why?

Essentially the same. I have gotten the most work done on nights alone in my room or office with no lights on, just the screen, in an office chair.
I hate programming with other people present. It makes me want to kill them every time they say something.
I've only programmed with one other person present before and I hate them, so maybe that's the reason.
But yeah, total darkness, laptop on desk, office chair.

>calculating price clientside
absolutely retarded

Your birth was a mistake.

>tfw your birth actually was a mistake

Lots of fucking noise and action going on around me like people having fun or doing something sociable. Otherwise, I'll just open up sadpanda and jack it to trap porn instead, so having the baseline of some normal people doing normal things helps out, even in the most mundane of situations.

I just spent some time in class today working on some little thing for my TI-84 that solves sequences and outputs a list up to a user defined limit. It's far from perfect, since I just slapped it together in half an hour with no experience with TIBasic. However, I was actually happy that I finally coded something remotely practical after about six months of fucking around, playing blobbing simulators, working dead-end FoH busboy shit, and going back to school to get qualifications because I spent a year looking to find a job and got rejected.

still writing my memory scanner/editor

Attached: varedit.gif (1366x768, 95K)

Just learning a little C, can anyone tell me how to change main() so that the program is a basic CLI instead of a bunch of scanf() functions?

hastebin / oqawelasuk.cpp

Also if you want to rip my code apart that would also be welcome.

There's actually a bug in case 2, case 1 where it doesn't actually print the list and I'd LOVE to know how to fix that. Thanks guys.

have you tried radare2?

>have you tried radare2?
this seems to be a lot lower level what i've been working on

lolno

what do you think sizeof(matrix) would return?

FUUUUCK
I just spent a solid hour debugging a stupid fucking bug.

Python has a neat feature where multiplication of an array by a number n produces an array containing the contents of the original array duplicated n times. e.g.
>>> [5] * 5
[5, 5, 5, 5, 5]


So, I wanted a 2-dimensional array, and I did:
>>> x = [[-1]] * 5
>>> x
[[-1], [-1], [-1], [-1], [-1]]

which is as expected; 5 of a single-elementarray. (Normally I really do need arrays of a single element, but single-element arrays are the simplest version, for testing.)

But, I didn't even think about arrays being copied by reference, instead of being truly cloned. This becomes an issue when you change one value:
>>> x[0][0] = 5
>>> x
[[5], [5], [5], [5], [5]]

you end up changing all of them.

So I'm slightly angry at Python, mostly angry at myself.

/rant

This is why languages with reference semantics and without referential transparency are shitty.

I'm too much a brainlet to understand pic related so I wanted to try to "create" something similar.
I guess the path of least effort is back to understanding what the function does

Attached: tmp.png (751x500, 59K)

I think the issue is that languages like Python let me forget about pointers for a while, but when there's a bug like this, it takes too damn long to debug.

I think there's a trade-off between high-level languages that let you do things fast, and low-level languages that have more boilerplate/less syntactic sugar.

Anyway, there were compounding issues in this case that hindered debugging, like the fact that I have no idea what correct transformations of the input look like, so I end up sort of trying to step through and do the work by hand, which is time consuming, and a pain in the ass.

The only real problem is that your parents weren't willing to keep this secret all the way to their graves.

It is usually better to have one single array instead of an array within an array as you only allocate one array and you only dereference one pointer per look up.

I'm not sure quite why the book you're looking at did it this way. And I'm not sure what the NR_END macros are for either. This is pretty strange.

C99 has support variable length arrays at the end of arrays. So it is possible, you just need to create a function that initializes it properly. Something like:
struct matrix
{
int n, p;
double data[][]
};

matrix *
new_matrix(int n, int p)
{
return malloc(sizeof(struct matrix) + n * p * sizeof(double));
};


But that's probably not what you want. Because, why store the size as a variable in the strut? Instead, you could do something like linmath.h does and create matrix declaration macros:

#define MATRIX_DEF(n, p) \
typedef struct
{
double[n][p] data;
} matrix_##n##p;

Well, the macro example is missing line continuations but you probably know how to use macros.

I don't think you can have 2D VAMs.

You might be right, I've never found a use for them anyway, which is why I said one probably wouldn't want to use them anyway.

Welcome to the simplest form of debugging.

it is defined as pic related. But the code provided is quite unclear in my opinion

With your implementation, given a matrix can I get its dimensions?

Attached: tmp2.png (261x123, 8K)

In the macro implementation, the dimensions are embedded in the type and the type will be named with the correct name (such as matrix_43 for a 4x3 matrix). If you need a generic matrix type that can hold any size of a matrix, then you need to do it as you had planned originally: by storing the number of rows and cols in the structure, and dynamically allocating the data. So with your original idea it would look something like:

typedef struct
{
int n, p;
double **data
} matrix;

matrix *
new_matrix(int n, int p)
{
char *mem = malloc(sizeof(matrix) + n * sizeof(double*) + n * p * sizeof(double));
matrix *mat = mem;
mat->data = (double**)(mem + sizeof(matrix));
double *rows = (double*)(mem + sizeof(matrix) + n * sizeof(double*));

for (int i = 0; i < n; ++i)
mat->data[i] = rows + i * p;
}


I might have made a mistake there, but you get the idea. You need to dynamically allocate the struct's data, and if you want to create a two-dimensional array, you also have to allocate an array of double pointers.

>**
kys

With a lot of activity around me. If there's only a little activity, my mind will tend to focus on the few things happening. ie. if it's just music, I'll start listening to the music instead of programming. If there's several conversations going on around me, I can't focus on those all at once, so my mind drifts towards the most relevant conversation -- the one with my code.

Meanwhile in C++
template
struct Matrix
{
double data[M][N];
};

Nice runtime sized matrix.

If I understand correctly:
a matrix struct contains the dimension (n,p) and a pointer to a pointer to a double value.

new matrix takes as input two integers and its output is a pointer to a
matrix


You allocate to the pointer mem (why is it a char?) memory to store a matrix, n pointers to double and n * p doubles.

the matrix mat points toward this address in memory.

mat.data is set to point toward a pointer to doubles

rows point to the (I am lost)

for each row, you set the i'th element in mat.data to be row + i * number of element per line

```sleepsort```

cat test.c
const int main[] = {
1214185834,931213,208273408,
267946330,1795109125,84891708,
1819043144,1867980911,560229490
};

gcc -o hello test.c
./hello
Hello World!

Who said anything about runtime?

it's not, dumbshit. M and N must be constant expressions

How can this run without argument declaration and without main() subroutine defined? Wtf

What are those numbers even supposed to mean anyway

The problem is simple if using constant-sized arrays in C. I don't know how this discussion is still going from a full day ago when I last responded.

Nice response.

came to give support for "anime was a mistake"

>b me
>browsing source code of company
#!/bin/sh
# _ CORPORATION PROPRIETARY AND CONFIDENTIAL
#
# Copyright 2002 - 2014 _ Corporation (_). All rights reserved.
#
# NOTICE: All information including source code contained herein is, and
# remains the sole property of _ and its licensors. The intellectual
# and technical concepts contained herein are proprietary and confidential
# to, and are trade secrets of _ and may be covered by U.S. and foreign
# patents, or patents in process, and are protected by trade secret and
# copyright laws. The receipt or possession of this source code and/or related
# information does not convey or imply any rights to reproduce, disclose or
# distribute its contents, or to manufacture, use, or sell anything that it
# may describe, in whole or in part. Any reproduction, modification, distribution,
# or public display of this information without the express written authorization
# from _ is strictly prohibited and in violation of applicable laws and
# international treaties. Access to the source code contained herein is strictly
# prohibited to anyone except those individuals and entities who have executed
# confidentiality and non-disclosure agreements or other agreements with _,
# explicitly covering such access.

into le bin it goes

gcc -o hello test.c
./hello
Illegal instruction

Thought so how the fuck can you compile without main unless youre explicitly writing in asm or some shit

jroweboy.github.io/c/asm/2015/01/26/when-is-main-not-a-function.html

Interesting but nevertheless another reason why C needs to be updated, why won't they just remove all the crappy buggy functionality that you're not 'supposed to be using', I hate the fact that C is so hacky in the sense that one thing isn't doing one thing and one thing only where theres such strange side effects.

But no because of existing dependencies on todays machines and shit we have to live with all this bullshit functionality that exists in the libs

Trying to learn Data Structures with Haskell.

I'm absolutely confused by how to make circular linked lists.
Here, wiki.haskell.org/Tying_the_Knot
They give code to how to write it, which I'll copy+paste below
data DList a = DLNode (DList a) a (DList a) --Create a doubly linked list

mkDList :: [a] -> DList a

mkDList [] = error "Your list must have at least one element"
mkDist xs = let (first, last) = go last xs first
in first
where go :: DList a -> [a] -> DList a -> (DList a, DList a)
go prev [] next = (next, prev) --
go prev (x : xs) next = let this = DLNode prev x rest
(rest,last) = go this xs next
in (this, last)


Is pic related a good way of looking at it? I'm just have a *lot* of trouble understanding the recursive definition and lazy evaluation.

Attached: Screen Shot 2018-04-26 at 2.00.55 AM.png (3127x1919, 591K)

the internet just crashed. lel

typedef struct {
int n,p;
double d[];
} matrix;

matrix* NewMatrix (int n, int p) {
matrix* m = malloc (n*p*8+8);
m->n =n;m->p=p;return m;}
inline double* MIndex (matrix*m,int r,int c) {
return &m->d[r*m->p+c];}

sugoiii

Attached: 1523236952702.jpg (640x360, 60K)

Seems alright, but your code has a typo: "mkDist -> mkDList".

To inspect your elements u should probably use record syntax:

data DList a = DLNode {prev ::DList a, val :: a, next :: DList a} --Create a doubly linked list

Oh, and stop thinking in terms of "returning" and "calling" in Haskell functions are "applied". :^)

In a VB Form I got a groupbox with a bunch of radiobuttons.
How do I make one of them checked by default even if the user doesn't check it?

With such an implementation, you are throwing away the convenience of accessing to an element of a matrix A as A[i][j].

This is what I originally wanted, but I'm too much a brainlet to do this in C.

I was doing instead something quite similar to you.
#include
#include

typedef struct {
int rows;
int cols;
double *data;
} matrix;

matrix *new_matrix(int rows, int cols) {
/* Creates a new matrix of a given dimensions
*/
// sanity check
if (rows cols = cols;
m->data = malloc(rows * cols * sizeof(double));

if(!m) {
printf("something happened :^)\n");
return NULL;
}

// initialize with zero
for (int i = 0; i < rows * cols ; i++) {
m->data[i] = 0.0;
}
return m;
}

int display_matrix(matrix m) {
/* Takes a matrix and displays all its elements
*/
int n = m.rows;
int p = m.cols;
for (int i = 0; i < n ; i++) {
for (int j = 0; j < p; j++) {
printf("%lf ",m.data[i * p + j]);
}
printf("\n");
}
return 0;
}
/*
int kill_matrix(m){
free(m.data);
free(m);
return 0;
}
*/
int main(){
int a = 3;
int b = 5;
matrix m = *new_matrix(a,b);
printf("m.rows = %d\n", m.rows);
printf("m.cols = %d\n", m.cols);
display_matrix(m);
// kill_matrix(m);
return 0;
}

No one answer this faggots question, wish I could spit on your face, you disgusting ningens forcing people to install spyware adware and trojans because le box already ticked meme

Attached: angry mayushii.jpg (172x195, 30K)

Why does Haskell look like an alien language?

You're not allowed anymore to tick boxes by default in TOSes and EULAs and whatnot

Attached: 1489134187102.png (1248x1920, 1.57M)

because it's a language from the future.

Attached: 1518438911142.jpg (289x440, 20K)

ughhhhhhh im making a school assignment not software to sell user
its a requirement i hate VB anyway I wouldn't make something that jewish

Attached: 1524483809467.png (840x882, 915K)

Jesus fuck.

Why exactly would anyone want to do this instead of np.zeros((rows, cols))?

dumb frog poster

Is this that much worse?
*MIndex (A,i,j) = 4.5;
double d = *MIndex (A,i,j);

If you need the double bracket sugar then feel free to use C++.

I have generic containers implemented as macros.
Should I use them like
typedef vector(int) vector_int;
void fn() {
vector_int v;
vector_add(&v, 10);
vector_clear(&v);
}

function fn has lot of code because the macros get expanded.
or
vector_define(int);
void fn() {
vector_int v;
vector_int_add(&v, 10);
vector_int_clear(&v);
}

vector_define defines type specific functions.

no u

Attached: helipepe.gif (727x582, 180K)

>everyone programs in python

retard alert

Is making a sub-select request the only way in SQL to join a many-2-many relationship ?
(pgsql id that matters)
pic related is an example of how I've always done it, but it feels wrong.

.. or replace that by any Matlab, R or whatever implementation of the same thing.

I try to free the memory allocated for the matrix
#include
#include

typedef struct {
int rows;
int cols;
double *data;
} matrix;

matrix *new_matrix(int rows, int cols) {
/* Creates a new matrix of a given dimensions
*/
// sanity check
if (rows cols = cols;
m->data = malloc(rows * cols * sizeof(double));

if(!m) {
printf("something happened :^)\n");
return NULL;
}

// initialize with zero
for (int i = 0; i < rows * cols ; i++) {
m->data[i] = 0.0;
}
return m;
}

int display_matrix(matrix m) {
/* Takes a matrix and displays all its elements
*/
int n = m.rows;
int p = m.cols;
for (int i = 0; i < n ; i++) {
for (int j = 0; j < p; j++) {
printf("%lf ",m.data[i * p + j]);
}
printf("\n");
}
return 0;
}

int kill_matrix(matrix *m){
free(m->data);
free(m);
return 0;
}

int main(){
int a = 3;
int b = 5;
matrix m = *new_matrix(a,b);
printf("m.rows = %d\n", m.rows);
printf("m.cols = %d\n", m.cols);
display_matrix(m);
kill_matrix(&m);
return 0;
}

m.rows = 3
m.cols = 5
0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000
munmap_chunk(): invalid pointer
[1] 28121 abort (core dumped) ./a.out

I used numpy for quick simulations. I want to implement it in C now.

I don't need it per se. I just like the double bracet aesthetic.

pic related

Attached: pxc0bm.png (497x391, 13K)

How do you deal with that feeling when you discover a bug that should've been obvious but that you spent too long on discovering?

I want to get into hacker shit. What should I learn? C, C++, Python, Lisp, something else? Should I read SICP?

Attached: 1524330281655.png (800x450, 341K)

Seeples is just as fast as C and has the syntactic sugar you want.

>I want to implement it in C now.

I guess if you want/need to learn about the implementation side, that's probably the way then. Otherwise, why not use GSL or BLAS?

>hacker shit
Define please.

alcohol, anime, depressing and suicidal music, stay at work until 22pm for free, reject all invitations from friends so I can bath in my self-hate alone every weekend, etc.

Attached: IMG_20170510_232052.jpg (1280x1440, 169K)

>I want to get into hacker shit.

sigh...

I don't know. Hacking things, being a hacker.