[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: 367
Thread images: 33

File: K&R himegoto waifux2.png (1MB, 1000x1400px) Image search: [Google]
K&R himegoto waifux2.png
1MB, 1000x1400px
old thread: >>56697751

What are you working on, /g/?
>>
how to make a tree in c?
>>
>>56706940
>Degenerate shit
Delete this thread an kill yourself.
>>
>>56706949
first you need to seed the ground

srand(3);
>>
Android apps
>>
finished writing the static site generator for my blog a while ago, but im too lazy to add a stylesheet right now so all the generated shit looks like cancer
>>
>>56706949
There's a nice, small implementation in the book "The practice of programming".
>>56706940
Just doing some tedious shit in C#.
>>
I love anime desu senpai
>>
>>56706940
Whats an alternative to goto in python?
>>
File: akari2.jpg (58KB, 514x524px) Image search: [Google]
akari2.jpg
58KB, 514x524px
akari-bbs rev. 11 is now live!
http://akaribbs.mooo.com/

Added in this update:
>Rotating banners
>Interactive linkquoting
>404 page
Also, I released it GPL.
https://github.com/microsounds/akari-bbs
>>
How do I make a python script restart when it reaches the end?
>>
>>56707013
Why would you need that? Just loop your program logic.
>>56707003
Naice that you actually released the source, good work.
>>
I'm getting tcc: error: no input files in cmd. Help.
>>
>>56707035
just use gcc you fucking autist

>>56707013
while (1)
{
/* your shit */
if (some_condition)
break;
}
>>
File: beautiful passing trap.jpg (58KB, 640x480px) Image search: [Google]
beautiful passing trap.jpg
58KB, 640x480px
>>56706940
Daily reminder that your qt3.14 trap >waifu looks like this IRL
>>
File: Calculus of Maki Constructions.png (312KB, 452x355px) Image search: [Google]
Calculus of Maki Constructions.png
312KB, 452x355px
>>56707045
hott
>>
>>56707003
>
/* global constants */
const int NAME_MAX_LENGTH = 75;
const int COMMENT_MAX_LENGTH = 2000;
const int COOLDOWN_SEC = 30;
const int POSTS_PER_PAGE = 50;
const char *default_name = "Anonymous";
const char *database_loc = "db/database.sqlite3";

You should use constants like that in C. You're unnecessarily allocating space and can't use them in things like switch statements.
You may be confusing it for how C++ constants work.
>>
File: cumfy.png (15KB, 720x400px) Image search: [Google]
cumfy.png
15KB, 720x400px
Q: Best language to use while drunk on a weeknight?

I submit VB, since it really is quite comfy.
>>
>>56707069
wow a whole 16 bytes wasted
>>
>>56707083
The real issue is that it doesn't work in the places that a constant can.
For example, you can't do
const int a = 10;
switch (b) {
case a:
...
}

in C.
>>
File: 1470269867365.jpg (17KB, 264x277px) Image search: [Google]
1470269867365.jpg
17KB, 264x277px
>using a meme language like C
>>
>>56707108
Why would I use a switch case?
>>
>>56707109
what you use?

stop false flagging, akkarin
>>
>>56707124
There are other cases in C where a constant may be required.
A case statement is just the most obvious.
>>
Learning rust because im too retarded to learn c++
>>
>>56707144
>too retarded
too smart*
>>
>>56707040
http://mirrors-usa.go-parts.com/gcc/releases/gcc-6.2.0/

Which of these do I snatch? I just deleted an 800-something MB folder because it didn't have the executable file. On win8
>>
>>56707147
>too smart
*"too smart"

captcha is alabama
>>
>>56707144
Actually R is safer and highly recommended for programming than c++
>>
>>56707133
>There are other cases in C where a constant may be required.
I haven't really had this problem.

>>56707149
Why can't you just install it from your package manager?
>>
>>56707144
Really, what C++ really means is D.

So you should use D.
>>
>>56707158
>safety

can some lisp fags tell me why lisp is so good?
explane like I'm retard
>>
i have a SA certification and some college but no degree.
Should i go for a bachelors degree in computers or just get another certification, this time in C#.net.
I crave to learn programming but im not a self starter much. plus i would be retaking some classes i took for my first cert but i also would be taking more in depth classes and learning some more skill.
>>
>>56707165
const char C = 'B';
C++; -- C
>>
>>56707161
Damn, I'm stupid. What package manager?
>>
>>56707144
Speaking of, what are some good resources for learning about designing systems level programs. I understand the concepts, but i wouldn't know how to actually apply them properly when writing code. Or maybe that means i don't actually understand them well enough.
>>
>>56707003
"lighttpd required"

uh, nginx is better anon
>>
>>56707196
The one that came with your distro.
I'm going to take a guess that you installed a debian-based distro, so type
sudo apt-get install build-essential
>>
>>56707003
>GPL
why not LGPL?
>>
>>56707070
>>
>>56707213
What makes it better?
lighttpd is pretty simple for what it is
>>
>>56707245
nginx has less memory and CPU usage, and nginx handles high request load much better than lighttpd

but both are lightyears better than apache so whatever
>>
>>56707215
>distro
anon he's probably on windows
>>
>>56706998
You can use try-finally if you want to run some cleanup code no matter what happens. If that's not enough then you need to redesign your code so that you don't require goto-like functionality. Python devs rejected labeled break & continue because they're apparently "too confusing".
>>
>>56707003
Pretty cool, just wished it were compatible with nginx.
>>
>>56706940
Is learning C as my first programming language a meme?
>>
>>56707284
You'd have much easier time with more modern languages.
>>
>>56707284
If by meme you mean core programming concepts, yeah.
>>
>>56707275
I'm sure it'll run on ngnix if you can enable the cgi module.
>>
>>56707295
What are some concepts that aren't just limited to systems programming that you miss out on by not learning c
>>
I made a text based game in python where you can walk around my house, is this an autistic thing to post on my github?
>>
>>56707319
yeah, don't post it
>>
>>56707319
Not at all, something is better than nothing. Until you have enough solid projects to replace it, i would keep it there.
>>
>>56707319
Yes.
>>
>>56707300
None, but if you start with a high level language, let's say a scripting language, you will be fooled by things like GC, references, and some abstracted methods like .map, .max, .find, etc.
>>
>>56707300
You'll never be able to program a circuit board.
At job interviews, it is common for employers to ask, "Oh, say can you C?"
>>
>>56707330
but would you need them if you stuck with those languages? Does a person who will never touch systems need to know how to manually manage memory if the language will always do it for you and probably won't let you optimize it yourself
>>
>>56707330
Is java cool to learn
Even if it is owned by Oracle, now
>>
>>56707349
it would probably make finding a job easier, but personally, i never found it pleasant to write non-enterprise programs in.
>>
>>56707323
>>56707324
>>56707326
two yes' and a no, guess it doesn't go up, what about a game where you have ten rolls of a dice to defeat a monster, each roll decides how much damage you will do?
>>
>>56707270
you are right. My UNIX class is actually starting up this week though haha. So I'll become familiar with linux distros shortly I assume.
>>
>>56707348
If you ask /g/: They're essential to know for anyone who'd like to call themselves a programmer
Anyone else: Nope, unless you're messing with embedded or other low-level stuff

>>56707349
Cool? Nah. Useful? Depends on what you're planning but Java is quite popular among enterprise programming jobs.
>>
>>56707348
>but would you need them if you stuck with those languages?
Definitely, if you don't know that kind of knowledge you can run easily into performance troubles, or even into simplistic shit like "IDK why my sort function doesn't werks".
>>
>>56707366
In fact I could do it without a dice have it randomly pick a number between 1-6
>>
>>56707366
I'm looking at it from the perspective of using it to find a job. Employers want to see that you actually know how to code, that's why they make you write fizzbuzz or some other simple program. Most employers will probably just be happy to see a github link on the resume.
>>
>>56707367
>i'm wasting my parents money on college classes to do things I could have learned for free in my spare time

ok
>>
Can I make a "steam-worthy" indie game with C?
>>
>>56707366
You could take the concept and base the game in somewhere else than your own house. Maybe flesh it out too, do an proper oldschool text-based rpg,
>>
>>56707299
yeah, i have no clue how to do that. o well
>>
>>56707383
>most employers will just be happy to see a github
most employers don't even know what github is
if your resume doesn't have the minimum number of buzzwords and the words "B.S." on it, you're going in the trash without even getting glanced at by a person.
>>
>>56707385
Nah, actually leftover Financial Aid so if anything, I'm wasting pennies of my parents money. I'm a poor.
>>
>>56707402
Probably yeah. I'm just speaking from personal experience where i was told that they don't usually see a github link on resumes. But to add context im talking co-op/intern level jobs.
>>
File: GLXSQoz.gif (125KB, 600x600px) Image search: [Google]
GLXSQoz.gif
125KB, 600x600px
>your two options for making money fast are php and node
>>
What data structure could I use to map out c++ file include hierarchies to detect redundancies (header pollution)

A binary tree would only work for files that include only up to 2 files right?
>>
Any good resources on learning java?
>>
>>56707444
stupid robot
>>
>>56707444

Does any serious company actually use node in production unironically?
>>
>>56707445
directed acyclic graph
>>
File: le shocked chris-chan.png (982KB, 648x787px) Image search: [Google]
le shocked chris-chan.png
982KB, 648x787px
>>56707059
>being attracted to chris-chan
Man, that's even worse than being Chris-chan.
>>
File: 1468266827746.png (297KB, 640x480px) Image search: [Google]
1468266827746.png
297KB, 640x480px
>>56707500
>>
>>56707470
yep, I even know about a certain video game company that uses it for their servers
>>
>>56707003
>>>/g/wdg
>>
>>56707511
A C imageboard belongs in /wdg/ like tomatoes belong in a fruit salad.
>>
>>56707508
have they explained why they picked node over other options
>>
>>56707337

If an employer phrased it like that, I likely would not get if they were asking if I could write in C, at least not right away... although I would have C as pretty much the first language on my resume.

>>56707149

https://msys2.github.io/

Currently the best distribution of MinGW-w64 (GCC for Windows) that I know of.

>>56707521

Salsa -- the tomato-based fruit salad.
>>
>>56707705

Ruby -- the nigger-based nigger nigger
>>
Argh. Trying to successfully use Group By or Group Join in a VB LINQ is frustrating.
>>
File: we wuz cwc.jpg (85KB, 640x480px) Image search: [Google]
we wuz cwc.jpg
85KB, 640x480px
>>56707507
>>
File: poo patterns.png (141KB, 1058x852px) Image search: [Google]
poo patterns.png
141KB, 1058x852px
>>56707330
>some abstracted methods like .map, .max, .find, etc.
They're called higher-order functions. Go OOP in loo.
>>
>>56707445
plz hpelp

>>56707479
explain
>>
File: 1391126757962.jpg (307KB, 796x574px) Image search: [Google]
1391126757962.jpg
307KB, 796x574px
>>56707740
Anon -- the ignorance-based racist poltard.
>>
Someone tell me something simple I can do in python, already done fizzbuzz
>>
File: Stormweenie.jpg (67KB, 476x717px) Image search: [Google]
Stormweenie.jpg
67KB, 476x717px
>>56707740
> Using the N-word.
Go back to your containment board stormtard. We don't want you here.
>>
>>56707740

No, you're thinking of OSGTP.
>>
File: red.jpg (149KB, 800x820px) Image search: [Google]
red.jpg
149KB, 800x820px
>>56707807
Looks like you have to go back
>>
>>56707705
>salsa
>salad
como
>>
>>56707822
implying reddit isn't full of trumptards. At least on 4chan they don't get the satisfaction of gaining virtual points for shitposting.
>>
>>56707838
what's the current exchange rate of (you)'s to upvotes?
>>
File: 1474060655231.png (390KB, 427x576px) Image search: [Google]
1474060655231.png
390KB, 427x576px
>>56707838
It's all part of /pol/'s master plan
>>
@56707848
dunno anon, are upboats elastic goods?
>>
How do I make a web based network scanner?

Something to be able to port scan using nmap online, how do I link the site to a vps?
>>
>>56706940
I can't get to bed and now I'm considering pulling an all-nighter
Help
>>
File: FoundTheBard.jpg (35KB, 477x473px) Image search: [Google]
FoundTheBard.jpg
35KB, 477x473px
>>56707824

It's from a D&D joke.
>>
>>56707918
the real joke is that people thought this was funny
>>
does anyone here have experience with intersystems cache? trying to find out more about it.
>>
>>56707165
I'm using my D with your mom
>>
>>56707940

You don't hang out with many normies, do you?
>>
#include <stdio.h>

struct tree {
int val;
struct tree * left;
struct tree * right;
};

struct tree *
mktree (struct tree * node, int depth)
{
node->val = rand() % 6;

if (depth) {
mktree (node->left, depth-1);
mktree (node->right, depth-1);
}
return node;
}

void
put_tree(struct tree * node, int depth)
{
if (depth) {
printf("v = %d\n", node->val);

put_tree(node->left, depth-1);
put_tree(node->right, depth-1);
}
}

int
main ()
{
struct tree t = {};
put_tree( mktree(&t, 9), 9 );
return 0;
}


but I get segfaults, why???
>>
>>56708150
Use GDB
>>
>>56708150
>mktree (node->left, depth-1);
>mktree (node->right, depth-1);
Wouldn't left and right be garbage pointers since you haven't pointed them to anything?
>>
>>56708150

You haven't initialized a value to tree t->left or tree t->right before mktree gets called the first time. Which is why whatever node you return ultimately with that function is going to crash because it's going to be some variation of uninitialized memory garbage values/NULL you will return.

Please initialize structs before you use them.

>>56708236

Yep.
>>
>>56708150

I'd like to know the thought process that went through your head when you made that mktree function.
>>
I don't have a smug anime girl so I don't know if I'm allowed to post here but what kind of math is needed to implement a cryptocurrency? Are there any cryptocurrency proof-of-concept methods that are open source?
>>
>>56708150
Aside from the root of the tree, you're never actually allocating anything.
>>
>>56708288

the same kind of math that is used for one way hash functions aka crypto code. look at sha256 in freebsd or gpg for bitcoin specific stuff.
>>
>>56708288
>Are there any cryptocurrency proof-of-concept methods that are open source?
The bitcoin client is open source, you know.
>>
>>56708257
>>56708288
struct tree *
mktree (struct tree * node, int depth)
{
static int v = 1;
node->val = v++;
struct tree l = {};
struct tree r = {};

if (depth) {
mktree (node->left=&l, depth-1);
mktree (node->right=&r, depth-1);
}
return node;
}


now what
>>
>>56708481
stdout
./a.out 
v = 1
v = 529354816
v = -1913371253
>>
>>56708481
That's still incorrect. Those pointers become invalid as soon as you leave the function.
You really need to learn how allocation works.
>>
>>56708495
so I have to malloc and then free?
>>
>>56708512
Yes. A tree is a dynamic data type, so you can't get around using malloc.
>>
>>56708527
To "get around something" to is "avoid something".
So he can't avoid using malloc.
>>
>>56706940 (OP)
Boss said he wants me to use a React framework on the front-end.

They're all node packages.

Our Application is Zend2/PHP on Apache.

Trying to bundle something with webpack that will give me the vendor packages and a single css file that will somehow make react-toolbox or react-essence or something actually work. Then I can bundle it into a Zend2 view template.

I've never worked much with Node and not a single tutorial actually runs out of the box, they all have shit I need to debug to get working.

Half the tutorials are for shit that is deprecated or abandoned and I don't know until I've been struggling with it for hours.

Not one of the React frameworks will work out of the box, they all need endless css loaders and shit installed and configured to get working the way that they say will happen if you just do 'npm install x'.


I want to die.
>>
>>56707158
>R
I'm a fan. I really only learned it at uni for some assignment but have twice used it for backend processing in commercial projects.

I'm pretty sure the set of developers paid to work in R is pretty small.
>>
my tree prog finally works
I feel acomplished

r8 it pls (keep in mind im a noob at c)
#include <stdio.h>
#include <stdlib.h>

struct tree {
int val;
struct tree * left;
struct tree * right;
};

struct tree *
mktree (struct tree * node, int depth)
{
static int v = 1;
node->val = v++;

if (depth) {
mktree ( node->left = malloc(sizeof (struct tree))
, depth-1
);
mktree ( node->right = malloc(sizeof (struct tree))
, depth-1
);
}
return node;
}

void
put_tree(struct tree * node, int depth)
{
if (depth) {
printf("v = %d\n", node->val);

put_tree(node->left, depth-1);
put_tree(node->right, depth-1);
}
}

void
ftree(struct tree * node, int depth)
{
if (depth) {
ftree(node->left, depth - 1);
ftree(node->right, depth - 1);
}
free(node);
}

int
main ()
{
struct tree *ptr = mktree( malloc(sizeof (struct tree))
, 9
);
put_tree(ptr, 9);
return 0;
}


also, how do I know if my structs are being padded with bits?
>>
>>56707470
>Does any serious company actually use node in production unironically?

Don't Facebook and Google use it?
>>
File: alcohol.gif (132KB, 500x281px) Image search: [Google]
alcohol.gif
132KB, 500x281px
>>56707444
>>your two options for making money fast are php and node
My one option for making money slowly is php and node at the same time.
>>
>>56708699
I just realized I didn't free.
does not freeing really matter if its all done at the end?
>>
>>56708699
Pretty nice, but that spacing is disgusting.
>>
>>56708699
>also, how do I know if my structs are being padded with bits?
By seeing if the size of the struct is the same as the sum of the size of each of the individual members. There is also a compiler flag for GCC and Clang (-Wpadded) which warns where there is padding.
You can find out where the padding is using the offsetof() macro in <stddef.h>

In terms of your implementation, there are lots of little things I could complain about, but for a beginner, it's fine.

>>56708744
>does not freeing really matter if its all done at the end?
It's extremely bad style not to free. Also, leaked memory is a huge deal for long-running programs.
>>
>>56708699

Read http://www.catb.org/esr/structure-packing/

But know that a struct layout is a design decision for your program. If you have users who will interface with your program and you suddenly change the layout, bad things happen.

This is what programmers with popular programs need to sort out with ABI compatibility.

It's also good practice to free.
>>
>>56708752
I was told to use spacing more so that is more readable.

>>56708763
pls complain about it, I need to know about implementation.

>>56708772
>link
nice, just put it into backlog
>>
>>56708517
He can avoid using malloc if he constructs the tree iteratively (using a stack data structure) and then finishes using the tree before that function returns.

>>56708699
#include <stdio.h>
#include <stdlib.h>

struct tree {
int val;
struct tree* left;
struct tree* right;
};

void free_tree(struct tree* restrict const node) {
if (node->left != NULL) {
free_tree(node->left);
}

if (node->right != NULL) {
free_tree(node->right);
}

free(node);
}

struct tree* make_tree(const int depth) {
if (depth <= 0) {
return NULL;
}

struct tree* restrict const new_node = malloc(sizeof(struct tree));
*new_node = (const struct tree){rand() % 6, make_tree(depth - 1),
make_tree(depth - 1)};

return new_node;
}

void put_tree(const struct tree* restrict const node) {
if (node->left != NULL) {
put_tree(node->left);
}

printf("v = %d\n", node->val);

if (node->right != NULL) {
put_tree(node->right);
}
}

int main() {
struct tree* restrict const root = make_tree(9);
put_tree(root);
free_tree(root);
return EXIT_SUCCESS;
}
>>
>>56707003
Reminder that const in C does not mean what it means in C++.
>>
if c anon is constructively criticizing my tree.c, keep at it pls
imma sleep, so I'll look at it tomorrow
thanks pham
>>
>>56708792
>pls complain about it, I need to know about implementation.
>static int v = 1;
This is hidden mutable state. It's trivial in this example, but hidden mutable state makes your program much more difficult to reason about.
>if (depth) {
>}
This is arms-length recursion, which is considered bad style in computer science.
Something like
if (depth == 0)
return;

mktree(...);
mktree(...);

is considered "better".
>node->left = malloc(sizeof (struct tree))
I'm not a huge fan of using the value of an assignment like this. It's obtuse.
>malloc(sizeof (struct tree))
You're not checking the return value of malloc, which can fail.
>int depth
This argument seems strange to me. You can walk a tree without knowing its depth.

>>56708800
>then finishes using the tree before that function returns
That use case is extremely limited.
>using a stack data structure
You don't need a stack. You can implement a binary tree quite easily with just an array.

Also, your code also contains arms-length recursion.
>>
>>56708905
capped
I see, I'll keep that in mind in more serious programs
>>
>>56706940
why do so many people like children cartoons for girls? its like bronies obsessing over mlp.

grow up.
>>
>>56708934
leave him alone, he gets off on being called out
>>
Javascript is disgusting but I have to learn it for a class
>>
>>56708946
can we please reply to him with anime girls being smug or laughing
>>
File: 1452403462016.png (79KB, 307x400px) Image search: [Google]
1452403462016.png
79KB, 307x400px
>>56708946

>>56708955
Javascript is shit though.
>>
Why the fuck is DataGrid so useless in C#? With DataGridView, colouring a single cell is so easy. You literally use coordinates [x,y] like you would with a 2D array. But DataGrids make doing so a nightmare, and WPF doesn't support DataGridViews.
>>
>>56708905
>You don't need a stack. You can implement a binary tree quite easily with just an array.
Sure, and an array can be used to implement a stack.

>Also, your code also contains arms-length recursion.
Astute observation. this reduces the number of stack frames that must be used to accomplish the task recursively. The base case checking is also entirely contained in the recursive function, so there's no additional code that the caller must write to use the interface.
>>
>>56709008
>Sure, and an array can be used to implement a stack.
A stack doesn't support the necessary operations to implement a tree, as a stack doesn't have random access. An array is actually the answer.
>Astute observation. this reduces the number of stack frames that must be used to accomplish the task recursively
By 1. A single stack frame isn't even worth thinking about.
All you've done is make your code less clear.
>there's no additional code that the caller must write to use the interface
The proper way of doing it doesn't require the user to do anything either.
>>
I'm being a dense idiot with simple high school math for some reason. Help me understand this.

Assume I have a sorted array from least to greatest in arr. When trying to calculate the 1st, 2nd, and 3rd quartile, why does the following code

    int midpoint = n / 2;
int q1 = arr[midpoint / 2], q2 = arr[midpoint], q3 = arr[n - 1 - midpoint / 2];
//Equal to midpoint % 2 == 0
if(!(midpoint & 1))
{
q1 = (q1 + arr[midpoint / 2 - 1]) / 2;
q3 = (q3 + arr[n - 1 - midpoint / 2 + 1]) / 2;
}
//Equal to n % 2 == 0
if(!(n & 1))
{
q2 = (q2 + arr[midpoint - 1]) / 2;
}


work for all cases but the following which I wrote doesn't?

    int midpoint = n / 2;
int q1 = arr[midpoint / 2], q2 = arr[midpoint], q3 = arr[n - 1 - midpoint / 2];

if(!(midpoint & 1))
{
q1 = (q1 + arr[midpoint / 2 - 1]) / 2;
q3 = (q3 + arr[n - 1 - midpoint / 2 + 1]) / 2;
}

else
{
q2 = (q2 + arr[midpoint - 1]) / 2;
}


doesn't?
>>
>go to local tech talks to hear about interesting new things
>it's filled with sanjays desperately trying to network
>>
>>56709045
A stack doesn't support the necessary operations to implement a tree, as a stack doesn't have random access. An array is actually the answer.
The stack is just for allocation. It would replace the call stack that's used in recursion. It doesn't have anything to do with the tree once the tree is set up.

>By 1. A single stack frame isn't even worth thinking about.
>All you've done is make your code less clear.
It's not just a single stack frame. For a depth of k we avoid using 2^(k+1) stack frames.

>The proper way of doing it doesn't require the user to do anything either.
So then what difference does it make? Aside from the trade off of performance (I'm using this term loosely, if this were a serious program we'd do everything iteratively provided the tree was going to be sufficiently large) vs. one fewer NULL check.

I would argue if you're coding in C then you care about performance to begin with. Although, then again you have the whole "use iterative methods instead" argument.
>>
File: DensityDataGraph.gif (4MB, 591x495px) Image search: [Google]
DensityDataGraph.gif
4MB, 591x495px
r8 my density graph viewer
I just finished it
I'm a little proud
>>
>>56708034
normies laugh at the most mundane jokes because they havent been exposed to the extreme levels of hilarity you can only find on the web like 4chan
>>
>>56709062
ignoring what's in the blocks: if it makes your head hurt i would just start running through the logic for small n. in the first listing it's possible that both blocks get executed, eg, if n = 4
>>
How long does it take to get to pro level? Can it be done in a year?
>>
>>56709062
>>56709174

Okay, screw me. I figured this out.

I'm writing this so I can understand my error fully even if it's pointless. My snippet of code fails if you have something like 8 numbers in your set instead of 6 numbers, where n / 2 is still even instead of being odd.

All the quartiles have to calculate from two numbers in their ranges where they search for the median since all those ranges would be even (For 8 numbers in set; 1st quartile: 4 numbers, 2nd quartile: 8 numbers, 3rd quartile: 4 numbers). This is opposed to something like 6 numbers where only the 2nd quartile has to search 6 numbers (even) but 1st and 3rd quartile search for 3 numbers (odd).

I just assumed every quartile range was the latter or polar opposite of it.

I supposed it makes more sense to me if I swap the q2 and q1+q3 if conditions in my code. Will comment my code with brief explanation.
>>
hii guys im actually gonna learn to program in c++ or c#
i am looking to make a world of warcraft like game that will eventually kill wow
i already have a name and story in my head
i don't know how to program yet so i am looking for more people to help me thanks
post your email here so i can add you to the team
>>
>>56709132
>The stack is just for allocation. It would replace the call stack that's used in recursion. It doesn't have anything to do with the tree once the tree is set up.
You said you would use a stack to _implement_ the tree. Obviously, people are going to think that you're using the stack for the implementation of the tree itself.
Get your fucking terminology right.
>For a depth of k we avoid using 2^(k+1) stack frames
I was talking about at the deepest level. Nobody cares about the other ones.
>Aside from the trade off of performance
You're making a lot of very poor assumptions about the way a CPU would handle this.
The overhead of a function call is practically zero (especially with all of this shit being passed around in registers, and all of the instructions would be cached anyway.
Your code also has a more complicated control flow, meaning that the CPU's branch predictor would do worse.
>Although, then again you have the whole "use iterative methods instead" argument
I never even said anything remotely like that.
Trees practically beg to be done recursively. Doing trees iteratively is retarded and inelegant.
>>
>>56709193
are you complete beginner?
depends what you mean by 'pro'
elaborate on what you are trying to achieve and maybe i can answer if it can be dont in a year or not
>>
>>56709193
>How long does it take to get to pro level?
Whatever that is supposed to mean.
>Can it be done in a year?
No. It'll take at least 10.
>>
File: smug cat chii.jpg (21KB, 604x499px) Image search: [Google]
smug cat chii.jpg
21KB, 604x499px
>>56708965
But this shit is good enough to make great software.
>>
>>56709235
based todd
>>
>>56709235
[email protected]
>>
>>56708517
>Yes. A tree is a dynamic data type, so you can't get around using malloc.
Not true.

http://pastebin.com/2NfZ6D95
>>
>>56709242
>You said you would use a stack to _implement_ the tree. Obviously, people are going to think that you're using the stack for the implementation of the tree itself.
>Get your fucking terminology right.
I said:
>_CONSTRUCTS_ the tree iteratively (using a stack data structure)
So clearly I was referring to construction and not the backing data structure.

>I was talking about at the deepest level. Nobody cares about the other ones.
Yeah, this is the deepest level. Checking for NULL before recursing prevents the deepest level of nodes from having each node on that level recurse twice (once for L and once for R). 2^(k+1) is the TOTAL number of stack frames we'd avoid using. It's the number of additional nodes that would be allocated if we were to add one more to depth.

>You're making a lot of very poor assumptions about the way a CPU would handle this.
>The overhead of a function call is practically zero (especially with all of this shit being passed around in registers, and all of the instructions would be cached anyway.
>Your code also has a more complicated control flow, meaning that the CPU's branch predictor would do worse.
It's hard to argue things like branch prediction vs additional stack frames without first benchmarking.

>I never even said anything remotely like that.
>Trees practically beg to be done recursively. Doing trees iteratively is retarded and inelegant.
You are correct -- you didn't say anything like that; I did! Using recursion in a language without tail call optimization or something similar is generally a bad idea provided the structure is intended to be sufficiently large (and even if not, it's often discouraged anyway). This is because it's slower than the iterative equivalent, and it opens you up to stack overflows that would otherwise not happen.

What's elegant isn't always how things should be done. Check out some style guides for C/C++ (hell, similar languages as well) and see what they have to say about recursion.
>>
>>56709356
>Stack performance
Subtracting a number (growing the stack) will always be faster than a jump.
>>
>>56709356
>>56709242
I think I understand the confusion about additional stack frames. They aren't constructed "vertically", so the call depth doesn't increase by
2^(k+1), but they're constructed sequentially. So the total number of frames would increase.

>>56709354
Very nice. Clever.
>>
>>56709354
This is sleep sort level shit.
>>
>>56709411
There's more to pushing, using, and popping a frame than changing the SP.

By the by, not all stacks grow down. And out of the ones that don't, not all grown up either. See, for example, SPARC.
>>
>>56709242
>You're making a lot of very poor assumptions about the way a CPU would handle this.
>The overhead of a function call is practically zero (especially with all of this shit being passed around in registers, and all of the instructions would be cached anyway.
>Your code also has a more complicated control flow, meaning that the CPU's branch predictor would do worse.
A function call is a branch.
>>
>>56709356
You need log2(n) stack frames to walk a balanced binary tree.
On my computer (64-bit GNU/Linux), the default stack size for a program is about 8 megabytes.
As for the size of a stack frame of some recursive function, lets be generous and say it's 256 bytes.
So we have about 32768 stack frames to deal with. We'll shave off half of those, because there are probably some other functions using up some stack space, so 16384 frames.
So to find out the number of nodes that our tree needs to have in order for us to have a stack overflow, we use
log2(n) = 16384
n = 16384^2
n = 268435456

So our tree needs to have 268 million nodes to overflow the stack.
As for the nodes themselves, they will need to have at least 16 bytes of data for pointers to their children, and some more space for some actual data. We'll be modest and give them a single int as their data. So 20 bytes of space for each node (not including malloc bookkeeping overhead).
So We require 5368709120 bytes or 5.3 gigabytes of tree data to overflow the stack.

Stack overflow is not an issue when it comes to trees.
If you were working with data with size of this magnitude, you certainly wouldn't be using a binary tree.
>>
>>56709600
>If you were working with data with size of this magnitude, you certainly wouldn't be using a binary tree.
You'd also take an iterative approach rather than a recursive one if dealing with that amount of data in a serious program (and usually even when not dealing with that amount of data).

This doesn't account for:
1) More constrained systems such as embedded ones.
2) The time penalty of additional frames.
>>
while gender != "male" or "female":
gender = input("Are you male or female?\n\n")
if gender == "male" or "female":
break

What is wrong with this. I want it to ask the question over and over until one of the two options are chosen, but it only asks the question once as if there is no loop there at all.
>>
>>56709675
>More constrained systems such as embedded ones
A constrained system would not be working with data on that scale.
>The time penalty of additional frames.
That is not where the performance issues lie. Locality of reference is the real performance killer with something like this.
Function call overhead isn't even worth thinking about, especially systems that pass most of their arguments in through registers.
>>
>>56709695
Your boolean conditions get grouped as:
(a) or (b). Use this knowledge to rewrite them.
>>
What am i doing wrong? I keep getting
"An object reference is required for the nonstatic field, method, or property on a Windows form"

Pastebin: http://pastebin.com/5MKk5yQU
>>
File: navysealcopypasta.png (115KB, 1280x800px) Image search: [Google]
navysealcopypasta.png
115KB, 1280x800px
python zipf thingy, run the code, tell it which file to read, tell it to create a xyz.csv , load it up in excell (or calc if your cheap like me), and see that some words are said proportionally more
        import  collections, string, csv

name = input('enter a file->')
handle = open(name, 'r')
table = str.maketrans('','',string.punctuation)
text = handle.read()
text = text.translate(table)
words = text.split()


x = collections.Counter(words)


print (x.most_common())

filename = input('nameit.txt-->')

with open(filename, 'w') as resultFile:
writer = csv.writer(resultFile)
for row in x.most_common():
writer.writerow(row)


pic lated
>>
>>56709695
>gender != "male" or "female"

This expression is stupid. Rewrite it. Also understand operator precedence in whatever language you're using and what the OR operator actually does. Also double-check what a valid string evaluates to when cast as a boolean.

These will help you understand what is happening.

Then also change 'gender ==' to 'strlower(gender) ==' or something valid in your language.

var cisGender = false;
while !cisGender:
gender = input("Are you male or female?\n\n")
cisGender = :(strlower(gender) == "male" || strlower(gender) == female)


Not sure what language this is so I don't know about the local equivalent of strlower() or variable declaration.
>>
>>56709708
>A constrained system would not be working with data on that scale.
You could fit in more data iteratively than you could fit in recursively.

>That is not where the performance issues lie.
2^k lateral stack frames created being of no import seems a little far-fetched, assuming of course that k is sufficiently large. Although I suppose without benchmarks it's a moot argument.
>>
File: 13638382284_86ec3dd28f_o.jpg (413KB, 1040x740px) Image search: [Google]
13638382284_86ec3dd28f_o.jpg
413KB, 1040x740px
>>56709734
pls help im nearly done
>>
>>56709751

python 3
>>
>>56709764
I'm not touching Windows forms.
>>
>>56709695
running = True    
while running:
gender = input("Are you male or female(NO TRANNY!)")
if gender == "male" or gender == "female":
break
>>
>>56709771
>python 3
Thanks, I worked it out afterwards (well, Python anyway) but I still don't know how to compare strings case-insensitively in it. Not that I care, I'm sure I can google it if I never need to know.
>>
>>56709807
>Are you male or female(NO TRANNY!)
Needs more gender politics.
>>
>>56709807
Why not set running to false?
>>
>>56709807
MALE = 0;
FEMALE = 1;

if gender == MALE | FEMALE:
:)
>>
>>56709828
I think he can cast lower on his input instead of his male and female, too lazy to go check though
>>
>>56709853
instead of the break? I was just trying to change his code as little as possible
>>
>>56709791
its for school senpai :^)
>>
Guys, noob question.
Inheritance in C++ (CodeBlocks) does not work.

class card
{
public:
int forinheritance;
};

class ally: public card
{
};

ally is still shown to have no members.
>>
>>56709873
>his

leave the sexism on /b/
>>
>>56709753
>You could fit in more data iteratively than you could fit in recursively.
You would hit the memory limit before you you even need more space.
In my example, I purposely added all sorts of wastage to show how large the tree has to be before an overflow would occur, despite those wastages.
Half of the stack taken already? That is extremely unlikely. It'll be far less than that.
256 of bytes for a stack frame? That's actually pretty large for something like walking a tree.
20 bytes per node? You probably wouldn't have such a small amount of data in a tree like this (you would use an array instead).
A binary tree? What about trees of any arity?

If you have a quaternary (arity 4) tree with a 256 bytes per node, 8MB of stack space with 5% of that stack space in use, and 32 byte stack frames, you would need a tree that is 984664 Exabytes large.

Don't underestimate logarithms.
>>
>>56709915
OK, what about the time usage of recursive algorithms vs iterative for very large trees?
>>
>>56709887
but does it compile?
>>
Need ideas for a programming project.
Any givers? Maybe some neat API to work with?
>>
>>56709861
>I think he can cast lower on his input instead of his male and female, too lazy to go check though
>his
How do you know he's gender identified as a cis male?

Seriously though, you're probably right. Using my phpish strlower:
gender = strlower(input....)

Is more efficient.
>>
>>56710107
>Need ideas for a programming project.
>Any givers? Maybe some neat API to work with?
Bundle react-toolbox into a single minified file for me. Thanks.
I can get react-essence out of their website actually but react-toolbox has a better data table that I want to use and bundling their shit is killing me.
>>
>>56710009
yes, it does, without error
>>
>>56710113
I meant a learning project, not a chore for a front-end webdev.
>>
>>56710125
There you go then. Inheritance in C++ works.
>>
>>56710141
>>56710113

#rekd
>>
    size_t txt_len = window->width;
char *info_txt = malloc(txt_len);

sprintf(info_txt, "Name: %s Health: %d", player.name, player.health);
strncpy(window->data, info_txt, txt_len);
//free(info_txt);


How come freeing the memory causes the program to crash here? Surely once it has been copied into the windows char *data, I can just free it?
>>
it does work.

#include <iostream>
class A {
public:
A(): a(123){}

int a;
};

class B : public A {
public:
B(){
this->a = 456;
}
};

class C : public A {
public:
C(){
this->a = 789;
}

int a;
};

int main(void)
{
A a;
B b;
C c;
std::cout << "A: " << a.a << std::endl;
std::cout << "B: " << b.a << std::endl;
// this accesses the base member a
std::cout << "C first: " << ((A&) c).a << std::endl;
// this accesses the overriden member
std::cout << "C second: " << c.a << std::endl;

return 0;
}
>>
>>56707003
>GPL
McFucking kill yourself.

GPL is anti-freedom, and communism.
>>
>>56710234
What's wrong with communism?
>>
>>56709734
What exact line are you getting that error on?
>>
>>56710207
Oh god, I added it back in and now it doesn't crash.
Something must be mega-fucked somewhere.
>>
>>56709887
see >>56710227
>>
>>56709005
The only difference as far as coloring a cell is that DataGrids are a collection of rows, so you have to navigate to the row, then the cell.

It actually makes sense from a data manipulation standpoint, and you could easily write your own extension method
myDataGrid.ColorCell(x,y)
that would do this for you if you're doing it many times.
>>
>>56710189
>#rekd
Not that I disagree but
>>56710141
>I meant a learning project, not a chore for a front-end webdev.
Oh, don't worry...there's plenty of learning curve in here.

Anyway, I'm not a front-end webdev, I'm a database developer, dammit.
>>
>>56710257
line 18, my bad
>>
>>56710292
>>56710227
it does not work, though ...

>>56709887

ally is shown to have no members.
and i cannot treat ally as an card-type object either.
>>
>>56710332
>it does not work, though ...
it literally does.

>ally is shown to have no members.
yes it does.
>and i cannot treat ally as an card-type object either.
yes you can
>>
>>56710241
Are you posting from a communist country? No? Wonder why that is?
>>
>>56710343
i know it ought to be like that. but it isnt, for some reason.

wait a minute, i will show you the screenshot
>>
>>56709138
Is that OpenGL?
>>
>>56710207
>>56710265
I guess I figured it out.
sprintf has no way of telling how large the chunk of destination memory is, so I'm probably copying past it into the realm of unpredictable.
>>
i learned binary semaphores in my CS module

but are they actually used somewhere? never seen them in actual projects
>>
>>56710345
Doesn't answer the question.
>>
>>56710429
communism is empirically proven to produce much worse outcomes than market economys. so most ex-communist countries adopted market economys afterwards.
>>
>>56710359
>snprintf exists
B A S E D C
>>
Give me your honest opinion about Go.
>>
>>56710437
capitalist countries benefit from big military forces, while communist countries will always suffer under them.
A communist country will never be able to withstand an arms-race against a capitalistic country.
This is the reason why they didn't hold for very long.
>>
>>56710479
interface {} garbage tier. avoid.
>>
>>56710481
it is not only arms, its also anything else. compare the standard of living of ukraine (once the richest UdSSR country) with that of germany.
>>
Still working on the python image encryption program. Still not working.
Wanna kill myself.
>>
Does Java still use a Virtual Machine today?
If so, why?
>>
>>56710521
Yes.
It works, it is fast, the ecosystem is built around the jvm.
So why replace it? And more importantly, who's gonna pay for that?
>>
>>56710437
Still avoiding the question by overgeneralising the answer.
>>
>>56710521
yes.
Portability and abstraction.
Most programs java is used for dont arent time critical or have to run good on systems with very limited ressources, so it is a good tradeoff.
>>
File: Screenshot (4).png (73KB, 1366x768px) Image search: [Google]
Screenshot (4).png
73KB, 1366x768px
>>56710343
Here is the screenshot that summarizes my problem. Inheritance does not happen.

The class "Ally" should include int forinheritance and int forinheritancetwo as members.

But it doesnt, as the list on the right shows.
>>
>>56710554
it answers the question.

>A: What's wrong with communism?

>Q: It produces worse results in almost every aspect than market economies.
>>
>/csfg/ - compsci freshmen general
>>
>>56710563
This is an issue in your IDE.
Also try it your auto-completion works outside the class definition.
>>
>>56710563
see >>56710592

i dont use code::blocks so im not sure but you should be able to change the auto-completion to include inherited members.
>>
>>56710583
So what are you saying? GPL will make my code run slower?
>>
should I learn Rust or Go? or stick with Python
>>
>>56710592
>>56710600
i also thought it is IDE-related.

so i have to change the auto-completion mode, seemingly.
>>
>>56710615
depends what you want to do exactly

Go is much much easier than Rust by the way
>>
>>56710592
yeah, the auto-completion seems to recognize Ally everywhere
>>
>>56710647
Why should anyone even learn rust?
>>
>>56710676
i guess that was my question
>>
>>56710676
Pussy bitches who need their 'safe space' to program in.
>>
>>56710615
>>56710647
>>56710715
The real question is, why would you pick between Rust and Go? They're two completely different languages that people seem to associate together because they're both new.
Go is a typical high level language with garbage collection and shit, Rust is a low level systems programming language with compile-time safety features.
>>
>>56710726
yup, i thought they were the same
so Rust is like C
and Go is like C#
who has better lib support?
>>
>>56710748
>so Rust is like C
>and Go is like C#
why are there so many dumb shits on /dpt/
>>
Why to learn rust when you can learn C?
>>
>>56710769
see
>>56710716
SJW extending their safe spaces into programming.
>Th-the segfaults are oppressing me!
>>
Made a pow, exp and log function. They aren't super fast or anything but it was still nice to learn the basic algorithms for them. Might make trig functions next.
>>
>>56710815
Try making them all asymptotically optimal.
>>
File: 1296946373441.jpg (116KB, 1280x720px) Image search: [Google]
1296946373441.jpg
116KB, 1280x720px
programming is for nerds
>>
>>56710785
>Statical type systems are SJW thing
wow
>>
>>56710898
Fuck off rust devs I'm not going to touch your shit language.
>>
Gonna start using Python. Which editors do you guys prefer? Are there even any IDEs for this, or should I just stick to Sublime or Atom?
>>
>>56709734
The problem is using Form.Controls to get the controls of the current form. Form is a class, not an instance. Form.Controls is an instance member.

Therefore you should use this.Controls to get the controls on the current form.
>>
>>56711000
Netbeans
>>
>>56711000
i recommend notepad but maybe you would like notepad++ since it adds a bit of color
>>
>>56707003
>return (!count) ? 0 : count;
xD
>>
I personally use atom, but sometimes I use the built in IDLE editor thing if I'm just mucking about with ideas
>>
>>56711190

meant for

>>56711000
>>
red pill me on dlang
>>
How else can one send mail if SMTP isn't accessible? Right now I send bulk email at work via a python script that just uses GUI automation to mimic the manual process. It "works" in the sense that it gets the job done and I don't have to watch it if the conditions are right, but it's got a lot of problems mainly residing in the fact that whichever window in the process is currently being used has to be in focus and on the primary monitor.

Getting the stuff I need from our database is done, but the kicker is sending it all out. I'm blocked from utilizing SMTP and I have no access to the credentials for the Exchange server we use. I was thinking about just passing it all to Outlook but I can't change the "Programmatic Access Security" option in Outlook that stops external programs from using it either.
>>
I'm trying to make all order statuses but 'cancelled' show up in my query. This returns nothing. What am I doing wrong?

$tsql = "SELECT * FROM dbo.[order]
WHERE NOT EXISTS
(SELECT * FROM dbo.[order]
WHERE status = 'cancelled' )
ORDER BY order_ID DESC";

This is for ms SQL 2008
>>
>>56711252
>MS SQL
I found your problem
>>
>>56711268
Right, but in theory this should have worked. Do you see any problem with the syntax?
>>
>>56711252
I might be a retard, but why do you not write
WHERE status != 'cancelled' instead of an extra SELECT statement?
>>
>>56711311
That worked. I feel like a dumbass now but thanks anon.
>>
>>56707070
Make 4chan reader for DOS
>>
File: 1433838266510.jpg (850KB, 1500x1125px) Image search: [Google]
1433838266510.jpg
850KB, 1500x1125px
How do I get values I strip from a packet using a python script into a SQL database?
>>
>>56711190
the github meme ide? how is it?
>>
File: cpp.png (14KB, 933x164px) Image search: [Google]
cpp.png
14KB, 933x164px
super noob here
how should one go about I return this filename without the extension
I know how to do it with std;:string but this TCHAR stuff is new and confusing to me
>>
>>56707070
Javascript, because you don't have to worry about types and shit
>>
>>56711365
http://en.cppreference.com/w/c/string/wide/wcschr
find L'.' replace with L'\0' done.
>>
>>56711363

Nothing fantastic but it works and is pretty lightweight.
>>
Rust vs. Go vs. D vs. C++
?
>>
>>56711534
>lightweight
i thought it was the opposite. it's closest to a web app isn't it? every new release hn just complains about the speed
>>
>>56711559
C++ > D > Rust > Go

As it currently stands.
>>
>tfw learning C++ coming from C#

this shit is a clusterfuck, but I want to make games and the magical garbage man gives me anxiety
>>
>>56711370
Terrible bait 0/10. Responded so you know to try harder next time.
>>
>>56711793
>C++ at the top
You 'avin a laff m8?
>>
>>56708905
>>56708928

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

struct tree
{
int var;
tree * right;
tree * left;
};

tree * maktree(int depth , int key_value)
{
tree * node = new tree;
node->var = key_value;
node->right = NULL;
node->left = NULL;

if(depth != 0)
{
unsigned int next_node_key_001 = rand()%30 + 1;
unsigned int next_node_key_002 = rand()%30 + 1;

while(next_node_key_001 == next_node_key_002)
{
unsigned int next_node_key_001 = rand()%30 + 1;
}

if(next_node_key_001 < next_node_key_002)
{
node->right = maktree(depth-1 , next_node_key_002);
node->left = maktree(depth-1 , next_node_key_001);
}
else
{
node->right = maktree(depth-1 , next_node_key_001);
node->left = maktree(depth-1 , next_node_key_002);
}
}

return node;
}

void print_tree(tree * tree_p , unsigned int start_node = 0)
{
printf("Node depth = %d ---- var = %d\n" , start_node , tree_p->var);

if(tree_p->right != NULL && tree_p->left != NULL)
{
print_tree( tree_p->right, 1 + start_node);
print_tree( tree_p->left, 1 + start_node);
}
}

void release_memory(tree * tree_p)
{
delete[] tree_p;
}

int main()
{
srand(time(NULL));

tree * tree_p = maktree(4 , rand()%30 + 1);
print_tree(tree_p);
release_memory(tree_p);

return 0;
}
>>
>>56711000
Pycharm is very good. But I prefer editing in vim. I don't use python for real applications.
>>
>>56711919
>delete[] tree_p;
>tree
>didn't even fix the shit I mentioned.
Kill yourself.
>>
>>56711934
What are you talking about?
I don't follow you..
>>
>>56712020
You're attempting to free p_tree as if it was an array, and you're only freeing the top (root) node, not the children. You need to traverse bottom-top and keep deleting them.
>>
>>56712020
Visit left child
Visit right child
Delete current node
Recursively.
>>
>>56706940
What anime? She's pretty cute
>>
File: Wabbit.png (1MB, 1039x896px) Image search: [Google]
Wabbit.png
1MB, 1039x896px
Sup /dpt/

Anyone test my program and see why it's not working?
>>
>>56712131
>she
>>
>>56712134
xD
>>
>>56711838
You can avoid garbage collection you know by being a bit clever
>>
>>56712134
he he he he he
>>
>>56706940
Retards, recursion and trees do not mix. Leave this shit to the real programmers.
>>
Learning Godot. Using GDScript is quite fun in the context of the engine. It feels pretty decent to me, but I haven't tried Unity to compare it to.
>>
>>56712173
But recursion and trees go really well together.
>>
>>56712131
>>56712134
oh u funny gaises xD
>>
>>56712188
Put "learn to read" on your list to faggot.
>>
>>56712227
I can read just fine desu :^)
>>
File: 1358832664505.gif (922KB, 400x225px) Image search: [Google]
1358832664505.gif
922KB, 400x225px
>Intel Cilk Plus people proposing array sections to C2X.
>mfw I was done reading the proposal

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2081.htm
>>
>>56712239
Not him, but allow me to specify. Retards & recursion & trees do not mix.
>>
>>56712227
You're sentence is ambiguous.
Are you saying that people who are retarded, recursion, and trees do not mix, or are you calling us retards and saying that recursion an trees don't mix?
>>
>>56712227
What are you talking about?
I don't follow you..
>>
>>56707366
Come on guy, you should post it. To heck with those guys.
>>
>>56712020
You're changed the language from C to C++, which is completely retarded.
>>
>>56712227
You being this retarded is confirmed.
>>
>>56712251
I hope that makes it in.
That seems like it would be useful as fuck.
>>
>>56712314
>>56712251
>bloat
fuck off
>>
>>56712251
So just Python slices?
>>
>>56712261
oh, i thought the was addressing an audience of retards. I see...
>>
>>56712335
How is that bloat?
They're efficient vectorised operations on arrays.
>>
>>56712380
FUCK OFF WITH YOUR BLOAT
>>
>>56712392
Enjoy using C89 and your lack of optimisation features then.
>>
>>56711919
I don't get why you're traversing this tree the way you are...
I had to look this up, because it didn't look familiar at all.

Pick one of the normal traversal methods...
>Pre-Order
Node
Left
Right

>In-Order
Left
Node
Right

>Post-Order
Left
Right
Node

I mean... at least... WHY are you traversing it that way?
Like, is there any REASON to traverse it in reverse pre-order?

Also, there's nothing there to reorganize it.
>>
>>56712314

Yeah, it would make some stuff that are currently verbose or hard in C to do completely trivial. It's not horrible syntax either, unlike C++'s proposed array_views and etc.

>>56712335
>>56712392

>Each of the expressions in a section triplet shall have integer type. The postfix expression in a section expression shall have type “pointer to complete object type”; the type of the section expression is “type” (i.e. the same type as the corresponding “simple” subscript expression; there is no section type).

If you call that bloat, I have no idea why you are using C at all in any form. Might as well use assembly.

>>56712359

No because it's not extracting the subset of elements and repackaging them in another array. It's just kind of a complex pointer to the entire set of values specified in the array section that you can then manipulate.

So instead of this code here:

for (i = 0; i < 10; i++)
A[i] = 5;


You can just do this

//[:] implies the whole array
A[:] = 5


It makes vectorization for compilers and humans much better.
>>
>>56709144
I hope you're not being serious. If you are, you should honestly go out a little more.
>>
>>56709138
Mind sharing a little more info on this? Looks neat.
>>
>>56712583
I don't really see the point of it though. C isn't a numeric computation language. There are well written ans thoroughly optimized n-dim array and BLAS libraries already written for those use cases.
>>
>>56710113
What about Building your own html parser. That is quite a learning project
>>
Complex operator+(Complex lhs, const Complex& rhs){
lhs += rhs;
return lhs;
}

in .cpp
should I be getting "no match for operator+ (operand types are Complex and Complex"?
>>
>>56712811
Yes, it's a C++ feature.
>>
File: failure.png (81KB, 1920x981px) Image search: [Google]
failure.png
81KB, 1920x981px
anyone got any ideas?
>>
>>56712735

It is a continuation of C and C++'s parallelism efforts. It says this in the description.

>This document provides a specification for the array section portion of the Intel® Cilk™ Plus language extension. Array sections are intended to allow users to directly express high level parallel vector array operations in their programs. This assists the compiler in performing vectorization and auto-parallelization. From the users' point of view, they will see more predictable vectorization, improved performance and better hardware resource utilization. Array sections are an extension of the standard C/C++ languages, including features that are designed for easy expression of array operations and simplified parallel function invocation.

At worst, with no multithreading or or assembly vector operators, it could be made optional or the compiler can just make it so that it's just syntactic sugar.

I did a bit more digging and found this on array sections with Cilk.

https://www.cilkplus.org/tutorial-array-notation

It actually could be a lot more useful than I thought it could be.
>>
>>56712879
try inputting "name"
>>
>>56712879
use raw_input() like it says on the left
in python 2, you use raw_input() to store string values, not input()
raw_input() stores it as "text" which is a string, whereas input() stores it as text, which is a variable

I think you should learn python 3 anyway
>>
>>56712849
funny, but how can it not find it? everything is compiling fine but for whatever reason its as if the overload doesnt exit
>>
python issue
print 'Welcome to the Pig Latin Translator!'

original=raw_input('Enter a word?')
empty_string = ""
if len(empty_string) > 0:
else:
print "empty"

Error message
  File "python", line 7
elif:
^
SyntaxError: invalid syntax
>>
>>56712909
It's also Intel chips only. Honestly I'm all for there being a dialect of C that's extended to cover the full feature set of x86, but Intel won't rule forever.
>>
>>56713092
not use python in a while, but elif surely needs conditional after it, like:
    elif (1 > 0):
>>
>>56713092
>>56713124
also elif: would have to come before the else: statement
>>
Currently still using a T420 for my day-to-day. It's a lower tier model, with a 1366x768 screen, no Bluetooth, and a 6-cell battery pack that's about 50% capacity.

We just bought a T420 and a 9cell battery pack for a project at school. It was kind of a blind bid but the battery ended up being brand new 2016 made, and the T420 had a 1600x900 screen and Bluetooth. All for like $300.

I really like it. And want to upgrade my laptop, but I can't justify $300 on a slight upgrade. Is there a modern laptop that rivals the T420 in durability, Linux support, etc?
>>
>he doesn't use for else statements
>>
>>56713152
I really don't understand why people shit on it so much. Are they honestly too retarded to learn a new flow control device?
>>
>>56713152
what's a "for else" statement?
>>
>>56713124
>>56713134
mistyped correct error message
  File "python", line 7
else:
^
SyntaxError: invalid syntax
>>
>>56713220
probably need to have code before else:

just write
if len(empty_string) = 0:
print "empty"

instead
>>
File: 1471450111834.png (213KB, 484x642px) Image search: [Google]
1471450111834.png
213KB, 484x642px
>using a language that has for else and elif but not for elfor
>>
>>56713256
the for is for elfor?
>>
>>56713237
doesn't work
Welcome to the Pig Latin Translator!
Enter a word? test
empty
>>
>>56713256
the fuck is for elfor?
>>
>>56713256
>elif
>>
File: ada95.jpg (85KB, 500x676px) Image search: [Google]
ada95.jpg
85KB, 500x676px
why is this language so obscure?
why nobody talk about it here?

genuine questions, i'm not implying anything
>>
>>56713276
>>56713287
Is learning new control structures really that hard guys?
>>
>>56713282
of course it works, what are you expecting
if len(empty_string) = 0:
will always work. empty_string is empty.
>>
>>56713301
I'm a same fag. fucked up the first post.

no it's not. Just want to know what the fuck it is.
>>
>>56713097

There's nothing in the syntax that indicates that array sections can only be done with Intel hardware. As far as I call, if you have SIMD on your hardware, your compiler can support this no problem. The only problem is with non SIMD platforms and what would happen if C gets this for those platforms.
>>
>>56713302
oh shit yeah, justr had a retard moment
>>
>>56713282
what are you trying to do?
finding out whether 'original' is empty?
then you should be using len(original) and not empty_string, or comparing original to empty_string.
>>
>>56713312
for (...)
else for (...)
else if (...)
else (...)

for (...)
elfor (...)
elif (...)
else (...)
>>
new thread when (now)
>>
>>56713340
I still don't understand. What's an actual example of elfor.
>>
>>56713367
else for (...)
>>
>>56713374
and how does that work in the context of actual code. That's not telling me what the statement actually does.
>>
>his language doesn't add the defwhiliforcase control flow structure
>>
Just use goto :^)
>>
>>56713421
> :^)
there's absolutely nothing wrong with goto

:^)
>>
>>56713393
Not him, but what is there to not understand?

ifor i in 0..10:
print(i);
elfor j in 0..20:
print(i + j);
>>
>tfw lisp automagically allows for-else using the very flexible do
(do ((i j (- i 2)))
((<= i 0) (princ "j is either even or not an integer"))
(if (= i 1) (return (princ "j is odd"))))
>>
new thread when ? :3
>>
>>56713450
>automagic
Fuck you
>>
File: 1460010022031.jpg (67KB, 416x508px) Image search: [Google]
1460010022031.jpg
67KB, 416x508px
>elif and friends
if you really want this cancerous bullshit just use macros
>>
We used to have very dedicated newthreadfags, but now the threads go on well past 310 posts.
>>
>>56713536
>>
>>56713479
You don't even need macros for this nonsense
elif

else if

fucking magic
>>
>>56713589
Stop lying
>>
>>56713614
Telling the truth is against my religion
>>
What's worth doing on codecademy, done with python on it since it's python 2.x
>>
>>56713774
So far I'm thinking
>learn git
>learn the command line
>HTML & CSS
>PHP
>>
>>56713445
what the fuck does that fo? why is that different from
for i in 0..10:
print(i);
for j in 0..20:
print(i + j);
>>
>>56707003
/* NOTES:
* compiling with -O2 under GCC introduces valgrind errors which
* makes it seem the function is peeking backwards into unallocated memory
* almost as if it is stuck reading old pointer values before it was realloc'd
* eg. "Invalid read of size 4"
* "Address 0xABCDEF is 72 bytes inside a block of size 73 alloc'd"
* Fix if this becomes a real issue.
*/

Quality coding m8
Thread posts: 367
Thread images: 33


[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.