/dpt/ - Daily Programming Thread

Anime edition

Previous thread: What are you working on Jow Forums?

Attached: teach_me_cpp_senpai.jpg (1440x810, 155K)

Other urls found in this thread:

haxe.org/
youtube.com/watch?v=yVcNsz36ZHI
kiwiirc.com/client/irc.rizon.net?channels=#Jow
godbolt.org/g/t3ZVPJ
youtube.com/watch?v=9cqRxo1V_OM
en.wikipedia.org/wiki/Partially_ordered_set
youtube.com/watch?v=vKUAMHSfMOk
youtube.com/watch?v=A4T8o5LS2KY
twitter.com/NSFWRedditImage

Getting an internship. Its not going well at all.

Experimenting with winsocks.

Is there any way to transpile a better language to AS3 or something like that? I'd like to write in JS or another language that's a bit more feature-complete, but I need to deploy the game in Flash. There's HaxeFlixel, but it seems more focused on real-time action games, and I'm trying to do something turn-based.

Company, where I was working some 5 years ago had .net -> flashbytecode compiler, and we were writing our reports viewer mostly in C#

haxe.org/

You in college? Look into doing a co-op. They're longer term positions but employers will suck your dick to get you to do a co-op.

I made some tweaks to my ascii art thing I posted yesterday. It can reference/build a text file of names and corresponding pics now

Attached: Capture.png (1155x1039, 269K)

Trying to make program that takes the text from a file and translates it into "Pig Latin" then writes it to a file on the drive.

>What are you working on Jow Forums?
i'm attempting to make irc server software

Attached: file.png (996x831, 149K)

giving up and getting drunk
youtube.com/watch?v=yVcNsz36ZHI

Isn't that under 10 lines of code?

substrings, concatenation, iostream
Under 10 lines as the other user said

>all this back slashes
looks painful to write

I'm still learning. Post a snippet?

Attached: 2nd wave radical feminist communist lectures her book thats critical of veganism to Antifa.png (467x400, 149K)

surprisingly, it's not

here's the compiled code which will probably make more sense
local users = require("users")
local numerics = require("numerics")
local commands = {
["NICK"] = function(line, user)
local requestedNick = line.args[1]
print("Requested nick: " .. tostring(requestedNick))
if not (requestedNick) then
user:send(numerics.ERR_NONICKNAMEGIVEN(user))
return
end
local nickInUse = false
for _, otherUser in pairs(users.connectedUsers) do
if otherUser ~= user and otherUser.nick == requestedNick then
nickInUse = true
break
end
end
if nickInUse then
user:send(numerics.ERR_NICKNAMEINUSE(user, requestedNick))
return
end
if (requestedNick:match("[A-Za-z0-9_\-`]+")) ~= requestedNick then
user:send(numerics.ERR_ERRONEOUSNICKNAME(user, requestedNick))
return
end
user.nick = requestedNick
end,
["USER"] = function(line, user)
local username = line.args[1]
local zero = line.args[2]
local asterisk = line.args[3]
local realname = line.args[4]
if user.registered then
user:send(numerics.ERR_ALREADYREGISTERED(user))
return
end
if not (username and realname) then
user:send(numerics.ERR_NEEDMOREPARAMS(user, "USER"))
return
end
end
}
return function(user, line)
local command = line.command or line.numeric
if commands[command] then
return commands[command](line, user)
end
end

you could do this in a perl one liner

Everything is a one line C program if you're feeling sexy enough

Just made this meme challenge. Please ask if anything needs more clarification.

Attached: Anime_Challenge_Hex.png (1080x1106, 714K)

Thread reminder that there is an IRC chat for DPT

kiwiirc.com/client/irc.rizon.net?channels=#Jow Forumsdpt

but...but... this looks hard.

You should be able to solve it.

stop using the word transpile
its just a fucking compiler

it actually looks fun 1 sec.

That looks familiar, ive seen that one somewhere before. I wonder if i can fjgure out a formula for that...

I don't believe that using your pinky so often is not a problem.

I can't think of a formula off the top of my head I was just going to write a program to manually run through the sequence.

Im phoneposting so math is only thing i can do. Sequence follows a pattern ibut ts way to early for my brain to figure ot out.
It goes something liken = n-1 + n-k where k goes {1,2,3,6...} but too earls to check if it goes like i think it does

k is the sum of all the numbers previous to it?

Python:
with open('input.txt') as f: words = f.read()
pig = []
for word in words.split():
if word[0].lower() in 'aeiou': pig.append('{}way'.format(word))
else: pig.append('{}{}ay'.format(word[1:],word[0]))
print('{}\n{}'.format(words,' '.join(pig)))


George Bush Doesn't Care About Black People
eorgeGay ushBay oesn'tDay areCay Aboutway lackBay eoplePay Away Day

Basically you want to:
read the file
split the text into words
create an empty list
if the first letter is a vowel, add "way" to the end
otherwise, shift the first letter and add "ay"
print the joined list

You can do other things to fix the case if you want to as well, but that'll get you started.

Python too, but not so helpful if he's learning.
with open('input.txt') as f: print(' '.join([x+'way' if x[0].lower() in 'aeiou' else (x[1:]+x[0]+'ay') for x in f.read().split()]))

n-1 and n-k are indices of prevuous elements, k will go up to some N then it will reset itself to 1as pattern continues i think. I think you should be able to make it like fibonnacies

Jow Forums, serious question. How to evolve past code monkey? I've got too used to StackOverflow, Google, and this absence of struggling and being able to find almost everything I could led me to the point where I don't bother understanding things. In spite of the fact I have passed interviews, I feel I am just not ready for a production code solely for this reason.
For example, now I am trying to write a basic interpreter (calculator with possibility to operate with boolean operations, such as gr, le, leq, geq, etc ..., operations precedence, and if/then/else/for). I feel that it would take me YEARS if I had no access to the Internet.

Is it the only way? How did you make it?

Attached: 1495349169332.jpg (480x411, 65K)

Considering contributing to ArchLinux, is it worth it? How hard is it to get involved past marking bugs as “not repo”.
Been adding some search features and states to a shell I wrote in lisp

Your damn example is wrong u idiot 14, 19, 22, 29 NOT 19 when making problems at least double check

>user makes a single typo and presses a single key to the right of the intended key
>this hostility

why is there no spiritual successor to Sneakers

I was kind if you ask me. People should be burned alive for things like these. Reminds me of university and retarded math prof who always had mistakes in proofs but asked for correct versions on midterms/final.

>There's HaxeFlixel, but it seems more focused on real-time action games, and I'm trying to do something turn-based.
it's just an API that can draw graphics and play sounds and shit. i don't see any reason why it wouldn't be suited to a turn-based game. just use state machines. it's just code, not some Game Maker-type visual programming thing or something. you can do basically whatever you want

Haxe source code is translated into source code for other languages which is then compiled using the native toolchains of those languages (where applicable; otherwise, interpreted by runtimes/browsers as-is). that's transpiling. the word "transpiling" exists simply to distinguish this approach from the theoretical alternative where Haxe is compiled from source directly into flash/C#/Java bytecode, assembly, etc

its all code and people have been using the word compile for all kinds of transformations for longer than you have been alive

Nth value = 0 + 0.368492N +0.085713N^2

prove me wrong. Its pretty good.

Attached: unit testing framework.jpg (600x373, 52K)

How would I start learning coding? Specifically in order to make fun little robots or programs in order to practice for future things

Attached: ss+(2017-06-23+at+01.45.32).jpg (664x566, 305K)

I am a non programmer explain this meme.

yeah... i'm well aware of that. but describing something as a "transpiler" expresses the (rather significant) implication that the thing is not a standalone/end-to-end solution, and rather depends on one or more external toolchains/compilers/runtimes to achieve its function. it's not as though a transpiler is *not* a compiler in the general sense. it's just a more specific term for a meaningfully differentiable subset of compilers. or; all transpilers are compilers, but not all compilers are transpilers

cpus that run higher level languages exist though, which makes it kind of an arbitrary distinction

when you have a series of tests for a procedure or a module, but the procedure or module might totally fail despite passing all the tests

This actually works in GNU C

#define LAMBDA(type,def) ({ \
type __func def; \
__func; \
})

void (*funcptr)(void) = LAMBDA(void, (void) {
printf("cool\n");
});

funcptr();

There is literally nothing wrong with my equation.

Thanks for explaining. I didn't get it either just browsing by.

Can you write the one line version without writing the for loop version first?

I always have to write out at least the pseudo code for the loop first, before I make it smaller.

Will I get past this step with experiences?

I wish they'd add proper anonymous functions. C would become top tier.

I did the list comprehension first. As you get more experienced you'll be able to do it.

Unless it's something simple like
[x for x in foo]
I wouldn't worry about it too much. I'd much rather have code that is easy to debug and understand than the one liner.

in that case, such a language would be the native language of the platform, and a compiler that translated to it from some other source language would not be a transpiler, but rather an end-to-end compiler for that platform. it's not arbitrary; it's just that the distinction lies primarily at the solution and platform levels. "transpiler" implies compilation to something which is neither the native language of the target platform, nor some standard or solution-local intermediate language (like VM bytecode or a native compiler IL), but rather to the source language of the *frontend* of some external toolchain/compiler/runtime (which, notably, is generally not owned or maintained by the same entity as the one developing the transpiler, which can have caveats; legal/licensing, platform/portability, upstream/downstream, etc - also, a transpiler will be subject to the limitations of the language it compiles to, as opposed to the limitations of whatever that language in turn compiles to). so the reason for the distinction is that a transpiler is not an end-to-end solution, or even really a frontend in the usual sense, but rather essentially a frontend to a frontend

That's pretty cool. I didn't know you could define a named function in a statement expression like that. Should it maybe be static?

name collision incoming. Isn't there a gensym in GNU C? That's something they would do...

>retarded math prof who always had mistakes in proofs but asked for correct versions on midterms/final

I'm still butt-hurt about this.

You wouldnt be? You have no idea how much work is to correct or redo all proofs from scratch on subject you are jut now learning.

Nested functions have different semantics in GNU C.

Bump.

If two nested functions are named "__func", what happens?

godbolt.org/g/t3ZVPJ

The __func's get an increasing number appended to their names. Their names are not global.

#define MIN(x, y) ((x) < (y) ? (x) : (y))

void seq(int * dst, int n)
{
static int beg[] = { 1, 1, 2, 3, 4, 5, 7 };

int m = 1;
int a = 0;
int b = 6;
int j = 0;

memcpy(dst, beg, MIN(n, 7) * sizeof(*dst));
for (int i = 7; i < n; i++) {
if (i - 1 == b) {
dst[i] = dst[b] + dst[++j];
a = b;
b += ++m * 6;
continue;
}
dst[i] = dst[i-1] + dst[j];
if ((i - a) % m != 0) {
dst[i] += dst[++j];
}
if (i == b) {
dst[i] += dst[a+1];
}
}
}
Here's a solution. It takes O(n) time and O(n) memory. I'm quite certain it could be done better, but I'm too lazy for that.

If you were actually smart enough to understand those proofs you wouldn't be bothered by typos because you would know what the next step should be following the previous ones.

wew, quite surprising

When rounding the result to the nearest integer, it gives wrong results for 1, 9, 12, and pretty much every number afterwards.

how does it feel to be a cut above, /dpt/?
now that you can see the syllabus and even video lectures of MIT, harvard, ...

And to realize, "I understand that. In fact, I'm better than that."

How does that feel, /dpt/? Does it feel like you can do anything? Do you realize, that you can do anything?

>Chopin, Op. 15, No. 2 in F sharp major. Larghetto

Attached: 429px-Hasse_diagram_of_powerset_of_3.svg.png (429x325, 10K)

would be a 10/10 post but
>no smug anime girl
0/10.

Attached: 1462665702455.png (311x311, 54K)

this.

you're better than this

The only thing it makes me feel is that I'm not smart, other people are just dumb. That and the fact that perseverance and discipline, which I severely lack, are worth more than passion and intellect.

i'm better than you

Attached: 1462333217717.png (506x658, 235K)

you recognize that deficiency, that's more than most people ever think about.
You can do it, I believe in you.

What I'm about to ask is probably retarded shit, so bear with me.
I have a class that has a vector of some struct, this vector is private and only visible to the class itself. I don't want this vector to be modified by anything outside of the class, but I do want them to be able retrieve the vector and its data, so I wrote a 'get' function. My problem with this is that the vector can be quite large and returning a copy of the vector doesn't seem right, but returning a pointer to the vector is also out of the question as I don't wanna this vector to be modified by anything outside of the class.

What do I do? I there any way I can return one element of the vector at a time? I remember working with SQLite a long time ago and its object returned one line of database row at a time through a while loop. How did SQLite do that?

Attached: 89783220548.jpg (305x309, 54K)

get arduino

Above what? That diagram is fucking obvious even gender studies major would understand it. MiT and harvard have to pass people so they can justify students paying 100k. And chopin? Every arts academy faggot and wannabe cultured person listens to him.
Realize you are not above anything and go back to to studying

yes YES Y E S
youtube.com/watch?v=9cqRxo1V_OM

Attached: pawg.jpg (640x360, 129K)

i was thinking Animal by Smash Into Pieces

Return a pointer to const data or const reference.

correct

>That diagram is fucking obvious even gender studies major would understand it.
I don't understand it.

Even though the vector itself is not a constant, can I return a pointer in 'read only' mode to this vector?

Attached: 4772364446964.jpg (348x342, 16K)

Its shows that powerset is set of all subsets just follow lines....

I dunno what fucking language you're using, but what you want is called a generator

I fixed my dithering algorithm so it no longer has weird fractal artefacts from over & underflow errors

Attached: floyd steinberg pantsu.png (256x551, 37K)

Yes. Non-const pointers can be coerced into const pointers.
int x = 0;
int *p1 = &x;
*p1 = 6; // compiles fine
const int *p2 = &x;
*p2 = 10; // compiler error

en.wikipedia.org/wiki/Partially_ordered_set

youtube.com/watch?v=vKUAMHSfMOk

Attached: download (13).jpg (257x196, 11K)

I just tested it with my class and it actually worked! Thanks a lot, my negroes.

Attached: 979829882819188249.png (257x246, 90K)

>use power for power
>use hate for freedom
>use money for cruelty
>use money for cruelty
>take control and keep it, don't let go
literally microsoft, I don't know how people are overlooking this github engulfing

How long would it take me to learn japanese if I already know haskell ?

Come here you freak
I saw you crawling last night
Big erection in your hand
You rule the world
You're gonna murder somebody weak
You're gonna murder somebody weak
Strong men win at violence and abuse
Strong men win at violence and abuse
Strong men win at violence and abuse

あなたは日本語を習うことができない

>あなた
Is he your husband or something?

i stuck it in so when he put it through translate it would make sense rather than 'I can't learn japanese' as google assumes the subject

[pic related]

Yes, /dpt/-chan is my wife.

Attached: 1508701545182.png (1280x720, 878K)

bad conversation
youtube.com/watch?v=A4T8o5LS2KY

Why not use おまえ?

You are forgiven!

Attached: c905d9fa0dd06456982b3d9b44a793c6.jpg (407x750, 41K)

just forgot (and I'm addicted to baiting you's from japanese pedants, same reason I generally stick a da on the end of i adjectives)

Attached: 1468942423425.png (700x668, 350K)

karen is cute

Attached: 1509600539174.png (639x630, 262K)

*snap*

indeed

Attached: 1468490277176.jpg (2048x1152, 259K)