[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - daily programming thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 320
Thread images: 30

File: fizz-buzz-dying-in-a-fire.jpg (128KB, 1000x930px) Image search: [Google]
fizz-buzz-dying-in-a-fire.jpg
128KB, 1000x930px
FizzBuzz edition

Old: >>55214118
>>
>>55226380
First for D
>>
File: learning wpf haha.gif (182KB, 533x365px) Image search: [Google]
learning wpf haha.gif
182KB, 533x365px
I'm learning wpf
>>
Easiest way to mess around with arc files?
>>
>>55226446
Why haven't you imported MahApps with Nuget yet?
>>
File: Train-Engine.jpg (89KB, 600x350px) Image search: [Google]
Train-Engine.jpg
89KB, 600x350px
The Rust game engine project Piston seems to be getting its own scripting language, called Dyon.

http://blog.piston.rs/2016/06/07/beware-dyon/

My gut instinct tells me it's shit.

Opinions?
>>
>>55226574
The syntax looks like Rust/Go abortion, I won't even bother looking into details.
>>
>>55226547
I just started with WPF, I'll check this out cheers senpai
>>
>>55226380
That's not even a proper fizzbuzz.
The useless webdev who wrote that stupid article couldn't even be bothered to learn fizzbuzz in all the time since the failed interview.
>>
>>55226380
Going into my Junior year of a Comp Sci program and have been learning Java and SQL both in class and in my own time.

What other languages will help me get an edge when applying for jobs?
>>
>>55226574
>My gut instinct tells me it's shit.
i didn't even visit the link and i know it's shit
>>
>>55226742
java and sql are all you need for most programming jobs these days
if you want to get into webdev/LAMP you need to know php
if you want to be a software expert, you need to know c or c++
>>
>>55226596
WPF truly is wonderful. Been using it for a couple of years with MVVMC pattern. It's insanely powerful.
>>
>>55226795
>you need to know php
NOPE

nope

fuck this shit

>>55226592
>>55226777
Rust is a good language but this scripting language appears to be useless.
>>
Actually while we're on the subject, C or Rust for some gamedev fuckery?

No C++ allowed and this is a hobby project for code nerd reasons so don't tell me to use Unity you cucks.
>>
>>55226855
use unity
>>
I have 3 months to develop some java program for university, but due to travel plans I'll have to make it in one week.
It should be fine because I already know how to do it, but it will still take long just because it's java
>muh oop
>>
>>55226855
Either program it from the start in c++ or if you're not doing that use unity. What the fuck are you smoking there is no substitute
>>
>>55226855
C with OpenGL
>>
>>55226574
>fn foo() -> { return = 3 }

>Dyon has a similar object model to Javascript.
>A variable with same name shadows the previous one:
>a := 0
>a := false
>println(a) // prints `false`
AYYYYYYYYYYY LMAO
>>
>>55226855
>this is a hobby project
then just use which ever language you want to use
>>
>>55226895
>Either program it from the start in c++ or if you're not doing that use unity
What's wrong with C or Rust?

>>55226910
but I'm pathologically indecisive
>>
>>55226901
>sjw webtards in charge of making a game engine
>>
>>55226855
Python. :^)
>>
>>55226922
Unity. If it's just hobby, there's no reason not to use the tools provided for you.
Now stop whining and code.
>>
>>55226922
what's wrong with C++? are you afraid you might learn some things?
>>
>>55226812
>NOPE
>nope
>fuck this shit
yeah, that's how everyone feels about it
>>
>>55226938
if it's a hobby, a programming hobby, there no reason to use the shitty tools for kids that try to avoid programming as much possible
>>
>>55226938
Backend engine shit is why I'm interested in the first place actually. That's the reason.

I don't have characters or an artstyle or even a game in mind I just want to noodle around with vertex buffers and shit.

>>55226945
I already know C++ and I'm trying to learn some things. That's the point yo.

(although if I actually used C++ 11 and newer features for once I'd be learning some things that way too)
>>
>>55226982
Then make your own engine instead of a game?

>>55226963
Sure, unless you actually want to finish your shitty projects.
Also
>Unity
>Shitty tools for kids
God damn man. Show me something of your creation.
>>
>>55226999
kys fag
>>
>>55226999
>Show me something of your creation.
it's like I'm really in agdg
>>
>>55226999
>Then make your own engine instead of a game?
That's the plan.

Perhaps I mis-stated my intentions.
>>
>>55227011
what's the next step of your master plan?
>>
>>55227011
2d?
use c + sdl
>>
File: this.png (24KB, 618x272px) Image search: [Google]
this.png
24KB, 618x272px
How to average two floating point values in C++, /dpt/? How do I fill in pic related?
>>
how fucking pathetic can you get, literally fuck off to >>>/vg/agdg, either you failed hard to program something "from scratch" because you're a pathetic idiot who gives up when encountering the slightest resistance or you didn't even try, you're just spouting dank memes and just decided ahead of time that you're a pathetic failure

opengl and graphics programming isn't even hard ffs
>>
>>55227025
Derailing this thread... WITH NO SURVIVORS

>>55227034
Yeah that'd be pretty legit.

Rust would be my first pick in a vacuum, but having hobby projects written in C is a good "hire me" kinda thing I think - plus C is compatible with fucking everything.
>>
>>55227063
I'd accuse you of having shit reading comprehension but I'm not even sure who you're responding to. What the fuck is going on in this post?
>>
>>55227089
obviously in reply to >>55226999 (You)

idiot
>>
unity is fucking shit it's like the python of game engines, it has horrible performance, shit tier design, retarded users etc
>>
>>55227140
UR SHIT U BASTERD
>>
>>55226574
>Traditional For loop:
>shows the C loop and not the counting loop from the 1940s (which influenced Fortran, Algol, BASIC, Pascal, OCaml, etc.) which is based on the "for i = 1, ..., n" notation found in mathematical texts and known to express only the primitive recursive functions
Put it in the fucking garbage!

https://en.wikipedia.org/wiki/BlooP_and_FlooP
>>
>>55227140
I'm
>>55226855
and I said
>so don't tell me to use Unity you cucks

so believe me when I say, some good games have come out of Unity. Verdun and Kerbal Space Program come to mind.

You appear butthurt against a piece of software you don't use and I don't know why..?
>>
I am doing a small project where I want some optional local software component to talk to a browser application written in javascript.
The local applications should be written in c++.
If it was c++ to c++, I would just use zeromq, What library should I use in website?
>>
File: 1354417696292.png (56KB, 372x439px) Image search: [Google]
1354417696292.png
56KB, 372x439px
I programmed compton.conf to fix AMD tearing.

backend = "xr_glx_hybrid";
paint-on-overlay = true;
vsync = "drm";
xrender-sync = true;
xrender-sync-fence = true;
>>
>>55227319
>programmed
>set some config
>>
>>55227319
Oy oy,

what's Compton?
>>
>>55227319
>programmed
>>
>>55227353
Hey boy, Lua began as a configuration language.
>>
>>55227472
Wouldn't have minded it staying that way.
But I suppose there was a gap to fill in that age.
>>
>>55226574
>>55227181
>4D vectors:
>a := (x, y) // same as `(x, y, 0, 0)`

Boy, what a lovely idea! I can't see any possibility for memory bloat here!
>>
>>55226804
How is winchan coming
>>
So I'm trying to generate a simple square & circle depth mask, like so:

    void init()
{
for(uint32_t x = 0; x < Size; ++x)
{
for(uint32_t y = 0; y < Size; ++y)
{
float dx = std::fabs(x - Size * 0.5f);
float dy = std::fabs(y - Size * 0.5f);
//float dist = std::sqrt(x * x + y * y); // circular
float dist = std::fmax(dx, dy); // square

float max = Size * 0.5f;
float delta = dist / max;
float gradient = delta * delta;

data[x][y] = std::fmax(0.f, 1.f - gradient);
}
}
}


It works fine for the square but if I use the circle one then the output is like 1/4th of the circle in the corner, what gives?
>>
>>55227902
I have no idea what you are talking about except to note that radius is squared and 0.5*0.5 = 1/4
>>
File: DIPswitch Demo 1.gif (1MB, 640x480px) Image search: [Google]
DIPswitch Demo 1.gif
1MB, 640x480px
Today I was paused work on the level editor and worked a bit on the actual game. I focused on simplifying the networking gameplay mechanic by adding a route button. When you hit R it shows the chain of devices connected to the one you clicked. Makes the game way easier to understand. Also made pretty dialog boxes :D

What do you think /g/? I am going for a kind of gameboy aesthetic but that may change.


>>55226446
What program did you use to make the gif? I have use GIFrecorder and as you can see it places a stupid watermark over it.
>>
File: kys.png (5KB, 282x369px) Image search: [Google]
kys.png
5KB, 282x369px
>>55227990
Naw it's cool I'm a fucking idiot, I used x & y in sqrt() rather than dx & dy.
>>
>>55228001
licecap, very easy to use but for some reason it fucked up the gradient
>>
>>55228041
dy = y1 - y2
dx = x1 - x2

Calculate that and then reduce each by some amount so they are in smaller increments, and then change coords by that much until you've reached your destination.
>>
>>55226574
>home-made dsl for game scripting
it's shit by definition
>>
>>55228001
Pretty nifty anon
>>
Hi /g/. I have considering getting into programming, but what programming language has the cutest syntax? this is all that matters to me.
>>
>>55228578
C has the most minimal and syntactically consistent syntax of any language.
>>
>>55228603
>syntactically consistent syntax

top bantz, lad.
>>
File: lolc.png (106KB, 555x619px) Image search: [Google]
lolc.png
106KB, 555x619px
>>55228578
Definitely not C.
>>
>>55228625
>intentionally hard to read code is hard to read

thanks senpai
>>
>>55228623
What?
It's all consistent.
There's no operator overloading and everything boils down to an abstraction on pointers.
>>
>>55228603
that doesn't sound very cute. I like my syntax to have some personality.
>>
>>55228662
You can write cute C code as well.
>>
Learning GoLang from previously working with Python. I really like it.
>>
>>55228677
Cutesie* code.
>>
is there anything wrong with this remove node function? I always feel like I'm missing something.

    void delete(struct Node *list, int data)
{
struct Node *conductor = malloc(sizeof(*conductor));
struct Node *previous = malloc(sizeof(*previous));

previous = list;
conductor = previous->next;
while (conductor != 0){
if (conductor->data == data){
previous->next = conductor->next;
free(previous);
break;
}
previous = conductor;
conductor = previous->next;
}
}
>>
>>55228578
programming isn't cute, fag
>>
typical haskeller """humor"""

https://hackage.haskell.org/package/acme-cutegirl-0.2.0.0/docs/src/Acme-CuteGirl.html
>>
>>55228603
>>55228660
>int (*f)(int *(*)(int (*)(int *(*)(int), int**)), int**)
>{ 001, 010, 100 }
>a = b /*p; /* division? */
>a, b = b, a

https://www.gnu.org/fun/jokes/unix-hoax.html
>for(;P("\n"),R--;P("|"))for(e=C;e--;P("_"+(*u++/8)%2))P("| "+(*u/4)%2);
>>
>>55228891
programming seems cute to me.
>>
>>55228891
programming is for cute lolis
>>
>>55228735
nodeT *ListDelete(nodeT *currP, elementT value)
{
if (!currP) {
return currP;
}

if (currP->element == value) {
nodeT *tempNextP;

tempNextP = currP->next;

free(currP);

return tempNextP;
}

currP->next = ListDelete(currP->next, value);


return currP;
}
>>
>>55228677
what makes it the cutest though? I want the girly cursive handwriting equivalent of code. is that C?
>>
>>55228967
When I say cute, I mean C can describe complex algorithms in just a few keystrokes, and if you make your variable names super short, you can come out with some very small and cute C code.
>>
>>55228960

I like this but it deletes the whole list. I'll use it for inspo though, thanks.
>>
>>55229013

oops no it doesn't, very good
>>
>>55228735
void remove_list_entry(entry)
{
indirect = &head;

while( ( *indirect ) != entry )
indirect = &( *indirect )->next;

*indirect = entry->next;
}
>>
File: kebab.png (2KB, 66x51px) Image search: [Google]
kebab.png
2KB, 66x51px
Trying to generate a number from 0-5 in java but then generate a new one excluding any number from 0-5 that I pick out.
Random tileType = new Random();

for (int i = 0; i < 12; i++)
{
for (int j = 0; j < 6; j++)
{
rowsByColumns[i][j] = tileType.nextInt(5);
}
}


that is what I have to generate a number but I dont know what to do in order to exclude a single number from 0-5 (any that I want)
>>
>>55229044
Maybe use a set data type and randomly select + remove elements from it.
>>
File: uhh.png (5KB, 315x343px) Image search: [Google]
uhh.png
5KB, 315x343px
>>55228029
Not sure where I'm headed...
>>
>>55227044
float buf = (float1/2);
return (float2/2) + buf;
>>
>>55229057
a set that can be indexed by position
>>
>>55229044
simply draw again until it's different thant the one exluced
>>
>>55229057
I get that, but what I'm doing in my program is filling a 2d array with randomly generated numbers from 0-5 and I'm writing a function that prevents the same number from occurring in certain places depending on what is around it.

For example, the first row in the array is:
0 2 3 1 0 0

The program generates the rows from left to right and columns from top to bottom. Before it generates the next number, it calls a function that checks what is to the left of it. If it's the same number, it needs to reroll EXCLUDING the number next to it.

After writing this I could potentially just have it get stuck in a loop and not leave until it generates a number other than the value that is next to it.
>>
>>55229044
generate a number from 0-4,
and if that number equals the excluded one set it to 5.
>>
>>55228578
Befunge
>>
So I'm reading on WPF, do people actually manually write XAML or do they use the designer?
>>
>>55228735
>I'm missing something
yes, you're missing common sense and the point of lists
>>
how do i make a program that takes no hard drive space and uses no ram
>>
>>55229034
if your removal is not O(1) you should rethink why you're using a list in the first place
>>
>>55229544
punch card
>>
>>55229547
That's actually just something I saw in some video Linus did, think he was talking about code readability or something.
He gave two examples
remove_list_entry(entry)
{
prev = NULL;
wak = head;

// Walk the list

while( walk != entry ) {
prev = walk;
walk = walk->next;
}

// remove the entry by updating the
// head or the previous entry

if( !prev )
head = entry->next;
else
prev->next = entry->next;
}


and
remove_list_entry(entry)
{
// The "indirect" pointer points to the
// *address* of the thing we'll update

indirect = &head;

// Walk the list, looking for the thing that
// points to the entry we want to remove

while( ( *indirect ) != entry )
indirect = &( *indirect )->next;

// .. and just remove it
*indirect = entry->next;
}


Where the bottom one was the good one.
>>
>>55229547
Can you give an example of list having O(1) removal?
As far as I know lists have search time + O(1) removal when deleting in the middle, which this >>55229034 is, however it doesn't keep track of list tail, so end deletion will be O(n)
>>
>>55229690
he was actually talking about knowing enough about pointers to realize the second one is the way you should naturally write C
singly linked lists are still shit if your use case involves random entry removal, regardless of using the worthless prev pointer or doing it idiomatically
>>55229820
double linked lists just have to update 2 pointers in order to remove an element; no search; that's what you should use when you need random entry removal
>>
has there been any studies done into whether dressing as a girl actually makes you better at programming?
>>
>>55229854
Yeah
>>
>>55229886
does it?
>>
>>55229904
Indeed
>>
>>55229854
Why don't you try it and report back?
>>
>>55229916
but I can't administer myself a placebo to compare to.
>>
File: notre-dame-console.jpg (1MB, 2646x1763px) Image search: [Google]
notre-dame-console.jpg
1MB, 2646x1763px
What is the right way to do certificate verification in OpenSSL?

http://www.ibm.com/developerworks/library/l-openssl/l-openssl-pdf.pdf
This says that all I need is:

if(SSL_get_verify_result(ssl) != X509_V_OK)
{
/* Handle the failed verification */
}


But the
SSL_get_verify_result
does not return with
X509_V_OK


This is how I connect:
int connect(bot_t *data)
{
int rv;

ERR_clear_error();
rv = SSL_CTX_load_verify_locations(
data->ssl_context,
NULL,
"../certs");

if (!rv)
{
fprintf(stderr, ERR_error_string(ERR_get_error(), NULL));
return 1;
}

//SSL_CTX_set_verify(data->ssl_context, SSL_VERIFY_PEER, NULL);

ERR_clear_error();
data->bio = BIO_new_ssl_connect(data->ssl_context);

if (!data->bio)
{
fprintf(stderr, ERR_error_string(ERR_get_error(), NULL));
return 1;
}

BIO_get_ssl(data->bio, &(data->ssl_connection));
SSL_set_mode(data->ssl_connection, SSL_MODE_AUTO_RETRY);
BIO_set_conn_hostname(data->bio, data->host);
BIO_set_conn_port(data->bio, data->port);

long result;
result = SSL_get_verify_result(data->ssl_connection);

if (result != X509_V_OK)
return 1;

ERR_clear_error();
rv = BIO_do_connect(data->bio);

if (!rv)
{
fprintf(stderr, ERR_error_string(ERR_get_error(), NULL));
return 1;
}

return 0;
}


And yes, that is the correct cert directory and I did hash my certs.
Wat do?
(besides using PonySSL)
>>
>>55229945
Of course you can.
Just take off the skirt and record your observations.
>>
File: code.png (24KB, 620x398px) Image search: [Google]
code.png
24KB, 620x398px
These four vectors are still full even after I run this code. Am I doing something wrong?
>>
>>55229967
Trying to SSL connect to freenode btw.
I do have the GandiStandardSSLCA.crt and I did convert it to pem.
>>
>>55229975
that's not a placebo. Since I expect crossdressing to make me better, it might make me better just from that.
>>
>>55227181
>>55226901
>>55226777
>>55226592
>>55227504
>>55228340

Do you guys just find the most random and shitty reasons to hate stuff without even trying to find out the motivation behind its design? It's actually very cringeworthy.
>>
>>55230056
I gave a reason
>>
>>55228001

pretty good for a flash game in 2007

also linear technology called, they want their logo back
>>
>>55230065
My post pointed out your inability to read and reason properly, and you have demonstrated that deficiency again. I never said you didn't have a reason, I called your reason blatantly ignorant.
>>
>>55230016
Then go get a friend and tell them crossdressing make you dumb and make them do fizzbuzz while dressed like a girl or something.
>>
>>55229982
I was able to fix it by calling clear() on all the vectors, but I'm still worried that the memory might not be getting recycled. Anyone know what's up?
>>
>>55230081
>My post pointed out your inability to read and reason properly
nope

>I called your reason blatantly ignorant
I gave a proper reason is waht I meant to say.
>>
>>55230099
>I gave a proper reason is waht I meant to say.
Then why don't you tell me what it was?
>>
>>55230056

yes

for 90% of languages, /g/ will just judge them based on syntax entirely
>>
>>55230110
This >>55228340
>>
>>55229982
that looks terribly wrong.
>>
>>55226480
Pls answer. I'm trying to make a program to automatically translate some files and I can't find the answer on google
>>
>>55230122
can you show me that definition? I've never seen it before but if it's really there then I will recant
>>
>>55230154
Autist
>>
Does anyone know of a good resource that goes over interacting with stuff on the heap in C++, how it's done, the underlying mechanics, etc?

I'm attempting to put an empty vector on the heap. I have a pointer to it, I've passed that pointer by reference to another function. Now I don't know how to write / read from the vector, if I'm right to expect it to be able to adjust its size, etc. I also don't quite know what "->" is.
>>
>>55230162
All right, so you accept that you lost this argument? Just say so so I can add it to my collection of internet arguments won.
>>
>>55230178
turboautist
a normal person would ask why but your autism didn't let you
>>
>>55230191
No, I saw that you had no valid arguments and insulted me (and therefore didn't feel the need to humor you for it), but I still need a written confirmation that I won this argument so I can document it, preferably before this thread 404s.
>>
>>55229982
why are you trying to erase the pointer and then delete it. it doesnt work that way, you are just leaking memory.
>>
>>55230204
I did not insult you, I simply stated a fact. (the fact that you are an autist)

>I saw that you had no valid arguments
Then you can't see well, I linked you to my argument above.
>>
>>55230126
>>55230219
What should I be doing instead?
>>
>>55230234
>I simply stated a fact. (the fact that you are an autist)
Fact or not, your post's negative tone makes it an insult.

>I linked you to my argument above.
Where? I still don't see a definition of domain specific language from a reputable source that claims that they're, using your words "shit".

The only thing you've done so far is make an ass out of yourself. Just say "You win this argument" and your misery will be over.
>>
>>55230256
delete pointers first, then remove it all from the vector.
for (auto &i : Q1CP)
delete i;
Q1CP.clear();


or use unique_ptrs so you dont delete things manually.
just removing it from the vector will do that for you so you can just call
Q1CP.clear()
>>
>>55230263
>Fact or not, your post's negative tone makes it an insult.
I do not think that calling someone an autist is in negative tone but instead simply informing them of their behaviour.
Moreover I find what you are saying as weird since I found >>55230178 and >>55230204 really insulting.

>Where?
Above

>I still don't see a definition of domain specific language from a reputable source that claims that they're, using your words "shit".
This is absolutely irrelevant to the current topic. Especially considering that you did not ask me about it in the previous post.

>The only thing you've done so far is make an ass out of yourself
Wow, this is truly insulting. Don't talk to me anymore ever!
>>
>>55230077
I'll take that as a compliment.
Its actually written in GML which is very similar to Java. I looked it up and I see what you mean, the logos do look very similar but the on in my gif is the default GameMaker:Studio icon.
>>
>>55230311
>for (auto &i : Q1CP)
> delete i;
>Q1CP.clear();

Don't think that's working. My memory usage isn't going down.
>>
File: 1459500980027.jpg (33KB, 493x276px) Image search: [Google]
1459500980027.jpg
33KB, 493x276px
>>55229013
Nice stack bloat there buddy! And you managed to pass the element by value recursively too! Bravo!

Maybe next time just use a fucking loop.
>>
>>55230175
pls halp
Scanning through Bjarne's book, but to no avail.
>>
>>55229113
Use rng to "flip a coin" to decide whether to generate a number in a range smaller than the number or a range larger than the number.
>>
Is the C Programming Language 2nd edition book still relevant?
>>
>>55230808
yes
>>
>>55230929
Cool. I'm going to make C my first programming language. It's going to be fun.
>>
File: banana.png (818KB, 780x582px) Image search: [Google]
banana.png
818KB, 780x582px
>mfw realizing that an anonymous inner class is a superior abstraction over lambda expressions

Java is king
>>
>>55230808
It teaches C89, which is an older C standard. However, the differences between C89, C99 and C11 aren't massive and you could pick most of that shit up from the wikipedia articles. K&R will teach you most of what you need to know.
>>
>Wasted days of work trying to write a script for work that does what would have taken ~2hrs if I just did it the dumb way
>now i'm down to the deadline and the script still doesn't work
>>
>>55231106
>>/pol/
>>
>>55226695
>learning fizzbuzz
It's literally high-school tier easy shit.
>>
recompiled an apk using advanced apk tool. Keep getting
"syntax of command is incorrect"

it worked a month ago. now its not.
>>
Something something programming
>those goddamn Scots
>>
File: temp.png (925KB, 832x478px) Image search: [Google]
temp.png
925KB, 832x478px
this guy kinda resembles bjarne
>>
>>55231559
don't fall for the jewish establishment propaganda, the economic effects of a brexit wouldn't be that bad at all
>>
File: 1460593249353.jpg (27KB, 256x256px) Image search: [Google]
1460593249353.jpg
27KB, 256x256px
> the language is ironically typed
>>
>>55231579
we'll have to see, wont we?

>>55231573
shut up
>>
>>55231579
The jews want you to leave m8
>>
>>55230574
>>55230175

use a debugger and learn to use it
>>
>>55231603
???
>>
>>55231618
How will this make me understand the language semantics?

I don't understand how to interact with the pointer returned by new when it comes to more complicated containers.
>>
Ruby, not sure if you're still planning on making a functional language backend, but this will probably be of interest to you if you are: https://github.com/stedolan/malfunction/blob/master/docs/spec.md.
anyways, this shit is kinda cool and im probably gonna make some language that compiles to it since it looks super simple to target anyways
>>
File: ok.png (65KB, 355x328px) Image search: [Google]
ok.png
65KB, 355x328px
>>55231623
>all of these shitty appeals to emotion
>>
>>55228001
You might want to think about another way to show the connections. What you have is pretty cool, but would quickly get annoying if you had to wait for it for the entirety of a game.
>>
>>55231618
don't ever use a debugger especially not for this purpose that's a preposterous idea
>>
>>55231664
>Thinks I'm making an argument
>Thinks I'd derive any value from engaging in substantive and meaningful dialogue with your sort on any topic whatsoever
>>
>>55230175
>I also don't quite know what "->" is.
sounds like you should learn the basics.
>>
my job is making me choose /dpt/, I have to use one of these three languages running on the JVM

>Groovy
>JS (doesn't have access to most js methods but can load js files from url)
>Python

We do AI shit. What do?
>>
>>55228960
Recursion in C should really only be used for things that you can't be added to do a better way. Lists seem to be a high use datastructures, so you might want to optimize it. Especially since your method will fail for long lists or lists with large elements.
>>
>>55231745
Python
>>
>>55231756
you sure? This job uses a lot of regex an python sucks at it
>>
>>55231745
all
shit

Go with JS or Python

>>55231785
most "modern" languages with regex suck.
>>
>>55231701
okay buddy, have a good evening :^)
>>
>>55231720
I just looked it up by calling it an arrow in a search.

I'll have to think about it. I don't understand why the . operator can't just do the right thing. The compiler knows the underlying type, and that it's a pointer. Well anyway, that's pieced in.
>>
>>55231814
Probably not, but thanks.
You too anon.
>>
>>55231813
>JS
>Python
>modern languages
nigga what kinda shit u on, better get me on some of that
>>
>>55231813
python is the only "modern" language that still has to compile regular expressions
>>
>>55231919
compiling regexes is literally a good thing
>>
If Ada is so great, how come it isn't popular?
Also: Verilog or VHDL?
>>
>>55231831
it's a remnant from shitty C
>>
>>55231930
This
>>
>>55231919
>Compiling regexes into very efficient state machines is a bad thing

And it's all about the moderate climates, you want to be cold and be hot, for sure. And it's all about the moderate climates, you want to be blessed, and be cursed, for sure.
>>
>>55231970
>pyturd
>very efficient
kek
>>
>>55231953
it's not great, it's horribly verbose and redundant, plus often misses the point when it comes to code safety (which is why so many government projects end up miserably). but anyways, good languages never become popular. quoting Bjarne Stroustrup: "There are two kinds of languages: those that people complain about, and those that people use"
>>
recompiled an apk using advanced apk tool. Keep getting
"syntax of command is incorrect"

it worked a month ago. now its not.
>>
>>55231930
how exactly is it efficient? It takes more time to type out and I don't see how it helps where speed is concerned
>>
File: 1461100247077.png (1MB, 1066x800px) Image search: [Google]
1461100247077.png
1MB, 1066x800px
>>55231584

> tfw the language is secretly typed
>>
>>55232047
https://en.wikipedia.org/wiki/Finite-state_machine
>>
>>55232047
the hell are you smoking?
>>
>>55232047
? how does it take more time to type out a compiled regex? they should be exactly the same...
anyways, regexes are really slow when interpreted and can be compiled into parsers, essentially, which will perform much better since the code is already there instead of having to keep going through the regex over and over directly and evaluating it at run-time
>>
>>55232080
Even C++ compiles regexes at runtime.
>>
>>55232093
>compiles at runtime
different than interpreting them (what you're describing is JIT compilation). anyways, C++ can do it other ways too (constexprs can probably be used to compile the regexes beforehand) and lots of fast languages do this (Rust, etc.).
>>
>>55232108
I know. Obviously.
>>

def foo():
def bar():
print 'hello'



how to print hello with this code?

foo().bar() ?
>>
>>55232160
I'd imagine you could probably only call it from inside foo()
>>
>>55231831
because that would make it harder to differentiate between pointers to structs and actual structs
>>
>>55232093
>>55232108
Implementations do this, not languages.
Faggot
>>
>>55232160

you would have to call it inside of foo and then call foo

only a class would have a function called like that.
>>
>>55232279
Okay, you got me. It's actually the STL and not the core C++ language.

By golly by gosh the fool I was not being more explicit.
>>
>>55232307
>It's actually the STL
No, implementations of the STL.
>>
>>55232318
The STL is part of the C++ standard. Conforming compilers have to include a functionally equivalent version, at least as far as behavior, interfaces, and guarantees.

eg, if the flag to spend more time optimizing regex compilation is omitted, your implementation of the STL is no longer standard conforming.
>>
>>55232318
the "library" of "standard template library" implies that it is the implementation.
>>
>>55232363
No, not at all. This is the most retarded thing I heard today.

>>55232346
>Conforming compilers have to include a functionally equivalent version, at least as far as behavior, interfaces, and guarantees.
Exactly

>eg, if the flag to spend more time optimizing regex compilation is omitted, your implementation of the STL is no longer standard conforming.
I am not aware of any flag that gives the command to the implementation to compile the regexes. But even if it existed and the implementation ignored it it would still be standard conforming.
>>
recompiled an apk using advanced apk tool. Keep getting
"syntax of command is incorrect"

it worked a month ago. now its not.
>>
>>55232387
>I am not aware of any flag that gives the command to the implementation to compile the regexes.
If you use the STL regex deal, to my knowledge they're always compiled at runtime. The optimization flag just has it better optimize that compilation, which might be worth the cycles if you're going to be search a very large dataset.
>>
>>55232418
>to my knowledge they're always compiled at runtime
Not guaranteed by the standard, it depends on the implementation.

> The optimization flag just has it better optimize that compilation, which might be worth the cycles if you're going to be search a very large dataset.
The optimization flag is just a hint to the implementation and is not guaranteed to do anything.
>>
File: 1451337320315.jpg (25KB, 400x386px) Image search: [Google]
1451337320315.jpg
25KB, 400x386px
O U T
U
T
>>
What's hap'nin /dpt/?


Nth for Wales
>>
>>55232807
>>55232944

The sun rises over an independent UK.
>>
>>55232997
Get cancer
>>
>>55233007
kys
>>
>>55233011
nice meme faglord
>>
>>55233098
EU is the meme, fag
>>
>>55233007
Not funny or clever.
>>
>>55233127
It's not supposed to be funny.

>>55233124
Nice ignorance, kike.
>>
File: Programming Shelves.png (952KB, 2100x1400px) Image search: [Google]
Programming Shelves.png
952KB, 2100x1400px
What's the best programming language and why is it Excel formulas?


>>55233007 >>55233011 >>55233098
>>55233124 >>55233127 >>55233148
>>>/b/
>>
>>55233148
you're fucking retarded, EU is pushing the jew agenda with the banking and mass immigration and race mixing etc, you've gotten this completely wrong, you have no reasoning for why the jews in the establishment would want people to leave the EU
>>
>>55233160
Scheme

>>55233164
Nice try kike.
>>
>>55233148
>It's not supposed to be funny.
Cancer sucks.
>>
>>55233176
not sure if trolling or just retarded

you're not saying much useful by just calling people kikes
>>
>>55233180
I wouldn't use it if it din't.

>>55233183
Either are you by memeing.
>>
>>55233190
*Neither
*didn't
I need to sleep.
>>
>>55233190
fuck off and die idiot, the EU is fucking cancer and anyone with a brain can see it, the leave side had a large majority outside of londonistan and scotland
>>
>>55233210
And the leave side was fucking stupid. No wonder why the Scottish people are liked everywhere in the world unlike the English.
>>
>>55233225
stay delusional queer
>>
>>55233226
Kill yourself carposter.
You are either a retarded American Trump supporter or a faggot and even more retarded Englishfag.
>>
>>55233255
lmfao stay buttmad fucking faggot spic

we got brexit

hopefully we can also get these:
>austrian re-election because election fraud/"mistakes"
>other countries follow suit in leaving the EU
>donald trump becomes the US president
>EU gets dissolved
>countries implement concentration camps to deal with illegal immigrants
>SJWs BTFO

feels good :)
>>
>>55233269
>spic
I am more European/White than you will ever be.

>donald trump becomes the US president
So, you admit being a homosexual normalfag. Why do you support NSA spying and the end of the individual freedom?
>>
>>55233291
you're either doing some very weak troll or you're really this stupid

you think shillary is better than trump for non-fags in any way?
>>
>>55233304
>you think shillary is better than trump for non-fags in any way?
Didn't imply that in any way.

>image
I know for a fact that many of these parties are by and for faggots. (not all of them though, at least one of these is actually good)

But you still did not reply to my question, Why do you support NSA spying anon?
>>
>>55233323
in the US, the only likely candidates that should be considered are trump or shillary, you have no other options unless something really surprising comes up which you have no reason to expect

and you're a fucking idiot, just calling the wrong people kikes and faggots, i'm done wasting my time on you
>>
>>55233333
Why do you keep refusing to reply to my one and only question? Maybe because you are an NSA shill?
>>
>>55233333

I feel as though these quints need to be checked, Anon.
>>
>>55230968
y tho
>>
>>55230968
tard
>>
>>55230968
1/10 Nobody is that retarded.
>>
>>55230968
>>superior abstraction
They're different things.
>>
File: floop.jpg (151KB, 509x347px) Image search: [Google]
floop.jpg
151KB, 509x347px
I'm back about my earlier post >>55229044

I've gotten to this spot in my program and at a complete loss.

        int[][] rowsByColumns = new int[12][6];
Random tileType = new Random();
int cnt = 0;
for (int i = 0; i < 12; i++)
{
for (int j = 0; j < 6; j++)
{
if (cnt == 0 || cnt == 1 || cnt == 6 || cnt == 7)
{
rowsByColumns[i][j] = tileType.nextInt(5);
}
else if (cnt != 0 || cnt != 1 || cnt != 6 || cnt != 7)
{
rowsByColumns[i][j] = tileType.nextInt(5);
if (rowsByColumns[i][j] == rowsByColumns[i-1][j] && rowsByColumns[i][j] == rowsByColumns[i-2][j])
{
while (rowsByColumns[i][j] == rowsByColumns[i-1][j] && rowsByColumns[i][j] == rowsByColumns[i-1][j])
{
rowsByColumns[i][j] = tileType.nextInt(5);
}
}

}
cnt++;
}
}


I have a 6 column by 12 row 2d array. I generate values from 0-5 (6 possible values) and assign them to each spot in the 2d array reading values in from left to right and top to bottom.

the first 2 rows ignore the [0][0], [0][1], [1][0], and [1][1] spots

a visual of this:
x x o o o o
x x o o o o

x being the ignored spots in the 2d array. They can be any number generated from 0-5.

The thing I want though is when it reaches one of the o's, I want it to randomly assign a number from 0-5 and then check what the two values to the left of it are. If the two x's are the same randomly generated value, it will reroll the o's value until it does NOT equal the two to the left of it.

Basically while it generates the numbers for each spot in the array I do not want 3 in a row horizontally. That is not allowed. It must reroll the value until it is different.

Can anyone spot why I'm getting an array out of bounds -1 when I start doing stuff like this rowsByColumns[i-1]
>>
Working on some GUI programming with Tkinter.
And it's ok...
Documentation is spotty but the library also seems sort of intuitive.
>>
>>55233457
Little paste error on
while (rowsByColumns[i][j] == rowsByColumns[i-1][j] && rowsByColumns[i][j] == rowsByColumns[i-1][j])
the last rowsByColumns[i-1] should be i-2.
>>
>>55233457
>
                    rowsByColumns[i][j] = tileType.nextInt(5);
if (rowsByColumns[i][j] == rowsByColumns[i-1][j] && rowsByColumns[i][j] == rowsByColumns[i-2][j])
{
while (rowsByColumns[i][j] == rowsByColumns[i-1][j] && rowsByColumns[i][j] == rowsByColumns[i-1][j])
{
rowsByColumns[i][j] = tileType.nextInt(5);
}
}

that outer if is pointless. you should use a do while() loop;
do {
rowsByColumns[i][j] = tileType.nextInt(5);
} while(rowsByColumns[i][j] == rowsByColumns[i-1][j] && rowsByColumns[i][j] == rowsByColumns[i-2][j])


else if (cnt != 0 || cnt != 1 || cnt != 6 || cnt != 7)

is always true. just make it an else.
>>
>>55233333
>>55233352
Waiting
>>
>>55233537
That's nice and all but doesn't solve the out of bounds issue
>>
>>55233537
also you could stick the first if into the while because it always calls nextInt.

>>55233572
thats because there was no checks to prevent that,
im guessing thats what cnt was trying to do, but it wasnt being reset and is just pointless. just use i instead

anyway the inner for loop should be
do {
rowsByColumns[i][j] = tileType.nextInt(5);
} while(
i >= 2 &&
rowsByColumns[i][j] == rowsByColumns[i-1][j] &&
rowsByColumns[i][j] == rowsByColumns[i-2][j]
);
>>
>>55233603
Well, cnt counts up to 72. 12x6 so there's 72 total numbers that need to be generated.

cnt is there to check for the first 2 spots in the first two rows. In the third row and all the way up to the last 12th row I want to be checking the two tiles above each spot to make sure there's no vertical 3-in-a-rows too.

x x o o o o
x x o o o o
p p i i i i

there's the entire board. x's are ignored and can be any generated value from 0-5. the o's in the first two rows with the x's will begin checking what the two blocks to the left of them are. If they are identical, this value must be rolled until it is NOT the same as the identical ones next to it.

Now, p's only check the two above them. i's check to the left of them AND on top of them.

I feel like I'm misunderstanding the layout of a 2d array or something.
>>
>>55233749
then you just check both ways, and check i/j if it will go out of bounds.
do {
rowsByColumns[i][j] = tileType.nextInt(5);
} while(
(i >= 2 &&
rowsByColumns[i][j] == rowsByColumns[i-1][j] &&
rowsByColumns[i][j] == rowsByColumns[i-2][j]) ||
(j >= 2 &&
rowsByColumns[i][j] == rowsByColumns[i][j-1] &&
rowsByColumns[i][j] == rowsByColumns[i][j-2])
);
>>
>>55233749
This is my understanding of 2d arrays.

if rowsByColumns is a [12][6] 2d array, you have this as a board to store values.

([0][0])([0][1])([0][2])([0][3])([0][4])([0][5])
([1][0])([1][1])... etc

is this right? is my double for loop incorrect with it's variables?
>>
>>55233774
that seems to have completely fixed the horizontal and vetical 3-in-a-rows from happening.

I really appreciate it, but may I ask for an explanation of what this snippet of code means?

still trying to wrap my head around modifying the spots in a 2d array using variables i and j
>>
File: in_the_rain_by_keapt.jpg (83KB, 750x375px) Image search: [Google]
in_the_rain_by_keapt.jpg
83KB, 750x375px
I need to make the jump to regular basic C programming and Data Structures programming. But I just can't begin, /g/. I need to be ready for an examn in a week. All the way from stacks to linked lists to trees and I know nothing.

I want to cry.
>>
>>55233878
to make the jump from regular C programming to Data Structures programming*

Jesus, I can't even properly write.
>>
>>55233333
Still waiting
>>
>>55226574
why do some game engines have their own languages? They're almost always shit. why not use lua, python, lisp, ...?
>>
>>55233966
>lua, python
Both shit

>lisp
Best solution
>>
>>55233972
>lua
>shit
>>
>>55233859
it just checks for 3 in a row/column and regenerates the number as long as there is one.

and i/j are just coordinates in a 2d array.
  0 1 2
0 a b c
1 d e f
2 g h i

arr[0][0] == a;
arr[1][0] == b;
arr[0][2] == g;
>>
>>55233980
Yes, it's fucking shit.
>>
Why is Java for the trash?
>>
Dudes, I need some help. I have this:

<div><img src="" /><p>0</p></div>

Every time I click on the div, I need to add 1 on p. One click = 1, two clicks = 2, something like that. I'm doing it with js, but I think my code is pretty shitty.


var ECONTADOR= contador.getElementsByTagName('div');
for(var i = 0; i < ECONTADOR.length; i++)
{
ECONTADOR[i].getElementsByTagName('img')[0].onclick = suma;
}

function suma()
{
d.getElementByTagName(img).getElementsByTagName('p')[1].innerHTML++;
}
>>
File: vcxccx.jpg (8KB, 241x172px) Image search: [Google]
vcxccx.jpg
8KB, 241x172px
>>55234023
It's 3 am, my brain doesn't work anymore.
>>
Bit fields are more or less just syntactic sugar for manually masking, right? Behind the scenes you are still doing all of those bitwise ands/etc?
>>
>>55234161
no
>>
>>55234176
How do bit fields work differently from using masking to set/get individual bits, assembly style?
>>
File: fizzbuzz.png (10KB, 478x165px) Image search: [Google]
fizzbuzz.png
10KB, 478x165px
>>55226380
this my fizzbuzz in powershell
>>
>>55234161
Bit fields effectively provide per-bit addressing
Of course you're correct that bitwise operations are used for this
>>
>>55233545
he probably works for the nsa so there you have it
>>
File: smug moss.jpg (3KB, 125x122px) Image search: [Google]
smug moss.jpg
3KB, 125x122px
>>55234196
>else if
>>
>>55234184
how do bit fields work differently than any other variable?
>>
>>55234212
I can't control how the language works
>>
>>55234222
>first class functions

>>i can't control how the language works
>>
>>55234196
>windows
do you hate yourself?
>>
>>55234243
It pays the bills.

>>55234233
what are you on about? I'm a sysadmin and mostly just do scripts, I wrote this fizzbuzz in about 30 seconds.

Anything other than elseif in powershell wouldn't work.
>>
>>55234198
Neat. Thanks.

>>55234216
I assume they don't and that when you address them what actually happens is bitwise and(+shift for a multibit field) on a read and a bitwise or on a write. Well, overflowing's a bit different.
>>
>>55234266
>It pays the bills.
like everything
>>
>>55234291
It's one of the dangers of working in a smallish (400 employees) company, you have to do a lot of different things.

As such, I do all linux/windows on the west coast, I don't get to specialize.

I also get to spin up my own vms whenever I want, unlike some places I used to work.
>>
Working on some pretty groundbreaking CS research and having kids on 4chan tell me that I'm a fraud and they can do this in 30 minutes.

I think I'm starting to outgrow this place...
>>
File: categorised monad haskell.png (95KB, 1463x677px) Image search: [Google]
categorised monad haskell.png
95KB, 1463x677px
r8 my monad
>>
File: categorised monad 3.png (28KB, 771x287px) Image search: [Google]
categorised monad 3.png
28KB, 771x287px
>>55234372
>>
>>55234372
Isn't this just a writer monad?
>>
>>55234516
I haven't used it, it might be similar, but this gives a set
>>
>>55234372
>seperator

Just kill yourself please
>>
>>55234313
Rewriting Linux kernel in tensorflow?
>>
File: image.jpg (104KB, 750x606px) Image search: [Google]
image.jpg
104KB, 750x606px
>>
>>55234609
Efficient global blackbox algorithm for optimizing arbitrary sequences of binary data. This shit can design you optimal gene sequences, mechanical parts, or whatever else you want the bit sequences it outputs to represent. All you have to do is score its suggested outputs with your fitness function. It needs no insight into the nature of the problem.

It's sort of like a genetic algorithm but way less shitty.
>>
Suppose I have a mathematical function. For example, glomerular filtration rate:

https://en.wikipedia.org/wiki/Renal_function#Glomerular_filtration_rate

GFR = (U x F) / P
GFR : volume / time (glomerular filtration rate)
U : mass / volume (concentration in urine)
F : volume / time (flow of urine)
P : mass / volume (concentration in plasma)


What is the technique to be used if I want to:

1. Store this knowledge (and many others) in my system
2. Read and parse arbitrary input from the user
3. If I detect that the user has supplied all of the above parameters
3.1. Automatically calculate and display the result

I'd be surprised if this were a new idea. I think I'm having trouble identifying it.

The whole thing should be chainable. In that example: doctors often order blood tests and urine tests. Creatinine is often used as the substance, and urine flow is determined from epidemiological data I can automatically extract from reports.

So, if given the creatinine parameters from the test and patient anthropometric data, it can derive appropriate values for that formula and automatically compute a result. Further: renal function can be classified based on this result. This system would digest a bunch of numbers and produce a high level assessment of renal function according to the same rule we use in medical practice.

This looks so simple when I think about it, I'm surprised doctors aren't using something like this. Much of our reasoning comes down to this

What am I looking for?
>>
>>55234717
Also it's gradient free.
>>
I'm working with a game framework that among a great deal of other things does simple sprite drawing on screen. I'd like to extend it to handle shaders as simply as possible and I'm thinking I'd just insert a function pointer call which does some gl* calls like glUseProgram(ShaderRef). Which you can optionally provide (not sure if having a stub by default or having a condition to check if it's valid is smarter).

Code looks something like this
glPushMatrix();
glTranslatef(_position.X, _position.Y, 0.0f);
....

glVertexPointer(2, GL_FLOAT, 0, _circleVertices);
glTexCoordPointer(2, GL_FLOAT, 0, _circleTextureCoords);
glDrawArrays(GL_TRIANGLE_FAN, 0, CIRCLE_DRAW_SECTIONS+2);
....
glPopMatrix();


I'm not sure if this is sensible or not. I'm not that comfortable with opengl yet. I've only just done some basic rendering stuff with GLEW/GLFW.
I think it makes sense though.
>>
whats the best resource for learning python in a way that also introduces you to math and the common programming concepts?

Im a vfx guy, in this program houdini we use VEX which is kinda similar to C++ and I do understand basic principles but really I see some amazing shit done by guys like looping over points and i get quite lost with while loops and all that kind of stuff. I figure python is a good place to start before I try something like processing or C with openGL.
>>
>>55234645
kek

>>55234772
don't learn maths from programmers, learn it from mathematicians
>>
>>55234785
Numerical methods > closed form mathematics

>>55234772
Get a numerical methods textbook and start learning either Matlab or Octave
>inb4 CS weenies tell him to study some webdev-tier language
>>
>>55234736
>Store this knowledge (and many others) in my system
Translate the algorithms into code and have each associated to a function. And an associated list of ID's for the variables used so you can check if you have what's needed to run it.
>Read and parse arbitrary input from the user
Well it can't really be arbitrary. They need to follow some kind of format, if i write:
UFP831823

You can't just assume U=83 F=18 P=23
But yeah you want some kind of format where the user can provide all possible arguments or a subset. That's very basic argument parsing.
>If I detect that the user has supplied all of the above parameters automatically calculate and display the results
When you parse your arguments you have them associated with a list of id's (say an enum with ENUM_FLOWOFURINE in an array of ints). You then search the array to see if the function can get all that's required and then pass the arguments to the function.
The easiest way to do this would be

enum VARS{
VAR_FLOWOFURINE,
VAR_CONCENTRATIONINPLASMA,
...
}

And then for your function you do something like
GFR(VarStorage[VAR_CONCENTRATIONINURINE],VarStorage[VAR_CONCENTRATIONINPLASMA],VarStorage[VAR_CONCENTRATIONINPLASMA]);
void GFR(concUrine,urineFlow,concePlasma){
//Do the stuff
}


You can even have the program solve for the provided variables by having a VAR_SOLVEFOR. Checking for that for every variable that's provided and then solve for that value. You can have GFR be a fourth argument. If you want you can always provide GFR if available and check if it matches with the calculated value.
>>
>>55234872
Oh by the way I'm assuming we have a lot of different functions here.
>>
>>55233997
Kill yourself.
Lua is a very nice scripting language.
>>
>>55234922
>babby has fallen for the meme
>>
>>55234948
Not him, but you're a retard.
>>
>>55234872
>Translate the algorithms into code and have each associated to a function

Done.

>associated list of ID's for the variables used so you can check if you have what's needed to run it.

What is this process?

I imagine I'd have to encode the meaning/context of each variable somehow. Using SI units are insufficient.

Do I need to study type theory? Or is that going too deep?

>Well it can't really be arbitrary. They need to follow some kind of format, if i write:

Don't worry about the parsing problem. This is actually the most interest part of this, and it's really exciting to work on it, but I want to understand how to process the data afterwards.

Assume I have a working algorithm which processes user input like patient history and gives you a data structure with the relevant data in something like JSON.

What I want to understand is how to put this data into the system in a way that it makes the most of it given the right knowledge. It looks at the data, sees all the parameters it needs for starting the process and executes it, getting more and more results and chaining more and more functions until it a final answer is reached.

>have them associated with a list of ids
>You then search the array

I don't think I understand how you're implementing it. What array? How does the algorithm determine that it has all the arguments?
>>
What is the point of immutable objects/strings/anything?
Is there some actual use?
Can't you just not change the value? What the fuck?
>>
>>55234991
Some would argue that mutable strings would cause more error-prone code, but I disagree that's a valid tradeoff
>>
>>55234991
You can. In fact, the language implementation does just that: it simply doesn't change the value under the hood, where changing the value is certainly possible.

Immutability is about guaranteeing the value can't be modified within the language. So that concurrency can become easy to program at the cost of copying data whenever you modify it.
>>
>>55234991

The compiler can optimise itself a lot if it knows certain variables won't be edited, and thus, don't need to be copied to functions they are passed to.

Or you can shoehorn immutability into a language that doesn't have such abilities and you have PHP and JS circle jerking over a useless feature.
>>
>>55234980
>How does the algorithm determine that it has all the arguments?
Well my solution is kinda obvious so I'l describe that first. But I'm suspecting your system is more generic maybe.

So my idea is that you
parse->slot _predetermined_ (like what your example was) variables into an array->see what can be computed and compute it 

So assuming parsing works and you identify say flowofurine.
You can have an array of maybe doubles where you want to store the value of flow of urine.
Additionally you probably want an array of bools to see if the value was available. So since you have predetermined what variables the program will take you can construct an enum (or equivalent in whatever language you use) for it. And then index VarStorage (which stores the actual values of the variables) and VarCheck (which stores if it was available or not).
Then, when you want to compute GFR that required concentrationInUrine ... you just check if VarCheck[VAR_CONCENTRATIONINURINE] and the others are valid and then call the function like:
GFR(VarStorage[VAR_CONCENTRATIONINURINE],VarStorage[VAR_CONCENTRATIONINPLASMA],VarStorage[VAR_CONCENTRATIONINPLASMA]);


Basically the enum is your ID's. If you want you can put the VarStorage and VarCheck at global scope and keep all the checks within GFR. I'd probably do that because it's easy to make mistakes if it's not contained like that.

So. The entire process
Before the program starts: You've encoded every variable that you accept (like flow of urine) as an enum or ID of some form. You've constructed two arrays, one for the variable types and one just containing bools to check if the variable is available.
When the program runs you parse the information passed, when you've determined that you have a variable you insert it into the array where you store the variables and set the corresponding bool array location to true.
VarStorage[valueID]=parsedValue;
VarCheck[valueID] = true;
>>
>>55235091
Assuming varcheck is default false.
>>
So, what do now, I wanted to start my bachelor in the UK next year.
>>
>>55234980
>>55235091
>>55235097
>Do I need to study type theory?
No. That's far too deep. Since all you're doing is math double is sufficient.
Suppose there could be some computations where you want integers.

I'd solve that by just making a union type
union Datatype
{
int Integer;
double Double;
SomeStruct TheStruct;
};

And just have the entire value array be of type Datatype. The functions what type they wanted. So they just do Datatype.Double for instance.

But I doubt you actually need that.
>>
>>55235115
I know. All those disgusting UK girls will be bothering you all the time now that their GBP is going through the floor and your indian rupee makes you a very wealthy man.

You could probably hire bodyguards though.
It's not too bad.
>>
>>55235013
Some people think strings are somehow different from character/byte/octet arrays when they're the exact same thing.

String functions have been fucking idiots in the mindhole since the beginning of computing as we know it. High level languages have utterly stupid string types with convenience text processing functions that comically fail at the slightest hint of unicode. Even in C where the distinction is painfully clear, the smart thing to do is to treat the already extremely basic str* functions as buggy, insecure versions of the much more useful mem* functions.

>>55235091
So let me see if I have the general idea straight.

1. Encode knowledge as functions taking arguments of specific types/contexts
2. Receive data with type/context information associated
3. Attempt to exhaustively match all data points against all function arguments
4. Collect all matching functions and their data
5. Apply the functions to their data
6. Store/report results

Is C really the right tool for the job here?
>>
>>55235137
http://www.docs.sasg.ed.ac.uk/fees/undergraduate_2016-2017.cfm?sorter=Programme_Name
My main worry is that I'll suddenly have to pay the overseas fees instead of the EU fees. Edinburgh is just an example.
>>
>>55235149
>Is C really the right tool for the job here?
I dunno but this stuff is really simple and I don't see an issue using it. I'm just not conveying it well apparently.
Maybe a complete program is simpler to understand.

typedef enum { //These are integers, we can index an array with them
VAR_CONCENTRATIONINURINE,
VAR_WHATEVERVAR,
VAR_ANOTHERWHATEVERVAR,
//we will have tons of varaibles I'm assuming
MAX_VAR_COUNT, //hey this is convenient
COULDNTPARSE //should probably have this
}
variables;

double VarData[MAX_VAR_COUNT];
bool VarCheck[MAX_VAR_COUNT];

int main(int argc, char* argv[]){
//pretend this is parsing:
for(int i =0; i<argc;i++){
int result= figureOutWhatThisIs(argv[i]); //result is one of
if(result!=COULDNTPARSE){
VarData[result]=stringToDouble(argv[i]);
VarCheck[result]=true;
}
}
//When we get here we will have two arrays, one with all the doubles (VarData) and one with bools

if(VarCheck[VAR_CONCENTRATIONINURINE]&&VarCheck[VAR_WHATEVERVAR]){
MyPretendFunctionThatStoresTheResultsOrPrintsIt(VarData[VAR_CONCENTRATIONINURINE],VarData[VAR_WHATEVERVAR]);
}
//Do the same thing for every function you wanted to compute
return 0;
}

It's not more complicated than that.
>>
>>55235219
>
//result is one of 

result is one of the enums.
>>
>>55235219
This is not data-driven. If I implement it using C enums, I can't modify the knowledge base later. At least not without rebuilding the whole thing.

Ideally I would be able to just write the rules at runtime and have them transparently persist along with all the data.
>>
>>55235248
Sure. Replace the C enum with some other structure and have it index the array based of that. malloc the arrays instead of statically declaring them.

I don't see the issue. Did you want to automatically translate math into code? That's been done but I don't know any good sources for that.

Just passing around this data isn't hard though.

If you want to define your functions somehow (lets say XML) and have the program be able to recognize the variables needed and match them well that will be very difficult. Stay away from C then.

But that's a very ambitious project. And frankly I don't see how much use it will be to have a program like that. How problematic is rebuilding really? Calling GCC once? Are you predicting you will be adding new stuff all the time and building would be a massive hassle compared to implementing this very complicated markup language/data format which defines functions, their arguments, variables and the algorithm to compute the result?

I'm not saying you should't go do that but it sounds like you're just making up excuses to do it. That's fine, I certainly wouldn't want to discourage you form doing something that complicated. It gets you a lot of experience I'm sure. But I just wrote the simplest solution assuming I wanted to get done.

Also worth noting that if this is for convenience if you write some markup you're gonna have to check it for errors. And then you might as well just have it all be in C and compile it every time automatically (write a program that does a system call to GCC and then run the produced executable). Because if you have problems in C code you can probably figure it out easily.
As mentioned I'd probably place the checking inside the functions rather than outside like in my example (didn't want to write a function definition).
It will be very similar to a markup solution except it's in C and requires you a second of wait every run because of GCC.
>>
I'm already very familiar with programming, what's the best online course/website to learn Python 3 from?
>>
When an animated entity is created it checks whether the texture it needs has already been loaded and loads it if it wasn't. What's the quickest way to check whether a given texture has been loaded? Hashtable with the IDs of loaded textures? Alphabetic binary tree?
>>
>>55235622
>Hashtable with the IDs of loaded textures?
Go with a hashtable.
You could just have a big array of bools if you know you don't have a massive amount of textures and check if the texture ID is available.
void glGenTextures(GLsizei n, GLuint * textures); 

What you get back in 'textures' here. Dunno what to call it.
>>
>>55235678
I meant to say if you have an array of bools you can index by the ID and set/unset the value.
>>
>>55235701
Let me post the correct link this time:

New thread:
>>55235694
>>55235694
>>55235694
>>
>>55226380
I just started c++. I have no previous code experience and I'm toying with codes and stuff.

This thing wont compile and I can't see why

 #include <iostream>

using namespace std;

int main()
{
int n, sum = 0, c, value;

cout << "num" << "\n";
cin >> n;
cout << "Insert " << n << " Integer" << "\n";

for ( c = 1; c <= n; c++)
{
cin >> value;
sum = sum + value;
}
if (sum + value > 20)
{
cout <<"the sum is more than 20 " << sum << ; // it stops here.
} else {
cout <<"sum of the integers = " << somma << "\n" << "and it's less than 20" ;
}


return 0;
}



Expected primary-expression before ';' token.

I know this might seem stupid as fuck but I just started.
>>
>>55235736
>
cout <<"the sum is more than 20 " << sum << ; // it stops here.

This line.
Also when reporting error messages report what line.
The
<<

is an operator. What you've written is similar to :
int i = 5+4+3+;

Which is a bit problematic as you can see.
>>
>>55235755
Also 'somma' isn't a thing. you probably mean sum.
>>
>>55235755
Okay, now it works. Thanks.
I need to be more careful.
>>55235761
yeah I wrote it and then rewrote it to post it here. It's sum
>>
>>55235770
>I need to be more careful.
No that's the exact opposite of what you need to do.
You need to be less careful. Don't write code carefully. Write it and have your compiler correct you if you're wrong. You will learn to see the obvious errors quickly. But don't let things like this distract you.

If it ever distracts you to think about these things simply stop caring about them and write the code according to the logical idea you have and then correct it.

It's what any good programmer will do.
>>
>>55235770
>I need to be more careful.

no, you dont, learning by making errors is the best to learn programming
>>
File: tehboxnoob.png (13KB, 399x464px) Image search: [Google]
tehboxnoob.png
13KB, 399x464px
android faggs here?

how fucked am I if I want to reorganize my classes in separate files (but under same package)? is there a possibility that I will fucking things up (like paths and names in other files)?
>>
>>55228001
How do you about actually go about making dialog boxes? I can never get it right when I try to make them (in C). Any tips/tricks?
Thread posts: 320
Thread images: 30


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.