/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

pastebin.com/T2HKrQy7
b-ok.org/book/2190882/ea606c
twitter.com/NSFWRedditVideo

c++ is the greatest language of all time

r*st is trash

...

wait can java be used in a similar way as javascript. ie... for responsive websites

>ie... for responsive websites
What?

typedef struct foo {} foo;
or
typedef struct {} foo;

ive started to learn python. i like the way typing fast in a text editor feels so i have been typing lines of print('random text') over and over, with some if/else loops thrown in. how long do i have before my autism goes terminal and i die a virgin?

data class Foo()

I'm mastering the art of matlab scripting, where 4 dimensional arrays are nothing to fear of!

>before my autism goes terminal and i die a virgin?
You still have a long way to go.

reminder to report and ignore shitposting

Rate my sieve, Sup Forums

sieve = (n) => {
let range = (n, step=1) => Array.from({length: Math.floor(n/step)}, (_, i) => i*step);
let candidates = range(n).splice(2);

candidates.slice(0, Math.floor(Math.sqrt(n))).forEach((i) => {
if (i != 0) {
range(n, i).slice(2).forEach((j) => {
candidates[j-2] = 0;
});
}
});

return candidates.filter((i) => i != 0);
};

sieve(100).forEach((i) => console.log(i));

Thoughts on the Carp language?

>A statically typed lisp, without a GC, for high performance applications.
Carp is a small programming language designed to work well for interactive and performance sensitive use cases like games, sound synthesis and visualizations.

>The key features of Carp are the following:

>Automatic and deterministic memory management (no garbage collector or VM)
>Inferred static types for great speed and reliability
>Ownership tracking enables a functional programming style while still using mutation of cache-friendly data structures under the hood
>No hidden performance penalties – allocation and copying are explicit
>Straightforward integration with existing C code

very functional of you

Thank you, that was my intention.

Have a bug:
sieve = (n) => {
let range = (n, step=1) => Array.from({length: Math.floor(n/step)}, (_, i) => i*step);
let candidates = range(n).splice(2);

candidates.slice(0, Math.floor(Math.sqrt(n))).forEach((i) => {
if (candidates[i] != 0) {
range(n, i).slice(2).forEach((j) => {
candidates[j-2] = 0;
});
}
});

return candidates.filter((i) => i != 0);
};

sieve(20).forEach((i) => console.log(i));

Need different /dpt/-girl images with better books.

BRING BACK THE TRAPSS!!!!!!

>'no'

I finished 2048 in C.
That was fun.

I have an SQL table that has a column for month and a column for year. How do I write a where clause that excludes the current month/year combo?
This was my initial attempt but obviously it will exclude all results from 2017 and all results from month 12:
SELECT * FROM table WHERE year != 2017 AND month != 12;

let me know when it hits 0.5 atleast

pastebin.com/T2HKrQy7
i'm assuming linking it would be more helpful

SELECT * FROM table WHERE not (year = 2017 AND month = 12);

thanks!

>higher rank polymorphism and quantification require explicit type/proof applica-
*blocks your path*

not portable 3/10 see me after class

>gay typefag math stuff
*ignores it and actually writes programs*

who /poopgramming/ here?
I'm on the toilet right now lol

It's a toy at best. No namespaces, no macros, overly simplistic linear type system, typechecking happens AFTER monomorphization (like C++). There's absolutely nothing novel about it

>it takes him longer than 30 seconds to poop
eat some fiber senpai

I'm more of an Sup Forums pooper. There's so many poop shows that are only worth my poop time.

Also my laptop sucks for toilet programming.

Based Dunfield-Krishnaswami type inference

>trying to get terminals to not buffer input on multiple platforms
no thanks, i don't want to have to deal with that shit

It's called bidirectional typing nerd.

this
seriously, why bother typesetting confusing math notation when you can type 2 paragraphs in plain english and say the same thing in half the time?

Well yes, but it also does some other neat stuff like hindley-milner-esque unification in the subtyping relation

>why bother typesetting confusing math notation when you can type 2 paragraphs in plain english and say the same thing in half the time?
Because it would take a lot of paragraphs to explain this algorithm (the paper comes with plenty of text, if you'd like to read it :) ), and the math notation isn't very confusing if you're used to reading it. Consider it just a form of densely-abbreviated code

>not pooping and just staying on the toilet for an hour

This is actually kind of cute, would SICP if I could.

I've tried that
I even added fiber supplement to my beverages every day for a few months
it doesn't work

i've finally fucking got my dijkstra implementation to work. Just need to find a way to draw it now.

shout out to those two posters who helped out.

nice
now implement flocking/swarming behaviour

I don't know your exact problem but the first thing with your image that comes to mind is A*, not dijkstra.

Birbs can be taught to talk, can they be taught to program?

is it possible in C to know the range of returned address from malloc?
I made a function that call malloc, then do something else.
But if another part of the code fails, the function will free the memory, then returning another value as error code.
void * somecode(){
void * retval;
char fail;
retval = malloc(sizeof(sometype));
fail = 0;
if(!retval)
{
return 0;
}
//initialize the object;
if(fail)
{
return 1;
}
return retval;
}
//the function that call somecode() now need to check whether it return a nullpointer or a pointer to address 1;


But i don't know whether by any chance malloc could return the address 1 itself, so the caller program interpret it as fail.
Is there any way to know the range of address that will be returned by malloc?

>not 4,0/3,1/2.2

A* is dijkstra's algorithm with a heuristic

If you want to find all shortest paths up to a certain cost (e.g. for movement in a tactics game) then you use Dijkstra.

I know, but it seems he's looking to move somewhere. The heuristic is simple in this case, distance.

What exactly is the problem? Align first by Y or X and then just go up/down/left/right until the target?

you select a little solider and select a tile in the blue range to move him to.

since you can move him to any tile in the range, I'm using dijkstra and not a* (no direction required).

Yes

:(

I actually have a medical condition that makes fiber act similar to laxatives so I take a lot of imodium but that just makes it harder to poo but it's okay because other wise liquid will be leaking out my butt every other hour

No, it's not. And typically malloc will never return 1. In fact, it'll never return an address that isn't a multiple of 8 on most systems

This. Sometimes, I just go to the English building after my last class, go to the bathroom, take a shit in like 30 seconds and then program/masturbate in the stall for like an hour.

Your post sounds like an ancapball meme tbqh

>Your post sounds like an ancapball meme tbqh
if only it was a meme, ileo anal pouches are tough

Not portably, no. Although you could do like linux kernel does with the IS_ERR() macro, using some values as errno's and others as pointers. Difference is that linux controls the address space.

Why do you need to do this? NULL should be your error value with the reason in errno(ENOMEM = malloc failed, EINVAL = invalid value, ...).

I'm sorry about that though, for real. It sounds pretty fucking terrible.

So, why do you need [capture] in lambdas?

impurity

yeah man it sucked
went through the surgeries when I was 13, now all I can talk about is pooping

Can't you take reference or pointers in the argument?

to mutate or not to mutate

at least you don't have huge hemorrhoids like I do
sometimes the bleeding is so profuse when I shit that I'm afraid that I will pass out, bleed out, and never wake up

if i cant find a job because no degree what are the odds to make a "decent" living with free lancing? i do live in a big city so i can network pretty well

that sucks, at least with mine my poop looks vastly different deepening what I eat so it's kinda like a game
i started taking specimens and have a logbook and everything
it's a fun hobby but people aren't that understanding

very few places care if you have a degree or not
they usually say right in the job posting "degree or equivalent experience"

It depends. If you are living in a shithole, freelancing will pay your bills.

If you can't find a job, make a good/killer app and open up a patreon.

>Haskellweenies still convinced that mutation is impure

Not a haskellfag, but if you are mutating the arguments, or any variable outside the scope it's no longer pure

>what are effect systems

effects suck

got feathers all over my keyboard again

lewd

Then why is Haskell getting linear types?

they're just feathers user

I've failed to learn C++ but I still want to try and learn it. What is the best way to open a gamewindow on windows and print text to the screen in a non-retarded way? I'd like to try and learn C++ a little bit by working on what's basically a small text adventure game. I'm not entirely new to programming and I've read enough intro to C and C++ books to be familiar with the concept of pointers and bitwise operations and logic and stuff. I'm just completely lost on the libraries and workflow front.

Header Files and compiling projects with multiple files still makes me incredibly uncomfortable. I've done some 2D interface programming and graphics programming with C# and OpenGL though.

i just had this sick idea for an app

i need an expert java programmer immediately who knows how to do augmented reality stuff

Sure, just wire me 12.5 million dollars.

what

Check out SDL for game development.

It's full of bad practice for c++ development but will get you started on video games.

b-ok.org/book/2190882/ea606c

Header files are simple, just remember to use include guards.

makes no sense to use SDL with C++
use SFML instead

What about with Rust?

Mathematicians are worse than Perl Monks, I swear to god.

i'm starting to learn ios tweak development. my first tweak just removes the dock, but it's a start.

%hook SBDockView

-(void)SetBackgroundAlpha:(double)arg1 {

%orig(0)

}

%end
BAM

you shouldn't play with it, you might get tetanus

What the fuck is this disgusting language?

Could you make a tweak that removes iOS entirely?

user please I'm just trying to make memory-safe games

Just don't violate memory then.

probably retarded question but im making a java desktop program and whenever i want to compile and run it i have to do the commands over and over again to compile then run it. Is there a faster way to compile and run the program?

easier said than done in any non-trivial program

Objective-C. it does look disgusting tho, i won't lie.

lol i could do that if I wanted but then i'd have to update my ios

Build system, like makefiles.

make a makefile

I made the OP image btw. Does the shop look good? It was my first time using free transform on photoshop.

Kotlin is the next Java

Looks like a crappy photoshop, honestly.
You gotta zoom in and spend more time blurring and cleaning up lines.

it looks great, don't sweat