/dpt/ - Daily Programming Thread

old thread: What are you working on, Cred Forums?

Other urls found in this thread:

akaribbs.mooo.com/
github.com/microsounds/akari-bbs
mirrors-usa.go-parts.com/gcc/releases/gcc-6.2.0/
msys2.github.io/
catb.org/esr/structure-packing/
pastebin.com/2NfZ6D95
pastebin.com/5MKk5yQU
en.cppreference.com/w/c/string/wide/wcschr
open-std.org/jtc1/sc22/wg14/www/docs/n2081.htm
cilkplus.org/tutorial-array-notation
twitter.com/NSFWRedditGif

how to make a tree in c?

>Degenerate shit
Delete this thread an kill yourself.

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

There's a nice, small implementation in the book "The practice of programming".
Just doing some tedious shit in C#.

I love anime desu senpai

Whats an alternative to goto in python?

akari-bbs rev. 11 is now live!
akaribbs.mooo.com/

Added in this update:
>Rotating banners
>Interactive linkquoting
>404 page
Also, I released it GPL.
github.com/microsounds/akari-bbs

How do I make a python script restart when it reaches the end?

Why would you need that? Just loop your program logic.
Naice that you actually released the source, good work.

I'm getting tcc: error: no input files in cmd. Help.

just use gcc you fucking autist

while (1)
{
/* your shit */
if (some_condition)
break;
}

Daily reminder that your qt3.14 trap >waifu looks like this IRL

hott

>/* 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.

Q: Best language to use while drunk on a weeknight?

I submit VB, since it really is quite comfy.

wow a whole 16 bytes wasted

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.

>using a meme language like C

Why would I use a switch case?

what you use?

stop false flagging, akkarin

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++

>too retarded
too smart*

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

>too smart
*"too smart"

captcha is alabama

Actually R is safer and highly recommended for programming than c++

>There are other cases in C where a constant may be required.
I haven't really had this problem.

Why can't you just install it from your package manager?

Really, what C++ really means is D.

So you should use D.

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

const char C = 'B';
C++; -- C

Damn, I'm stupid. What package manager?

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.

"lighttpd required"

uh, nginx is better user

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

>GPL
why not LGPL?

...

What makes it better?
lighttpd is pretty simple for what it is

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

>distro
user he's probably on windows

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

Pretty cool, just wished it were compatible with nginx.

Is learning C as my first programming language a meme?

You'd have much easier time with more modern languages.

If by meme you mean core programming concepts, yeah.

I'm sure it'll run on ngnix if you can enable the cgi module.

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?

yeah, don't post it

Not at all, something is better than nothing. Until you have enough solid projects to replace it, i would keep it there.

Yes.

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.

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?"

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

Is java cool to learn
Even if it is owned by Oracle, now

it would probably make finding a job easier, but personally, i never found it pleasant to write non-enterprise programs in.

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?

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.

If you ask Cred Forums: 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

Cool? Nah. Useful? Depends on what you're planning but Java is quite popular among enterprise programming jobs.

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

In fact I could do it without a dice have it randomly pick a number between 1-6

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.

>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?

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,

yeah, i have no clue how to do that. o well

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

Nah, actually leftover Financial Aid so if anything, I'm wasting pennies of my parents money. I'm a poor.

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.

>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?

stupid robot

Does any serious company actually use node in production unironically?

directed acyclic graph

>being attracted to chris-chan
Man, that's even worse than being Chris-chan.

...

yep, I even know about a certain video game company that uses it for their servers

...

A C imageboard belongs in /wdg/ like tomatoes belong in a fruit salad.

have they explained why they picked node over other options

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.

msys2.github.io/

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

Salsa -- the tomato-based fruit salad.

Ruby -- the nigger-based nigger nigger

Argh. Trying to successfully use Group By or Group Join in a VB LINQ is frustrating.

...

>some abstracted methods like .map, .max, .find, etc.
They're called higher-order functions. Go OOP in loo.

plz hpelp

explain

user -- the ignorance-based racist poltard.

Someone tell me something simple I can do in python, already done fizzbuzz

> Using the N-word.
Go back to your containment board stormtard. We don't want you here.

No, you're thinking of OSGTP.

Looks like you have to go back

>salsa
>salad
como

implying reddit isn't full of trumptards. At least on Cred Forums they don't get the satisfaction of gaining virtual points for shitposting.

what's the current exchange rate of (you)'s to upvotes?

It's all part of Cred Forums's master plan

@56707848
dunno user, 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?

I can't get to bed and now I'm considering pulling an all-nighter
Help

It's from a D&D joke.

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.

I'm using my D with your mom

You don't hang out with many normies, do you?

#include

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???

Use GDB

>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?

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.

Yep.

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?

Aside from the root of the tree, you're never actually allocating anything.

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.

>Are there any cryptocurrency proof-of-concept methods that are open source?
The bitcoin client is open source, you know.

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

stdout
./a.out
v = 1
v = 529354816
v = -1913371253

That's still incorrect. Those pointers become invalid as soon as you leave the function.
You really need to learn how allocation works.

so I have to malloc and then free?

Yes. A tree is a dynamic data type, so you can't get around using malloc.

To "get around something" to is "avoid something".
So he can't avoid using malloc.

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

>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
#include

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?

>Does any serious company actually use node in production unironically?

Don't Facebook and Google use it?

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

I just realized I didn't free.
does not freeing really matter if its all done at the end?

Pretty nice, but that spacing is disgusting.

>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

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

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

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

I was told to use spacing more so that is more readable.

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

>link
nice, just put it into backlog

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.

#include
#include

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 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;
}

Reminder that const in C does not mean what it means in C++.

if c user is constructively criticizing my tree.c, keep at it pls
imma sleep, so I'll look at it tomorrow
thanks pham

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

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

capped
I see, I'll keep that in mind in more serious programs

why do so many people like children cartoons for girls? its like bronies obsessing over mlp.

grow up.

leave him alone, he gets off on being called out

Javascript is disgusting but I have to learn it for a class

can we please reply to him with anime girls being smug or laughing

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.

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

>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

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.

r8 my density graph viewer
I just finished it
I'm a little proud

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 Cred Forums

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?

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

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

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

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

But this shit is good enough to make great software.

based todd

moot@Cred Forums.org

>Yes. A tree is a dynamic data type, so you can't get around using malloc.
Not true.

pastebin.com/2NfZ6D95

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

>Stack performance
Subtracting a number (growing the stack) will always be faster than a jump.

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.

Very nice. Clever.

This is sleep sort level shit.

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.

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

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.

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

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

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: pastebin.com/5MKk5yQU

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

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

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

pls help im nearly done

python 3

I'm not touching Windows forms.

running = True
while running:
gender = input("Are you male or female(NO TRANNY!)")
if gender == "male" or gender == "female":
break

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

>Are you male or female(NO TRANNY!)
Needs more gender politics.

Why not set running to false?

MALE = 0;
FEMALE = 1;

if gender == MALE | FEMALE:
:)

I think he can cast lower on his input instead of his male and female, too lazy to go check though

instead of the break? I was just trying to change his code as little as possible

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.

>his

leave the sexism on Cred Forums

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

OK, what about the time usage of recursive algorithms vs iterative for very large trees?

but does it compile?

Need ideas for a programming project.
Any givers? Maybe some neat API to work with?

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

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

yes, it does, without error

I meant a learning project, not a chore for a front-end webdev.

There you go then. Inheritance in C++ works.

#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
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

>GPL
McFucking kill yourself.

GPL is anti-freedom, and communism.

What's wrong with communism?

What exact line are you getting that error on?

Oh god, I added it back in and now it doesn't crash.
Something must be mega-fucked somewhere.

see

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.

>#rekd
Not that I disagree but
>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.

line 18, my bad

it does not work, though ...

ally is shown to have no members.
and i cannot treat ally as an card-type object either.

>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

Are you posting from a communist country? No? Wonder why that is?

i know it ought to be like that. but it isnt, for some reason.

wait a minute, i will show you the screenshot

Is that OpenGL?

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

Doesn't answer the question.

communism is empirically proven to produce much worse outcomes than market economys. so most ex-communist countries adopted market economys afterwards.

>snprintf exists
B A S E D C

Give me your honest opinion about Go.

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.

interface {} garbage tier. avoid.

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?

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?

Still avoiding the question by overgeneralising the answer.

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.

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.

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

This is an issue in your IDE.
Also try it your auto-completion works outside the class definition.

see i dont use code::blocks so im not sure but you should be able to change the auto-completion to include inherited members.

So what are you saying? GPL will make my code run slower?

should I learn Rust or Go? or stick with Python

i also thought it is IDE-related.

so i have to change the auto-completion mode, seemingly.

depends what you want to do exactly

Go is much much easier than Rust by the way

yeah, the auto-completion seems to recognize Ally everywhere

Why should anyone even learn rust?

i guess that was my question

Pussy bitches who need their 'safe space' to program in.

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.

yup, i thought they were the same
so Rust is like C
and Go is like C#
who has better lib support?

>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?

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

Try making them all asymptotically optimal.

programming is for nerds

>Statical type systems are SJW thing
wow

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?

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.

Netbeans

i recommend notepad but maybe you would like notepad++ since it adds a bit of color

>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

meant for

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

>MS SQL
I found your problem

Right, but in theory this should have worked. Do you see any problem with the syntax?

I might be a retard, but why do you not write
WHERE status != 'cancelled' instead of an extra SELECT statement?

That worked. I feel like a dumbass now but thanks user.

Make Cred Forums reader for DOS

How do I get values I strip from a packet using a python script into a SQL database?

the github meme ide? how is it?

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

Javascript, because you don't have to worry about types and shit

en.cppreference.com/w/c/string/wide/wcschr
find L'.' replace with L'\0' done.

Nothing fantastic but it works and is pretty lightweight.

Rust vs. Go vs. D vs. C++
?

>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

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

Terrible bait 0/10. Responded so you know to try harder next time.

>C++ at the top
You 'avin a laff m8?

#include
#include
#include

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;
}

Pycharm is very good. But I prefer editing in vim. I don't use python for real applications.

>delete[] tree_p;
>tree
>didn't even fix the shit I mentioned.
Kill yourself.

What are you talking about?
I don't follow you..

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.

Visit left child
Visit right child
Delete current node
Recursively.

What anime? She's pretty cute

Sup /dpt/

Anyone test my program and see why it's not working?

>she

xD

You can avoid garbage collection you know by being a bit clever

he he he he he

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.

But recursion and trees go really well together.

oh u funny gaises xD

Put "learn to read" on your list to faggot.

I can read just fine desu :^)

>Intel Cilk Plus people proposing array sections to C2X.
>mfw I was done reading the proposal

open-std.org/jtc1/sc22/wg14/www/docs/n2081.htm

Not him, but allow me to specify. Retards & recursion & trees do not mix.

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?

What are you talking about?
I don't follow you..

Come on guy, you should post it. To heck with those guys.

You're changed the language from C to C++, which is completely retarded.

You being this retarded is confirmed.

I hope that makes it in.
That seems like it would be useful as fuck.

>bloat
fuck off

So just Python slices?

oh, i thought the was addressing an audience of retards. I see...

How is that bloat?
They're efficient vectorised operations on arrays.

FUCK OFF WITH YOUR BLOAT

Enjoy using C89 and your lack of optimisation features then.

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.

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.

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

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.

I hope you're not being serious. If you are, you should honestly go out a little more.

Mind sharing a little more info on this? Looks neat.

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.

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"?

Yes, it's a C++ feature.

anyone got any ideas?

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.

cilkplus.org/tutorial-array-notation

It actually could be a lot more useful than I thought it could be.

try inputting "name"

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

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

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.

not use python in a while, but elif surely needs conditional after it, like:
elif (1 > 0):

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

I really don't understand why people shit on it so much. Are they honestly too retarded to learn a new flow control device?

what's a "for else" statement?

mistyped correct error message
File "python", line 7
else:
^
SyntaxError: invalid syntax

probably need to have code before else:

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

instead

>using a language that has for else and elif but not for elfor

the for is for elfor?

doesn't work
Welcome to the Pig Latin Translator!
Enter a word? test
empty

the fuck is for elfor?

>elif

why is this language so obscure?
why nobody talk about it here?

genuine questions, i'm not implying anything

Is learning new control structures really that hard guys?

of course it works, what are you expecting
if len(empty_string) = 0:
will always work. empty_string is empty.

I'm a same fag. fucked up the first post.

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

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.

oh shit yeah, justr had a retard moment

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.

for (...)
else for (...)
else if (...)
else (...)

for (...)
elfor (...)
elif (...)
else (...)

new thread when (now)

I still don't understand. What's an actual example of elfor.

else for (...)

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 :^)

> :^)
there's absolutely nothing wrong with goto

:^)

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)))
((

new thread when ? :3

>automagic
Fuck you

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

...

You don't even need macros for this nonsense
elif

else if

fucking magic

Stop lying

Telling the truth is against my religion

What's worth doing on codecademy, done with python on it since it's python 2.x

So far I'm thinking
>learn git
>learn the command line
>HTML & CSS
>PHP

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);

/* 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