[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: 382
Thread images: 39

File: 1480974118479.png (518KB, 974x974px) Image search: [Google]
1480974118479.png
518KB, 974x974px
What are you working on, /g/?

Old thread: >>59620334
>>
Dear /dpt/,

What are the programming languages you'd say you know well? Something you'd put on your resume, and you'd would feel comfortable doing the interview exercises in
>>
>>59623865
C
>>
File: 1361734873016.gif (3MB, 278x296px) Image search: [Google]
1361734873016.gif
3MB, 278x296px
Proper animu macro
>>
>>59623865
Ada, C, Verilog
>>
File: 1453782850239.jpg (184KB, 850x782px) Image search: [Google]
1453782850239.jpg
184KB, 850x782px
>>59623850
Why must you people act like elitists when it comes to langs?
>>
>>59623865
Python
>>
Re-implementing Lisp in Haskell.
>>
>>59623865
>What are the programming languages you'd say you know well? Something you'd put on your resume, and you'd would feel comfortable doing the interview exercises in
C, Java, C#, PHP, ASM
>>
>>59623865
C, C++, Lisp
>>
>follow instructions in book
>"Hello world!" app wont run
>didn't write a single line, just chose empty activity in Android IDE, emulating Marshmallow on a Nexus 6P

please help.
>>
>>59623865
C, OCaml, Python, probably Java too
>>
File: ecere.png (882KB, 1587x796px) Image search: [Google]
ecere.png
882KB, 1587x796px
Holy shit why is nobody talking about this esoteric language!
http://ecere.ca/
>C ABI
>cross platform(desktop platforms, android, js trough emscripten)
>open sores
>OOP for the simple minded
>>
OCaml, C & C#
>>
File: data.png (105KB, 1386x589px) Image search: [Google]
data.png
105KB, 1386x589px
Can anyone point me in the direction of a tutorial that will help me parse this data using Python pandas?
>>
>>59623925
Why not just use C++ and pretend you have C with classes at that point?
>>
>>59623865
C, C++, OCaml and Matlab
>>
>>59623941
>convert to csv
>import pandas as pd
>pd.read_csv('filename')
>>
>>59623952
>C ABI without shitty fully retarted sepples name mangling
>actually designed unlike sepples
>no templates shitting up the lang
Looks way better than sepples.
>>
>>59623890
How does it feel knowing there's no job lined up for you once your current companies kicks you out?
>>
>>59623925
Is this impressive?

Most new langs have a c abi, are OS and are multi-plat.
>>
>>59623976
Right, I've gotten that far.

The issue I'm having is getting the data out of a cell with specific parameters. This data is airplane performance data, where the columns represent weight and the rows represent altitude. So at 240000kg and 21,000ft the plane is burning 8420 kg/hr and flying 402 kts. I'm trying to figure out how I can feed pandas and weight and an altitude to get my fuel burn and speed.
>>
>>59623998
bretty gud, actually.
I'll be laughing at you cucks when I have thousands of more job opportunities than you could ever wish for.
>>
>>59623865
Java is the only correct answer GOD you are all such plebs
>>
>>59624025
Even if I knew Java I would still not put it on my resume because I'd be too embarrassed
>>
>>59623987
>>no templates shitting up the lang
Just because C++ gave them a stigma doesnt mean theyre bad.
Templates are great.
>>
>>59623998
Learning new languages is fucking easy
>>
>>59624005
try to write library in your new lang and use it from C nigger.
>>
>>59623998
//Original version
void parse(char** tokens, char* buffer)
{
char* tok = strtok(buffer, " ");
if(tokens[0] != NULL)
free(tokens[0]);

tokens[0] = (char*)malloc(strlen(tok)+1);
strcpy(tokens[0], tok);

//Rest of function is irrelevant
}


//Updated version
void parse(char* cmd, char** args, char* buffer)
{
char* tok = strtok(buffer, " ");
if(cmd != NULL)
free(cmd);

cmd = (char*)malloc(strlen(tok)+1);
strcpy(cmd, tok);

//Rest of function is irrelevant
}


Reposting.

First version works fine, if I print tokens[0] back in the calling function it spits out the correct string.
Second version does not. Printing the cmd char* inside the parse function works fine, all the way to the end of the function
Attempting to print it in the calling function does not work.
If I don't check to see if it's NULL, valgrind spits out
Address 0x0 is not stack'd, malloc'd or (recently) free'd

If I do check to see if it's NULL, it'll print whatever conditional statement I put in.

so:
Before parse
>NULL
Inside parse
>"Command"
After parse
>NULL

>>59624024
See above
>>
>>59624044
Why in the world would i do that, ivan?
>>
>>59624044
D is a better language
>>
Continuing my quest to become a grand Lisper. I changed Racket with Clojure and HtDP with Brave Clojure.
>>
Java is pure.
>>
>>59624044
[spoiler] Ada [/spoiler]
>>
>>59624014
>df = pd.read_csv('filename', index_col='WGT')

And use http://pandas.pydata.org/pandas-docs/stable/indexing.html to index your col and row
>>
What relevant software is written in Lisp?
>>
>>59623925
>go to their forums
>community is basically dead

no thanks
>>
>>59624066
clojure is not lisp.
>>
File: absolutelydisgust.jpg (94KB, 600x450px) Image search: [Google]
absolutelydisgust.jpg
94KB, 600x450px
>>59624082
Pure shit
>>
File: how.png (58KB, 1013x314px) Image search: [Google]
how.png
58KB, 1013x314px
How do I solve this?
Do I have to save all past abundant numbers?
How do I know that 24 is a sum of two abundant number if I haven't "remembered" that 12 is one?

Or maybe I should just go backwards from 28123 and always check each summand?
>>
>>59624039
undergrad who thinks he knows a couple of languages but in reality he knows 0 detected
>>
>>59624103
Why is it not a lisp?
>>
>>59624044
>use it from C
literally pointless
>>
>>59624035
you would because most software dev jobs are all in java
>>
>>59624135
Good thing I'm not a shitty programmer who can't afford the luxury to be selective with where they apply to
>>
>>59624083
>ada
>new lang
>>
>>59624117
It's a Lisp, but it is not Lisp.
>>
>>59624146
bold claims my dude
>>
File: help.jpg (216KB, 1331x613px) Image search: [Google]
help.jpg
216KB, 1331x613px
I hit empty activity in android studio, but when I try to run the hello world app it gives me these error messages.

Did I install something incorrectly?
>>
>>59624059
That's strange, it seems like your char * is going out of scope on return. What does your function call/calling code look like? Do you leak the malloc'd memory as well?
>>
>>59624160
for you
>>
>>59624168
help yourself m8.
Apparently it doesnt like the "parent" strings
>>
>>59624168
if that's copy pasted, then probably different versions
>>
>>59624059
>this is the kind of shit C cucks have to deal with for the most trivial problems
>>
>>59623865
Python, C++, Haskell, and C in that order. SystemVerilog as well, but that's not very syntactically verbose and requires more knowledge of FSM design then anything.
>>
>>59624156
Has there ever been a language called Lisp which is not a dialect?
>>
>>59624146
name one useful software you wrote and show proof
>>
>>59624115
Why isn't it, again?
>>
>>59624185
char* cmd = NULL;
char* args[MAXARGS];
char buffer[MAXLINE];
int i = 0;
for(; i < MAXARGS; ++i)
args[i] = NULL;

while(fgets(buffer, MAXLINE, stdin) != NULL) {
buffer[strlen(buffer)-1] = '\0';

parse(cmd, args, buffer);

//If I omit the conditional, it segfaults
if(cmd == NULL)
printf("cmd is NULL\n");
}


And it looks like yes, I lose whatever gets malloc'd and copied on crash. So it's hanging out there somewhere
>>
>>59624261
I'm retarded

printf("%s\n", cmd);

is what will cause a segfault if I skip the conditional
>>
>>59623850
I wrote bubble sort in clojure
(defn bubble-sort [vector]
(defn bubble [vec vec2 bub]
(let [f (first vec)
rest (rest vec)]
(if (empty? vec)
(conj vec2 bub)
(if (> bub f)
(recur rest (conj vec2 f) bub)
(recur rest (conj vec2 bub) f))
))
)
(defn bubble-iter [vec count]
(if (= count 0)
vec
(recur (bubble (rest vec) [] (first vec)) (- count 1))))
(bubble-iter vector (count vector)))
>>
File: 1118858050.jpg (57KB, 300x376px) Image search: [Google]
1118858050.jpg
57KB, 300x376px
finally found nice c++ book, gonna fall for c++ meme. with me luck /dpt/
>>
>>59624303
this book sucks
>>
>>59624303
Good luck my man
>>
>>59624244
Knowing a language != knowing the syntax

You better know the in and outs of the language, have a few projects written in it, know the standard library and the common 3rd party libraries, know the standards for good code, and have something to show for it
>>
>>59624329
A month of work
>>
>>59624113
I can think of two ways. First is a map, keeping track of all abundant numbers seen so far. Then, for the current number, after checking if it's abundant (and adding it if so), walk down all values i in the map. If (curNum - i) is in the map, add curNum to the running sum and continue. Another way is only look for abundant numbers, again keeping them in a map. When you find a new one, add it to all other abundant numbers in the map, then add that to the running sum. Might need to have a set for uniqueness checking though (or divide by 2 at the end or something).
>>
How do you format if statements with really long conditions?
if (thisShitIsReallyLong() || thisShitIsLongToo() || wowThisCodeIsSoSelfDocumenting() || jesusFuckingChrist()) { 
// stuff
}

if (thisShitIsReallyLong()
|| thisShitIsLongToo()
|| wowThisCodeIsSoSelfDocumenting()
|| jesusFuckingChrist()) {
// stuff
}
>>
>>59624378
Check the styling guidelines that you're using
>>
I inherited a legacy codebase of a million lines of spaghetti code.

What do? I'm trying to not kill myself here.
>>
>>59624378
haskell
fmap or $ sequence [thisShitIsReallyLong, thisShitIsLongToo, wowThisCodeIsSoSelfDocumenting, censoredThisOne]
>>
>>59624378
>using a language that encourages camel case instead of underscore-separated words

This is the truly horrifying part
>>
>>59624378
if(thisShitIsReallyLong() ||
thisshitIslongToo() ||
...) {
...
}
>>
>>59624360
first option is what I was thinking about, too.
I'll just first find all abundant numbers til the upper limit and then work my way to the solution. Thanks for your thoughts anyways
>>
>>59624089
AutoCAD.
Emacs.
Witcher 2 (naughty dog games).
Something in Hubble uses it.
>>
>>59624229
Yes. The original LISP.
>>
>>59624277
does it work if you change your parse definition to char * parse(char ** args, char * buffer); and thus in the while loop would look like cmd = parse(args, buffer); ?
>>
>>59624229
Yes. McCarthy's original Lisp.

>>59624450
GIMP but people hate it.
>>
>>59624450
>Witcher 2 (naughty dog games).

How do I know the rest of your post isn't bullshit
>>
>>59623850
I'm currently finishing off the client side of some server software.
Not gonna lie, I feel really happy now the cryptography algorithm is fixed. Could have it ready for launch tonight.
>>
>>59623865
Java, C#, Scheme, OCaml, maybe F#
I would put others on a resume but I'd need to review a little bit if I was gonna do interviews for a job that involves them
>>
>>59624484
My bad. Uncharted, not Witcher.
>>
>>59624484
naughty dog games did use Lisp at least back in the Ps2 days where they wrote their own dialect, compiler and shit just to make crash bandit or w/e. There's a whole blog about it.
>>
>>59624465
Yes, that works without issue. Although in reality this function already has a return value so that's not an option.

It's clearly handling it by value and not by reference, but I can't imagine why the hell it would. Unless it's expecting it to be just a single character, and not an array of characters?
>>
>>59624392
the style guide says to avoid lines longer than 80 characters but not how to handle long if statements.
>>
File: dmr-1.jpg (33KB, 540x370px) Image search: [Google]
dmr-1.jpg
33KB, 540x370px
>>59623887
>>
>>59624508
yeah I remember reading them optimizing for 4x cd read speeds and largely making their level design according to those hardware limits.
>>
>>59624310
i skimmed through Accelerated C++(too old), Stroustrup books(can't apprehend those, seems like academic gibberish to me), C++ primer(too much info) - all those also have bad typography (the versions i copied at least). The Gregoire one is the best i found so far(i'm not very smart and don't have much time to dive deep), its 2014 and has comparisons to C and C++14 coverage. Probably gonna proceed with Effective Modern C++ after i finish this one. Have a better book advice?

>>59624315
thanks anon
>>
>>59624523
Good bye Gandalf
1946-2003
>>
>>59623865
C, C++, C#, Clojure, Chicken
>>
>>59624113
I've done it this way

#include <iostream>
#include <vector>
#include <math.h>

bool is_abundant(const long& number) {
long sum = 0;
for (long i = 1; i < number/2; ++i)
if (!(number % i)) sum += i;

return (sum > number ? true : false);
}

bool check_if_sum(std::vector<long>* abundants, const long& number) {
int i = 0, j = abundants->size()-1;
long sum;

while (i <= j) {
sum = abundants->at(i) + abundants->at(j);
if (sum == number)
return true;

if (sum < number)
++i;
else if (sum > number)
--j;
}
return false;
}

int main(void) {
std::vector<long>* abundants = new std::vector<long>;
for (long i = 1; i <= 28123; ++i)
if (is_abundant(i)) abundants->push_back(i);

long final_sum = 0;
for (long i = 1; i <= 28123; ++i)
if (!check_if_sum(abundants, i)) final_sum += i;

std::cout << "Sum of all numbers that cannot be written"\
" as the sum of 2 abundant numbers is " << final_sum
<< std::endl;

delete abundants;
return 0;
}

Sum of all numbers that cannot be written as the sum of 2 abundant numbers is 112272625
>>
>>59624066
>I changed Racket with Clojure
Why? Curious since I've been contemplating whether I should learn Racket or Clojure.
>>
>>59624558
I bet y'all who mention C++ but don't mention it first would get fucked with template questions
>>
>>59623850
I used """Rust""" to make a Discord self-bot that displays my currently playing music over on spotify as a game
>>
File: spj.jpg (31KB, 224x223px) Image search: [Google]
spj.jpg
31KB, 224x223px
is uselessness a side effect?
asking for a friend
>>
>>59624059
You're passing the pointer to cmd by value. That is, the 'char* cmd' creates a temporary cmd pointer equal to the pointer you've passed to the function parse.
You want a reference to this pointer. A pointer to pointer will solve this for you.
>>
>>59624616
no.
useless languages have no side effects.
>>
>>59624608
I started checking out Rust the other day to see if it lives to all the de hype. The impression I got was that it tried to look like C but with conscious restrictions "since it's hard to write real C".

Is this a reasonable approximation of Rust, or should I keep looking into it?
>>
>>59624601
you'd be losing that bet then.
>>
>>59624630
>>59624518
Ya, I think it should be parse(&cmd, args, buffer); It's been forever since I've worked in C, Python and C++ have made me weak ;;
>>
[$code]printf ("Hello /dpt/!");[$/code]
>>
>>59624647
Rust is a total joke. It gets memed because it's compiled, but you still need C for low level code.
>>
File: 1478841021326.gif (2MB, 700x388px) Image search: [Google]
1478841021326.gif
2MB, 700x388px
>>59624663
>>59624630
That did the trick.

Fucking baffling. I have three other functions that take in char* arguments and copy strings in without issue.
Thanks either way
>>
tell me what to read to git gud at algorithms
>>
Whos your favorite speaker/programming author, /dpt/?

I could listen to Scott Meyers for days without getting bored.
>>
>>59624755
Simon Peyton Jones
>>
>>59624663
>>59624716
parse(char **cmd, char **args, char *buffer) would work.

There's no problem with copying contents into a memory region pointed to by a temporary pointer as created with parse(char *cmd). The address cmd points to is still the same as the address of the pointer passed to parse.
When you try to malloc and free that pointer is when things get weird. The pointer you've passed to parse(char *cmd) is copied by value, not by reference. Let's say you have char *foo which points to no particular address. You call parse(foo). The temporary inside the scope of parse gets assigned to the pointer that malloc returns but foo is unaware of this and remains pointing at nothing/invalid address.
>>
We now return to our regularly scheduled programming.
>>
>>59624588
In short: Clojure has a better (as in bigger and more mature) ecosystem than Racket. Clojure is able to interact with Java, so you have a pleathora of libraries to choose from.
Also, as a Java developer, Clojure feels like a better choice to me.
>>
>>59624588
>tfw functionally pure hashes/arrays in clojure
>>
>>59624755
Scott Allen
>>
>>59624868
>Clojure is able to interact with Java,
that is not a plus
>>
>>59624913
Dumb anime poster.
(pill already taken, thanks)
>>
>>59624647
That's the point of safety, and safety is the main selling point of Rust.
>>
>>59624965
It is a plus. You get all the Java libraries, but you don't have to write Java yourself.
>>
>>59624647
You definately should. Rust is pretty fascinating with its borrow check system
>>
>>59625193
So if I feel that I normally write perfectly secure C code, there's literally no point in using Rust?
>>
>>59625226
>I normally write perfectly secure C code
you don't though
>>
>>59625226
No, it means you're delusional
>>
>>59625226
>if I feel that I normally write perfectly secure C code,
which does not exist
>>
>>59625226
>perfectly secure C code
Is this real life?
>>
>>59625239
>>59625241
>>59625246
I take that as a collective "yes", then.
>>
>>59625259
Post link to an open-source C software you've written
>>
File: hiddenwhitesupremacistmessages.jpg (292KB, 997x1545px) Image search: [Google]
hiddenwhitesupremacistmessages.jpg
292KB, 997x1545px
>>59625239
>>59625241
>>59625246
>>59625256
autism
>>
File: atashi-2.jpg (201KB, 1920x1080px) Image search: [Google]
atashi-2.jpg
201KB, 1920x1080px
>>59625276
>putting my identity on 4chan
>>
>>59625313
I manage to fail at basic OPSEC all the time!
Come on anon, you can do it too!
>>
>>59625313
i did it once
am still alive
>>
>>59625344
>>59625349
Just for you then, Anon. Don't tell the others.

https://github.com/dolda2000/ashd
>>
>>59625313
>damage control
>>
File: ss (2017-03-28 at 09.53.08).png (1KB, 148x77px) Image search: [Google]
ss (2017-03-28 at 09.53.08).png
1KB, 148x77px
Coulomb's Law

If anyone can suggest an approach to implementing Coulomb's constant (k_e) in python3, I would greatly appreciate it.
>>
I should really implement a multiply instruction(and make a C compiler too).
>>
>>59625375
>https://github.com/dolda2000
>salem-client
LOL shlomo
>>
>>59625409
Python can't handle K?
>>
>>59625409
It's a constant, what's there to implement?
>>
>>59625409
>implementing Coulomb's constant (k_e) in python3
k_e = 8.99e9? Am I missing something?
>>
>>59625409
Implement it as 1/(4*pi*epsilon_0)
>>
is there any speed difference between 64-bit and 80-bit floats on x87?
>>
>>59625538
No SSE with 80 bit floats, which is a performance loss.
>>
>>59625538
There are no 64-bit floats on x87. Everything is 80-bit.
>>
>>59625375
loftar get back to work on hafen.
>>
File: 1488762619029.jpg (37KB, 686x576px) Image search: [Google]
1488762619029.jpg
37KB, 686x576px
>>59625538
What are you working on, so you are interested in x87?
>>
>>59625473
EPSILON = expm1(8.854187817e-12)
COLCNST = 1/(4*pi*EPSILON)


Provides the value I am looking for I believe, thanks
>>
>>59625409
work in units where k = 1
engineers I swear....
>>
>>59624044
This is easy with Rust.
>>
>>59625623
>t. somebody who has never used or compiled anything in rust
>>
>>59625654
Who are you quoting, anon?
>>
File: timer.png (19KB, 891x355px) Image search: [Google]
timer.png
19KB, 891x355px
>>59625577
A timer, nothing special. Just multiplication and division, but it needs to be fast.

>>59625560
gcc won't emit any sse here. I suppose there's no difference between 64 and 80 then?
>>
File: moot.jpg (85KB, 1024x512px) Image search: [Google]
moot.jpg
85KB, 1024x512px
>>59625662
I hate this meme
>>
Why SHOULDNT I use inline for all my functions? Literally what do I have to lose
>>
>>59625874
Employability
>>
>>59625874
I-cache locality, for one thing.
>>
>>59625874
if you wouldn't write a function as a macro, don't inline it.

Inlineable functions generally don't require additional variables, they're just 1 line of arithmetic.
>>
>>59625874
-O3 -flto and let the compiler decide.
>>
>>59623850
I have no idea who was shilling ATS in here, but goddamn is it hot, inconsistent garbage.
>>
>mfw no one here works at Facebook/Google/Amazon/Palantir/Dropbox/eBay/Apple

Are you too shit to play with the big boys?
>>
>>59626145
I own my own business. We write exclusively in Common Lisp.
>>
>>59626145
>wanting to work for Facebook or Amazon
>ever
>>
>>59626145
>no Microsoft

is that no longer trendy
>>
have cpus built in functionality for binary <-> decimal and maybe hexadecimal conversion?
>>
>>59626178
no
>>
File: lol.jpg (366KB, 1127x1600px) Image search: [Google]
lol.jpg
366KB, 1127x1600px
>ywn work at bell labs with the bell lads
>>
>>59626178
>CPU
>2017
Everyone is using GPUs now dumbass
>>
>>59626187
why not? if you have to convert lots of 64bit integers it would be useful

>>59626210
not me I welded 20 ryzen together for extra speed
>>
>>59626203
No, but you can work at Google which is better
>>
>>59626221
>if you have to convert lots of 64bit integers it would be useful
And how would you store their decimal form?
Though, CPUs of the past had BCD and some of them worked with BCD on the hardware side.
Now CPUs are so fast, so you don't need such a thing as BCD.
>>
>>59626165
Is it even possible to be hired at microsoft if you're not indian?
50% of their staff is H1B now.
>>
>>59626279
you will only need decimal when a human is involved. so binary in -> string/ or whatever out (I have no idea how it is encoded. 2 bytes per char?).
>>
>>59626226
it's not
>>
>>59626335
>you will only need decimal when a human is involved
What's the point of conversion then?
>>
>>59626203
>ywn work at RAND Corporation
why live?
>>
>>59626351
At least they're not a government subsidised monopoly?
>>
>>59626408
shouldn't you be koding with karlie?
>>
File: 1481669792807.png (128KB, 500x674px) Image search: [Google]
1481669792807.png
128KB, 500x674px
>>59626203
>you will never work at old xerox and revolutionize computers every work day
>>
File: 1486138298936.jpg (48KB, 250x256px) Image search: [Google]
1486138298936.jpg
48KB, 250x256px
>>59626354
I bet there would be some use case
>>
>>59624113
Try memoization
>>
>>59626427
>ywn work with stallman before passwords sent him down the crusade path of madness
>>
>System Design with Ada
Why are older books so comfy?
>>
>>59626178
x86 has some bcd instructions.
>>
>>59626517
Physical books for programming are the best.
excited for my idris one to get here.
>>
Is moving all my file system operations behind a module overkill? I figure since I do it for database stuff, it would make sense for the file system.

Currently all the file manipulation is mixed in with the business validation.
>>
>>59626592
modules make the most sense.
>>
>>59626592
if you are using the filesystem for data persistence, yeah. imagine that in the future, instead of using the filesystem you switch to use a database. that should be seamless.
>>
I can't fucking program

I'm doing a project euler problem that has to do with factors of factorials, and I'm getting a lot of bad memory access errors.. I've been looking at this for about an hour, but I have no idea what I'm doing wrong:

void makeFactorialMap(int nFactorial, std::set<long>& primes)
{
std::vector<std::vector<long>> factorVec;
std::vector<long> temp(0, 0);
factorVec.push_back(temp); factorVec.push_back(temp); //n = 0, 1 have zero "non-one" factors

temp.push_back(1); // Temp: < 2: 1 >
factorVec.push_back(temp);

for(int i = 3; i <= nFactorial; i++)
{
std::cout << i << std::endl;
/* the factors of n! is equal to factors(n) + factors( (n-1)! ) */
std::vector<long> temp = getFactors(i, primes), prev = factorVec[i-1];

long tempSize = temp.size(), prevSize = prev.size(); //Make them long so that we don't underflow

for(int p = 0; p < tempSize - prevSize; p++)
{
temp.push_back(0); //Make temp and prev the same size
}
for(int p = 0; p < prevSize; p++)
{
temp[p] += prev[p]; //Add the factors of (n-1)! to the factors of n
}

std::cout << prev << temp << std::endl;
factorVec.push_back(temp);

}
std::cout << factorVec << std::endl;
}

help, plox?
>in b4 "C++"
>>
>>59626221
You'll probably find that rather few programs are bottlenecked on the conversion between decimal and binary.
>>
>>59626427
>mouse
>gui
>good ideas
>>
>>59626825
I have no idea what you're doing either.
Post the problem.
You literally don't need any memory allocation to do anything relating to factorials.
>>
Can anyone help me out? I'm pretty new and I'm trying to make a prime number checker in C++. Here it is so far. For some reason it returns correctly for certain numbers like 17 but then when I enter 37 it freezes up and times out. I'm aware that I probably don't need to use functions for the project but I want to learn them better.

https://pastebin.com/zFrmUh7d
>>
>>59626618
I'm actually using both so it would end up looking like this:

addANewThing foo bar = 
let thing = Thing foo bar
result = validate thing

case result of
OK -> do
FileSystem.addThing thing
Database.addThing thing

Bad err ->
Log.append err
>>
>>59626844
A prime number must not be divisible by any number except 1 and itself.
You're just checking 2, 3 and 5.

Even the most wasteful implementation of checkPrime() would require a for loop.
>>
>>59626842
>You literally don't need any memory allocation
Am I doing memory allocation? All I'm doing is pushing back vectors

Anyway, pic related is the product
>>
>>59626844
Not incrementing I, stupid
>>
>>59626874
I don't understand that math jizz, what does the problem want exactly?
>>
>>59626844
>>59626873
>>59626881

Oh I've been screwing with the code a lot but i was incrementing by one before.
>>
>>59626844
>freezes up and times out
You may want to try using a debugger, Anon.
>>
>>59626891
>I don't understand that math jizz
>typical /dpt/ "programmer"
>>
>>59626948
Nah those other guys were right. I must have deleted the i = i + 2 at some point trying to fix something else.
>>
>>59626891
Okay, what I'm doing is as follows:

-Get the factors of a bunch of factorials
-I have a function that retrieves the factors of a number n,
getFactors

-In
 MakeFactorialMap
, I have a two-dimensional grid that contains the number of times each number appears in the prime factorization of a factorial (for example, because both 5 and 10 are divisible by five, the "5" spot on the vector is 2)

I'm pretty sure my method would work, I just have no idea why the vector arithmetic isn't working
>>
>>59626825
>>59626874
Shit dude, feels like you're overcomplicating this. Maybe you've thought of some improvement, but if not you can basically brute force it with
for (int i = 2; i <= n; ++i){
int fact = 1. j = 1;
while (fact % i) {
fact *= fact + 1;
++j;
}
sum += j;
}

Think that's correct.
>>
>>59626874
>>59626825
you're making this shit way too complicated. all you need to solve this is a single for loop

int i = 1;
int result = 1;

while(result < 100000000)
{
++i;
result = result * i;
}

printf("%d", i);
>>
>>59627062
Well, I need to get an absurdly high number of factorials (only made worse by the fact I don't know what the upper bound would be), and I need to be able to re-use the amount of factors a factorial has...

Thanks for the suggestion, though.
>>
>>59627112
Hmm, yea my bad. I see what you're getting it. Interesting problem
>>
File: algorithms.jpg (84KB, 320x373px) Image search: [Google]
algorithms.jpg
84KB, 320x373px
>>59627112
you should read this
>Well, I need to get an absurdly high number of factorials (only made worse by the fact I don't know what the upper bound would be), and I need to be able to re-use the amount of factors a factorial has...
hint: that's a million miles from correct
>>
>>59627158
>reading
ew

But I have noticed that I tend to be on the slower side of the solutions in Project Euler (interpret that as you will)... I'm not that great at the recreational math or designing algorithms, so maybe this is the step in the right direction.
Still, I have no idea why the vector thing doesn't work.

Thanks, though!
>>
>>59627158
A-a-and you could be less smug and just say what do you mean.
>>
>>59627093
>>59626874
re-read the question and i got it, it's still pretty easy. you just do a modulo check. gimme a minute and i'll post the code
>>
File: 1470557147849 (1).gif (31KB, 500x492px) Image search: [Google]
1470557147849 (1).gif
31KB, 500x492px
>new job i'm applying to requires a security clearance
>look at the forms to get one
>requires listing off 3 friends from the past 7 years

There's no hope for getting this job is there.
>>
>>59627237
you're done for
>>
>>59627237
kek
>>
>>59627237
Don't you need the offer to apply for a clearance?
>>
>>59627261
Technically yeah they have to apply for you, but I'm pretty sure i'm fucked no matter what since that's probably a big red flag.
>>
>>59623880
>>59623890
>>59623896
>>59623900
>>59623905
>>59623923
>>59623954
>>59624025
>>59624227
>>59624500
>>59624558

To each and every one of you: are you currently employeed and where? I am trying to get into software engineering as a career and this would be very helpful to me
>>
>>59627237
How much information about them do they need?
just list off three believable names or three local social media accounts.
i doubt youre in anything serious so theyll just run a background check on them and leave it at that.
>>
>>59627320
they do interviews
>>
>>59627320
They use the people to interview about you and the position was for a TS clearance.
>>
>>59626874
Hello,

I think you have to take the prime factorization of the factorials into consideration. For example the prime factorization of 10 is 2*5. Since 5 is the biggest prime factor 5! is the first factorial which is devisible by 10 (because it is the first factorial that has both 2 and 5 as factors in it).

Same with 25. 25 = 5*5, so the smallest factorial which is divisible by 25 has to have two factors of 5 in it. Since 10=2*5 you get one of the 5s from the 10 and the other one from the usual factor 5 in 10! (kinda shitty to explain).

I can't be bothered to write a program for you, but I think with the above considerations you could greatly reduce computation time without having to compute huge factorials.

Hint: Every second factorial adds a factor 2, every fifth factorial adds a factor 5
>>
>>59627320
Don't worry they can tell you don't have any friends in the first interview if you even get called in.
>>
>>59627358
On the other hand, though, bro, prime decomposition is pretty expensive.
>>
>>59627358
That's what I'm doing, though...
Here's the code for the factoring:
std::vector<long> getFactors(long n, std::set<long>& primes)
{
long temp = n;
std::vector<long> divisorCount; //How many times each prime number divides into n

int divisor = 0;
for(long prime : primes)
{
divisorCount.push_back(0);
while(temp % prime == 0)
{
divisorCount[divisor]++;
temp /= prime;
}
if(temp == 1) break;
divisor++;
}
return divisorCount;
}
>>
>>59627379
But you only have to do prime decomposition of 10^8 which is pretty easy
>>
>>59627371
It seems you have experience with this anon. Tell us!
>>
>>59627297
Why would it be helpful? You can get a job with any popular language
>>
>>59627333
>>59627335
What if said friends are busy or just dont respond?

Do you lose the opportunity at that?
>>59627371
dont even try to hide my autism /anti-socialness. Nor wousd i ever apply for big corps
>>
>>59627387
Of every number up to and including 10e8
>>
>>59627393
Major red flag, they'll probly track you for being some kinda terrorist.
>>
>>59627398
You need the first factorial which has the factors 2^8*5^8. If you read my hint again it should be pretty easy to figure out
>>
>>59627408
Beyond a phone interview it just seems like a huge inconvenience. And kind of useless because no friend would do anything but feed the same bullshit you usually do for interviews.
>>
>>59627420
reread the task. You need to calculate big S not small s.
>>
>>59627420
I think you need to read the question again
>>
>>59627393
If they can't get a good picture of you as a person they will simply deny you the clearance.
>>
>>59623850
How does hybrid approach work? I see projects are written in a mixture of different languages. How do they connect to each other?

For example if I want to make a torrent client how can I take the hybrid approach? For example, I want Vala to handle GUI and user inputs while the C/C++/D/python etc does separate jobs in the backend.

How does it work?
>>
>>59627446
I get that, but a character assessment from strangers just again, seems useless.
id imagine giant corps like that have more efficient means.
>>
>>59627420
>>59627440
>>59627442
>>59627398
>>59627384
>>59627358


I took a simpler approach... It seems to be taking a while, but it got me the correct answer for S(100)
int main()
{

std::vector<mpz_class> factVec;
for(int i = 2; i <= 100; i++)
{
mpz_class result;
getFactorial(i, result);
factVec.push_back(result);
}


long MAX = pow(10, 8);
std::set<long> primes;
sieve(MAX, primes);
std::cout << "Done with Primes!" << std::endl;
long sum = 0;
int l = pow(10, 7);
for(long i = 2; i <= MAX; i++)
{
if(i % l == 0) std::cout << i << std::endl;
if(primes.count(i))
{
sum += i;
continue;
}
else
{
for(int numInd = 0; numInd < factVec.size(); numInd++)
{
if(factVec[numInd] % i == 0)
{
sum += (numInd+2);
break;}
}
}
}
std::cout << sum;
return 0;
}
>>
>>59627237
Can you use family members? Or maybe a teacher or whatever.
>>
>>59627439
It is a huge inconvenience for the government doing their interviews shit but it's one of those red tape processes that just happens. The red flag would be lying about it, I dunno what they'll do for friendless people. They WILL hunt down (some portion of) whoever you list no matter where they are. It's kind of creepy.
>>
>>59627483
Could you take the direct approach as well and compare the times?
>>
>>59627503
I'm doing the direct approach rn, it's doing it at a rate of about 10^5 numbers per second (which means I'll finish in about 10^3 seconds, or about 20 minutes (assuming constant time for n)
>>
>>59627483
Just looking at this quickly it looks like you only calculate the primes for 10e8. Now, the primes for 100 is a subset of those, which is probably why you got the correct answer. But I'm sure this won't for work other numbers.
>>
>>59627478
Well I'm assuming this is for government clearances so it's not the actual corporation doing it.

>>59627486
No and Yes. Basically has to be non-relatives that know about you, what you do, etc outside of work.

>>59627491
I would imagine they'll deny you or try to catch you in a follow up interview or polygraph interview, but they will also contact people you didn't list (ex co-workers, neighbors, etc) especially if it's a high ranking clearance.
>>
Who else /not give a shit about gender and just want competent coworkers/?
>>
>>59627556
Why did you bring that up?
>>
>>59627556
just you
>>
>>59627556
literally everyone else but the people bitching.

When you have to nearly force people into a field, then theres a problem.
>>
>>59627584
All the fuss recently about discrimination and whether meritocracy is problematic.
>>
>>59627555
Can you list the person conducting the interview?
>>
>>59627551
But why wouldn't it work for larger numbers? I calculate a large number of factorials, and if a number is prime, then the first "m" for the "n" would be that prime number.
>>
>>59627603
"recently"
>>
>>59627603
thats why tech needs to move out of commiefornia.
Nothing but a cesspool.
>>
>>59627613
what?
>>
LALR(1) parser using lex/yacc.

It dumb.
>>
>>59627466
Bump
>>
>>59627627
thing about cali is they have contract rules where companies can't own your private inventions and things, which is why startups are viable there. You can spin off into your own company from working in your off time.

Unlike the ancient HP/Bell type contracts where ANYTHING you do while working there belongs to them.
>>
How should rings work in a CPU architecture?
Sidenote:
Should I make my ISA 64bit?
>>
>>59627634
It's the most conversation I've had with a real person in 7 years.
>>
File: 1464822448795.gif (662KB, 800x528px) Image search: [Google]
1464822448795.gif
662KB, 800x528px
C++ prof gave me the cash register program to do for class,

have it down to inputting the amount and breaking the change down to be distributed down to the dollar, but don't know how to make it break down the cents, any idea?
>>
>>59627645
This, the US desperately needs more states with laws like Cali's when it comes to employee IP and non-competes.
>>
File: Screenshot_2017-03-28_19-22-53.png (18KB, 448x288px) Image search: [Google]
Screenshot_2017-03-28_19-22-53.png
18KB, 448x288px
>>59627647
forgot picture
>>
>>59627615
Well, I haven't read your code thouroughly, but how does knowing the primes of 10e8 help you solving the problem for odd values of m for example.
>>
File: elk.jpg (158KB, 720x960px) Image search: [Google]
elk.jpg
158KB, 720x960px
>>59627653
damn
>>
>>59627666
How can a company own things you produce off company time?
Unless I'm being paid 24/7, that shouldn't be.
>>
>>59627653
Use anonymous on 4chan as a reference, guaranteed security clearance.
>>
>>59627657
you do calculations in cents instead of dollars

alternatively you could make a money class with dollar and cent attribute, but that might be too complicated for your purpose
>>
>>59627645
Cant individual companies specify that in their contracts/hiring agreement anywhere?
Or does some shiity federal/state thing supersede all except cali?

Or is it just because its a blanket thing there so no one bothers elsewhere?

t. manchild
>>
>>59627692
It's in a lot of peoples' contracts. It's shitty, but it happens. A lot.
>>
>>59627692
That's legal in contracts, like an NDA or something.

>>59627711
Anyone could specify that anywhere, I don't know if they do. Cali's the only example of that I know of personally.
>>
>>59627683
Most primes are odd numbers, so that's why I calculate primes up to 10^8

...Okay I sort of know where you're coming from. It won't give me the right answer because I only calculate up to 100!, so I don't know s(n) for multiples of primes larger than n
>>
>>59627711
My understanding is that many companies put clauses in their employees' contracts for non-compete periods, IP ownership, etc. and in most states they're enforceable. Cali, however, has laws that state such clauses are not enforceable. IANAL though.
>>
>>59627732
Oh, shit, nvm. I forgot what sieve is about. Thought it calculated the primes for n not up to n.
>>
File: 1475329530390.jpg (36KB, 368x259px) Image search: [Google]
1475329530390.jpg
36KB, 368x259px
>>59627732
>Most primes are odd numbers
Yeah, like, 99.99999999999999999999999999% of them.
>>
>>59627721
>>59627744
alrighty, thanks for the info lads
>>
>>59627757
lel
>>
>>59624608
>"""Rust"""
Why did you use many quotations?
>>
>>59627483
There is no trick to this one right? I thought that there might be some memoizing trick, but I don't think there is.
def S(n):
facts = {5:120, 4:24, 3:6, 2:2, 1:1}
sumF = 0
for i in range(2, n + 1):
print i
sumF += s(i, facts)
return sumF

def s(i, facts):
j = 1
while(True):
if j not in facts:
facts[j] = j * facts[j - 1]
if facts[j] % i == 0:
return j
j += 1
>>
File: Funny Shrug.png (18KB, 500x500px) Image search: [Google]
Funny Shrug.png
18KB, 500x500px
>>59627757
ya got me
>>
second year cs here
what job to look for in the summer?
i just want to learn mostly not looking for money. would anyone even accept me without a degree?
I know a little bit of c++ c# java and web programming with php
>>
>>59627297
I am currently employed.

I work for a small company, so telling you where would basically dox me.

I use C# every day to do various things. One of the bigger pieces of software I'm working on basically digs through a database and automatically generates the pipelines to move data from most popular DBMS's into Azure and system-version it so we can see the data change over time and report on it.
>>
>>59626970
Yes, but if you could use a debugger, you wouldn't even have had to come here to ask about that.
>>
>>59627799
>what job to look for in the summer?
You don't. Learn Android App development
>>
>>59627799
internships m8
sure it cant be too hard to find a spot
>>
>>59627799
get a summer internship.
>>
File: 1456271270443.gif (91KB, 634x400px) Image search: [Google]
1456271270443.gif
91KB, 634x400px
What is an ABI?
What is SVN?
What is version control system?
What is Travis CI?
>>
>>59627842
What is a search engine?
>>
>>59627842
ABI - Application Binary Interface
SVN - Subversion(a VCS)
VCS - A program that essentially allows you to keep histories of work, in which you can revert backwards if needed.
Travis Cl - A web service that automatically builds software to test if it passes.
>>
File: 1487274497061.jpg (3KB, 104x125px) Image search: [Google]
1487274497061.jpg
3KB, 104x125px
>Anon, your screenshots are too dark
Someone please explain, how Win95 grey is dark?
>>
>>59627919
Did you post your screenshots in 3.4K 104x125 JPGs? It might just look darker than it actually is.
>>
>>59627919
pic?
>>
>>59627919
>unironically still saving thumbnails
>>
>expecting to be able to program while being monolingual
>>
File: o.jpg (142KB, 1024x576px) Image search: [Google]
o.jpg
142KB, 1024x576px
>>59628002
>>
Where do people look for tech jobs?
I really have no clue, and craigslist in my area looks like a shithole.
>>
>>59628035
>craigslist
>>
File: d lang.png (909KB, 1280x720px) Image search: [Google]
d lang.png
909KB, 1280x720px
>>59628025
>>
>>59628025
>D
>the productivity of C++ and the performance of Python
Sounds about right.
>>
>>59628025
it's slower than C/C++ and it's harder to find a D programmer than it is to find a Python programmer
D is shit
>>
>>59627966
The thread was deleted when I found the pic, so I could only retrieve thumbnail.

>>59627953
I chuckled.
No, the reason is prof uses Win10, and I use Win2000 for his old-ass software.
Hell, screenshots will look darker.
I just don't understand how is THAT can make anyone care about it.
>>
>>59628060
You misread
>>59628064
Wrong
>>
>>59628064
>it's slower than C/C++
What projects are you working on?
>>
>>59628079
I read the truth, not the propaganda.
>>
>>59628025
Too bad they mixed it up and got the performance of Python and productivity of C++ instead
>>
>>59628064
>it's slower than C/C++
Thats funny considering many D STD's have been proven faster than C++'s and I think even some C ones as well.
>>
>>59628090
>>59628025
D cannot have performance as good as C++, because it has a garbage collector.

Scrap the GC and then we'll talk. Until then D is a less popular Java or C#.
>>
>>59628094
Any actual evidence for that claim of yours?
>>
>>59628092
Yeah, sure
>>59628094
No they didn't. D is pretty fast
>>
>>59628103
>because it has a garbage collector.
GCs are not a bad thing in most of the cases
>>
>>59628107
D = GC
C++ = no GC

>>59628116
Sure, languages like D and Java are pretty fast these days, but they still can't compete with C/C++/Rust
>>
>>59628103
That's not true though, what you do get is an inherent overhead not necessarily a measurable performance decrease.
>>
>>59628126
see >>59628125
Also, you can avoid GC and write inline ASM if you like performance that much
>>
>>59628128
>>59628125
Of course no GC can stop programmers from writing in logical memory leaks, which is why it's probly better to handle it from a design standpoint than relying on GC.
>>
>>59628126
C++ = Counter Productive
>>
>>59628126
@nogc exists for much of the std.
D also has many deterministic memory features like arrays
>>
>>59623850
is there any easy way to make lists on C?
>>
>>59628077
Isn't that one of the sluts from NNB? Could of just opened a random episode and taken a screenshot.
>>
>>59628166
C doesn't have lists
>>
>>59628134
Nice strawman.

>>59628128
>an inherent overhead not necessarily a measurable performance decrease
The first part contradicts the second.

>>59628154
Doesn't matter unless the entire language is no-GC. You can't claim to have performance as good as C++ if you have a GC.
>>
New thread:

>>59628171
>>59628171
>>59628171
>>
>>59628181
That's not what he was asking.

>>59628166
Yes.
>>
>>59628173
I don't watch anime, I just collect funny anime pics.
>>
>>59628188
Not at all, you're guaranteed to get larger binaries but not necessarily slower binaries. Completely different concepts.
>>
>>59628166
struct node {
struct node *next;
void *obj;
};


There you go, a basic linked list
>>
>>59628210
I get that GC doesn't cause you performance problems, but it does cause me performance problems. Please try to understand that.
>>
>>59628215
that part is easy, but how to add and remove nodes?
>>
>>59628205
Interesting hobby.
>>
>>59628235
It's just severe lack of time.
>>
File: QNrPj.png (163KB, 1151x688px) Image search: [Google]
QNrPj.png
163KB, 1151x688px
a web scraper but I'm currently failing... need help.

on airbnb.com when you look at a property listing, you can click the check-in box which brings up a date-picker. It shows which dates are available and if you hover over a date it shows you the price for that night. I'm looking to scrape this calendar data: so for each date of the month, is it available and what is the price?

However, the date picker and its data are loaded dynamically and I cannot seem to find it in the source using firebug. When the date-picker is displayed clicking on firebug's highlight-inspector makes the date-picker disappear.

Attached screenshot shows the date picker with the unimportant stuff blurred out. In firebug you can see the input element which toggles the date-picker to be displayed. where/how can I grab the html data in this date-picker so I can start writing a script with selenium?

help me please anons...
>>
>>59628225
I'm not saying GC *WONT* cause performance problems just not that they are inherent in the design. You've got like a constant additional time at best, which isn't necessarily slower overall.
>>
>>59628230
You make a doubly linked list.
>>
>>59628257
True C experience
>>
>>59628252
Programs that exhibit the best case of GC behavior are a very small subset that does not include most programs that I or anyone else (except maybe D fans) wants to write.
>>
>>59628230
struct node {
struct node *next;
void *obj;
};

void add(struct node *head, void *nobj)
{
while(head->next) {
head = head->next;
}
head->next = malloc(sizeof(struct node));
head->next->obj = nobj;
head->next->next = NULL;
}


simple add at end for singly linked list, i'll leave remove as an exercise for the reader.
>>
>>59628274
It wouldn't be too big of a leap for C++ or Rust to have a decent GC based on their pointer abstractions but you're right nobody WANTS that. Except D people I guess.
>>
Do I need to learn C before C++
>>
>>59628297
Yes, it's an upgrade. You need to pass year X before going to year X+1
>>
>>59628297
You should learn C, and then not learn C++.
>>
>>59628268
How would you remove a node(that isn't the head) from a singly linked list without iterating through it?

This has nothing to do with C.
>>
>>59628297
I would advise against it, if you're starting with C++11 or higher. There's some really bad habits you can pick up that do not work well with a lot of C++ concepts. Of course you can write C++ code exactly like C code, it's just.... wasteful of your time?
>>
>>59625226
No, there's plenty of other redeeming attributes.

In the case of accomplishing the same level of safety though it's needless roundabout and time consuming.
>>
>>59628280
actually, i don't understand why there are 2 pointers inside the struct node
one pointing the next node isn't enough?
>>
>>59628297
No actually, it's a common FUD. C is pretty obsolete and if you follow Bjarne's book carefully he doesn't require you to learn C at all
>>
>>59628329
C is far from obsolete. C++ is more obsolete than C.
>>
>>59628297
same shit
the only difference is the hashtag include and theres no printf and scanf
>>
>>59628320
Thing is if you're writing safe secure C code you're going to be going through those boilerplate motions anyway. Inherent checks > explicit checks imo.
>>
File: 02f.jpg (34KB, 655x527px) Image search: [Google]
02f.jpg
34KB, 655x527px
>>59628311
>>59628317
Why is C++ even bad?

I've heard the general inclinations, but what are some actual examples of bad designs?
>>
>>59628325
One points to the next node.
One points to the data stored at the node.

That data could be as simply as a reference to an int or another struct or an array, etc
>>
>>59628337
C++ has confined C to very niche programming while C++ is used more as a general purpose language, IDK what you are talking about
>>
>>59628347
C++ has no paradigm, it has all paradigms. The design possibilities and lack of focus make it great for GIGANTIC projects that both need low level machine-tier code and high level abstractions but that's rarer than most people think. It also has a LOT of syntax. So much fucking syntax to cover and if people are doing things in a bad way things can get very out of control.

I've always known some C++, mostly on /g/ people hate it cause they get confused by more symbols on the screen then babby duck defend retarded pointer reference pointer reference shit in C.
>>
>>59628359
ok, thanks!
i'll study your code
>>
>>59628370
In a year, Rust will be more popular than C++ for new projects. C will continue to maintain its niche.

The only thing C++ has going for it is inertia. C at least has portability.
>>
>>59628388
Well I am fascinated with Rust. Maybe I'll wait till Rust v2 comes out and they set a proper standards of doing things
>>
>>59628388
That may be true but it raelly depends on how C++ manages to bring in updates to new releases. They went 30 years without a serious standard but they're really on the ball now. Who knows when C++ might implement borrow checking and stuff? They've implemented every other feature ever made.
>>
>>59628344
I'm not sure what you're saying but my point was that if you're accomplishing the same safety as Rust in C then it's just effort gone to waste

Just because it's more complicated doesn't mean it's more complicated for a purpose. You shouldn't have the ability to create situations that you would literally never want.
>>
>>59628386
It only works because C lets you abuse void * as basically a pointer to anything. You just need to cast from it to access whatever you stored there.

You could also just make a linked list that stores one specific type, ie:
struct node {
struct node *next;
int item;
};
>>
>>59628397
>. Maybe I'll wait till Rust v2
Its easier to learn changes than a whole new language.
If youre interested, start now.
>>
>>59628403
I'm saying that Rust does things automatically through design what it takes a million explicit checks to accomplish (and this is the way you're supposed to do it) in C/C++. Less boilerplate at the cost of a slight mindfuck.
>>
>>59628407
How amusing that C does polymorphism better than Go.
>>
I made thsi fun game in C++ where you input a string and you get a jumbled version back that may not even contain all the letters haha LOL

However I don't know how to code so I come to you to ask how can this be improved?
#include <iostream>

int main() {
std::string str;
std::cin >> str;

int len = str.length();

for (int i; i < len; i++) {
int index = std::rand() % len;
std::cout << str[index];
}

return 0;
};
>>
>>59628412
>>59628397
Rust is super immature now, not even people who write in rust use Rust. They all 100% of them use rust nightly.
>>
>>59628440
I like lolis anyway
>>
>>59628456
Right, and rust nightly is probly the coolest lang for personal hobby projects. I will almost certainly not regret learning it but completely impossible for production for a while.
>>
>>59628384
While you're here could you explain to me what the deal is with >>

It's just so fucking weird and in it's own world. Why is this what they chose for calling input and output? Calling? I'm not even sure what to call what it's doing because the syntax is so weird
>>
>>59628481
C++ iostreams are completely retarded.
Don't try to find any logic there. There isn't any.
>>
>>59628481
That is a stream. It's sort of similar to a unix pipe in practice. cout << outputsIntoCout() << dumpsIntoCout2()

>>59628513
I wouldn't say they're retarded they're just incredibly obtuse. Actually learning what's going on under the hood is practically impossible. It's not a very good start.
>>
>>59628533
>>59628533
No. They're actually retarded.
As already discussed, the syntax is awful.
It introduces a shitload of state which really shouldn't be there.
It hard-codes the order of the arguments (Bad for internationalisation).
It's MUCH slower than C's stdio.
>>
>>59628574
It is functionally different from C's stdio though, too. It has the whole stream/buffer stuff inside it which.... is just so much trouble to introspect it's probly not worth it anyway in a lot of cases.

I'm not saying it's good it's just not C's way or the highway. Doesnt C++STL come with a C-style STDIO alternative too?
>>
Is this how u check for a palindrome in C++? I'm trying to learn C++ but I bet I'm doing it wrong

#include <iostream>

bool check_palindrome(std::string str) {
int len = str.length();

for (int i = 0; i < len/2; i++) {
if (str[i] != str[len-i-1]) {
return false;
};
};
return true;
}

int main() {
std::string str;
std::cin >> str;

std::string result = (check_palindrome(str)) ? "Yes!" : "No!";
std::cout << result;

return 0;
};
>>
>>59628701
module find_palindromes;

import std.stdio;
import deduplicate_string_array;
import sort_by_descending_length;

string[] find_palindromes(in string str)
{
string[] found_palindromes = [];
for (int i = 0; i < str.length; i++)
{
if ((i + 1 < str.length) && str[i] == str[i + 1])
{
string current_palindrome = "" ~ str[i + 1];
int k = 1;
while ((i - k >= 0) && (i + 1 + k < str.length) && str[i - k] == str[i + 1 + k])
{
current_palindrome ~= "" ~ str[i + 1 + k];
k++;
}
found_palindromes ~= current_palindrome;
}
}
deduplicate_string_array(found_palindromes);
sort_by_descending_length(found_palindromes);
return found_palindromes;
}
//..
>>
>>59628761
that doesn't look like cpp
>>
>>59628771
>cpp
The C Preprocessor lacks to facilities to write a palindrome checker.
>>
>>59628761
>still no foreach or parallelism
why do you hate good things
>>
>>59628792
Wouldn't that cause data race?
>>
>toupper is a global function in C++

How does this work? String is in std:: but toupper is just hanging around in the global namespace?
>>
>>59628848
toupper is a C function. C does not have memespaces for functions.
>>
>>59628833
with @safe @trusted, no
>>
>>59628866
||
>>
When do I use
 int array[10]
and when do I use
vector<int> vector
???? i get it the first one is a contiguous block allocated at declaration coming straight from C, and the second one is some sort of complicated template with lots of functionality, but like practically how do I decide
>>
>>59629088
That is a lot of explaining on algorithms. If you don't need to shift elements or resize your array, it's probly going to be better...?
>>
>>59629113
just found out I gotta consider
std::array
too
>>
how do you guys study 2 languages at the same time?
i'm learning both C and Java, and my mind sometimes mix stuff up
>>
>>59629146
>implying i need to know any other language if i know Python
>>
>>59629146
One is imperative and the other functional.
I think on both sides and the syntax is mostly seperated as well.
Abanden those shit-tier ones though
>>
>>59629180
lol java is functional now? is it cause you chain your shitty methods?
>>
>>59629196
No i meant for myself.
>>
>>59629088
first when you are making a program where you need to manage memory, second is general-purpose basically
>>
>>59628701
>u
No, you begin with suicide.
Thread posts: 382
Thread images: 39


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