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

/dpt/ - Daily Programming Thread

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

Thread replies: 320
Thread images: 28

File: 1485438720022.png (423KB, 720x720px) Image search: [Google]
1485438720022.png
423KB, 720x720px
Old thread: >>59430383

What are you working on, /g/?
>>
>>59438680
>They store offsets from the stack pointer
Ah, cool, that's the part I was missing.
>>
any neural net autists ITT?
how do i normalize many independent sequences? theyre all in a different range, and ranges may overlap between two sequences
should i normalize the data as if it were one sequence or each sequence independently?
>>
A D fag posted a problem about finding common substrings between two.

Here is my solution in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int *lcommon(char *s, char *t) {
int strlen1 = strlen(s);
int strlen2 = strlen(t);
int len = (strlen1 < strlen2) ? strlen2 : strlen1;
int i, j, k;
int longest = 0;
int **ptr = (int **)malloc(2 * sizeof(int *));
static int *ret;
ret = (int *)malloc((len + 3) * sizeof(int));
for (i = 0; i < 2; i++)
ptr[i] = (int *)calloc(strlen2, sizeof(int));

ret[1] = -1;
for (i = 0; i < strlen1; i++) {
memcpy(ptr[0], ptr[1], strlen2 * sizeof(int));
for (j = 0; j < strlen2; j++) {
if (s[i] == t[j]) {
if (i == 0 || j == 0) {
ptr[1][j] = 1;
} else {
ptr[1][j] = ptr[0][j-1] + 1;
}
if (ptr[1][j] > longest) {
longest = ptr[1][j];
k = 1;
}
if (ptr[1][j] == longest) {
ret[k++] = i;
ret[k] = -1;
}
} else {
ptr[1][j] = 0;
}
}
}
for (i = 0; i < 2; i++)
free(ptr[i]);
free(ptr);
/* store the maximum length in ret[0] */
ret[0] = longest;
return ret;
}

int main(int argc, char *argv[]) {
int i, longest, *ret;

if (argc != 3) {
printf("usage: longest-common-substring string1 string2\n");
exit(1);
}

ret = lcommon(argv[1], argv[2]);
if ((longest = ret[0]) == 0) {
printf("There is no common substring\n");
exit(2);
}

i = 0;
while (ret[++i] != -1) {
printf("%.*s\n", longest, &argv[1][ret[i]-longest+1]);
}
free(ret);

exit(0);
}
>>
reimplementing Redox in Haskell
>>
>>59438836
Same, no I/O though.
>>
Is there something like Write you a Haskell but finished?
>>
Why do so few languages support bit arrays as part of their standard library?

I know that's implementation side but my ideal language (...implementation) would store and process arrays of booleans as bit arrays by default.

t. man with trillions of booleans to process all time who hates to run out of memory
>>
Languages every programmer should study:

>C
>C++
>Rust
>Lisp/Scheme
>Prolog
>Haskell
>Idris
>>
>>59438906
http://www.cplusplus.com/reference/bitset/bitset/
>>
>>59438935
>C++
Everything you said except this.
>>
>>59438832
Wow, that is some awful code.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

const char *lcs(const char *a, const char *b, size_t *out_len)
{
// +1 for the empty string column/row
size_t a_len = strlen(a) + 1, b_len = strlen(b) + 1;
size_t (*sol)[b_len] = calloc(a_len, sizeof *sol);

if (!sol)
exit(1);

// Coordinates to the best known solution
size_t max_x = 0, max_y = 0;

for (size_t i = 1; i < a_len; ++i) {
for (size_t j = 1; j < b_len; ++j) {
if (a[i - 1] == b[j - 1]) {
size_t len = sol[i - 1][j - 1] + 1;
sol[i][j] = len;

if (len > sol[max_x][max_y]) {
max_x = i;
max_y = j;
}
}
}
}

*out_len = sol[max_x][max_y];
const char *ret = a + max_x - sol[max_x][max_y];

free(sol);
return ret;
}

int main()
{
size_t len;
const char *s = lcs("123", "abc", &len);

printf("%.*s\n", (int)len, s);
}
>>
>>59438948
C++ is THE example language to learn from though.
>>
>>59438970
>>59438832
Really?
import std.stdio;
void main(string[] args){

string str1 = args[1];
string str2 = args[2];

string[ulong] largest;

for (int i = 0; i < str1.length; i++){
for (int j = 0; j < str2.length; j++){
if (str2[j] == str1[i]){
string current = ""~str1[i];
ulong current_largest_length = current.length;
for (int a = 1; (a+i < str1.length && a+j < str2.length); a++){
if(str2[a+j] == str1[a+i]){
current ~= str1[a+i];
}
}
largest[current.length] = current;
}
}
}
auto largest_key = largest.keys[0];
foreach(i; largest.keys){
if (i > largest_key){
largest_key = i;
}
}
writeln(largest[largest_key]); //I even got strings of different length
}

> ldc2  main.d ;and ./main  cadfdce nadfica
adfc
>>
>>59439059
Bjarne, hvorfor skapte du et så forferdelig programmeringsspråk?
>>
>>59439102
Bjarne isnt responsible for C++ getting out of control.
>>
>>59439102
kurwa :DDD
>>
>>59438798
z-score
>>
>>59439091
>adfc
That's the longest common subsequence, not the longest common substring.
They are different algorithms.
>>
My program needs an API which is used with an HTML <script> tag, which uses a URL as a source and runs a callback function.

But I've come across a scenario where I need that callback function to use the API for itself, and although possible to do it by having the callback function create script tags, it's messy and difficult.

Is there a neater way?
>>
File: 1206262549778.jpg (485KB, 900x695px) Image search: [Google]
1206262549778.jpg
485KB, 900x695px
Ruby beginner question here. Is it better to use the .push method in ruby to combine arrays if they get to be very large? Are a few smaller arrays better than one big one for run time?
>>
File: 1-100.png (3KB, 31x603px) Image search: [Google]
1-100.png
3KB, 31x603px
Something has gone very wrong here.
Posted about this yesterday
>program calls a console program, takes its output and places that output in a textbox
>program I'm using for testing is really simple, for(i<100;i++) write i to console
>even I couldn't fuck that up
>add the data to a concurrentqueue
>every update I pull the count and place it in an array then write the array
>this is the data being written, it seems to come in fine though
fug
>>
where can i get an xml file or whatever of current stock market?
>>
>>59439397
use JSON with one of the websites you find on google
>>
>>59439437
You're saying how to parse the XML file, not how to get it.
Well, you did say how to get it, but the day "just Google it" becomes an acceptable answer for anything is the day Bernie Sanders becomes president.
>>
>>59439397
for real time data you have to pay someone to get it. or your bank or w/e might provide it for free for certain markets but they probably don't allow you to scrape it with automated tools
>>
>>59439437

if i do this daily, do you think they will block me? also im pretty sure its against tos or something to atuomate this
>>
how do i make this work in c#

        public bool Regist(Client a, Date date, int i, int d)
{
Call c = new Call([here should be object im interacting with], a, i, d);

}


the call constructor takes 2 clients, but how do i get the caller client without making it an argument of the function?

i found MemberwiseClone() but it doesnt save changes on the original object. maybe this doesnt even make sense idk
>>
What's a good project for when I'm drunk
>>
>>59439685
Lisp interpreter
>>
File: fullspeed lighting sims.png (549KB, 1154x605px) Image search: [Google]
fullspeed lighting sims.png
549KB, 1154x605px
>>59438778
Unity
It's using Cg.
>>
>>59439706
gpu register spilling maybe
>>
>>59439382

1. The push method does not combine arrays, it appends an element at the end of one. If you call push with an array argument, it'll end up looking like this:
irb(main):001:0> a = [1,2]
=> [1, 2]
irb(main):002:0> a.push [3]
=> [1, 2, [3]]


The method you are looking for is concat, which would instead produce the value of [1,2,3]

2. Regarding runtime performance, if I remember correctly, Ruby's arrays are implemented like vectors. They have a length and a capacity, and the capacity doubles every time one tries to append elements beyond said capacity. A larger array should be able to push back more elements without requiring memory re-allocation, but it may also require more memory. It's been a while since I've looked at the Ruby source code though, so things might be a bit different...

You probably shouldn't be as concerned about performance for this, however. Keep different variables for different things. The point of Ruby is not necessarily to be a fast language, but to be a language you can enjoy. Putting all of your variables in one giant array does not make for well-maintainable code.
>>
File: 1482870681809.png (2MB, 1254x1771px) Image search: [Google]
1482870681809.png
2MB, 1254x1771px
>>59439696
cool
>>
>>59439755
Ruby: why Ruby?
>>
>>59439684
help
>>
>>59439800
this is not irc
>>
>>59439755

Thanks for the information. I'm still learning and this is all very interesting and helpful to me. I will definitely keep the concat method in mind.

>>59439800
I know a guy who has been using it awhile, which helps because usually I can ask him questions and he doesn't mind helping me with it. The alternative would be trying to learn Java or C and having no one I know to help me. Also, it's my intention to transition into Rails someday if I can get Ruby down well enough.
>>
>>59439835
No idea what you're trying to accomplish.
>>
File: breathing_mask_wojak.jpg (23KB, 480x480px) Image search: [Google]
breathing_mask_wojak.jpg
23KB, 480x480px
>tfw have computer science degree from a reputable university
>tfw can't find a job
>tfw fell for the computer science meme
>>
>>59439800

It's the most comfy scripting language out there. Really great for string and array processing
>>
>>59439932
What about Scheme?
>>
What's this about strtok not being thread safe?
>>
>>59439958
strtok has static internal which means you get different results on each call.
>>
>>59439929
there's a huge shortage of competent programmers, all you need is to know programming and not be an overly autistic freak
>>
File: 6565 (2).jpg (34KB, 410x410px) Image search: [Google]
6565 (2).jpg
34KB, 410x410px
>>59439929

This is probably just someone being a comedian but out of curiosity is it because you wont accept below a certain pay for a job? Like do you feel you wont earn enough or your skills are too high for what they want to pay? Because as someone without a degree and looking from the outside in there seems to be tons and tons of programming jobs available all over the damn place but they just don't pay well enough to fill the positions, resulting in the demand for programmers being high.

I'm not implying you are like ungrateful, I know that you have to make x amount of dollars just to get by and you can't work for peanuts and just hope for advancement or making a connection, but what's the deal? Are they literally not calling you back or getting back to you?
>>
>>59439958
strtok_s
>>
>>59439941

Scheme can be alright, although I'm not as familiar with the standard library. Also, it doesn't really have great syntax for function composition. By comparison, since most things in Ruby are done with methods, rather than naked functions (which are really just methods on the main object), I can compose functions by means of chaining methods. I also can take advantage of the fact that parentheses are optional for regular functions. If I wanted to call f(g(x)), it's really just f g x.
>>
File: blanket_feels.png (696KB, 633x758px) Image search: [Google]
blanket_feels.png
696KB, 633x758px
>>59439979
>>59440005
I dunno. I applied for so many jobs and I only got one interview and the pajeet asked me if I could reverse a string in bash (which I couldn't do). I failed the interview.
>>
>>59440031
>f g x
>not f (g x)

literally retarded
>>
>>59440070

Both are valid in Ruby. Similarly, a b c d e is equivalent to a(b(c(d(e)))), or scheme's (a (b (c (d e)))), or F#'s a <| b <| c <| d<| e. I nonetheless find that e.d.c.b.a is much cleaner than all of it.
>>
>>59440070
>not forg(x)
>>
>>59438935
>Rust
Everything you said except this.
>>
File: 56yy5.png (520KB, 640x480px) Image search: [Google]
56yy5.png
520KB, 640x480px
>>59440052

Well I'm sorry sir and or madam. I wish you luck when you snag another interview which I'm sure you will. You might even find a place that cares more about interest and drive over per-existing skills, but that's kind of rare. Try to keep your chin up friend.
>>
>>59440090
>Both are valid in Ruby
THEY'RE COMPLETELY DIFFERENT
>>
>>59440109
Thank you anon. Where do you live where there is a shortage of programmers?
>>
File: 17362047.jpg (78KB, 960x960px) Image search: [Google]
17362047.jpg
78KB, 960x960px
>>59440102
Rust is pretty nice
>>
>>59440094
>not fag(x)
>>
>>59440132
>last pic

lol nope, nice try.
>>
>>59440132
Where did you find these
>>
>>59440139
That's the closest to 2D you'll get
>>
>>59440155
nice gap vs full rub was what i was commenting on.

first two are damn close, last is not.
>>
>>59440155
i thought projections were the closest you get to 2d
>>
File: 1464695973506.png (809KB, 883x673px) Image search: [Google]
1464695973506.png
809KB, 883x673px
>>59440130

Not where I live. I live in Appalachia and looking to leave because this place is dying fast.

I would suggest any place like a big city that has lots of companies and individuals looking for programming skills. Also, where there are lots of people there is more of a chance to find startups or things that could use you, or be in the same boat and willing to work with you on a project.

Basically, I think the ideal way to go would be move to just outside a city where it will be much cheaper, but close enough you can commute to work or find an apartment if you do land a job or find some work to do.

However, I would think programming you could do from home in many instances. Also, have you tried freelancing or helping with open source projects to make some friend/connections?
>>
what do you think about java /g/?
>>
>>59439979
>all you need is to know programming and not be an overly autistic freak
Theres a difference?
>>
>>59440176
Fuck off, you hillbilly freak!
>>
>>59440132
>You'll never get a dragon mommy gf
why even live?
>>
>>59440132
>>59440146
>>59440146
WHERE DID YOU FIND THESE?
>>59440183
shit
>>
File: not_so_bad_wojak.jpg (13KB, 601x601px) Image search: [Google]
not_so_bad_wojak.jpg
13KB, 601x601px
>>59440176
Okay, thank you again anon.
>>
>>59440195
Go to tumblr and search for lucoa cosplays
>>
>>59440210
Disgusting.
>>
>>59440210
>tumblr
What are you doing
>>
So I'm unemployed, but have a CS degree with a good GPA and all that. But I don't want to work for a big company, or any company really. All I want to do is make my own games, which is feasible, but not when you have no other income. Friends/family are pressuring me to get an SE job so I can eventually work for Amazon or the like, but I fucking hate the thought of doing that. I'd rather get 20K a year making my own games than 100K+ working at a top tech company.

Is there a position I could hold that's low-stress and low-effort that can keep me afloat while working on my own projects? I don't want to get tied into being a software dev my whole life just because it's what I'm qualified to do.
>>
>>59440265
No
Move out
>>
>>59440265

Could you apply for a part time position somewhere doing part time development or something? Like you'd work half as much, and make around 50k a year, and have time left over for games and stuff.

Like I imagine there is something like that where a company only wants someone doing small programs or touch-ups on things rather than a full time person. In fact, wouldn't it be cheaper for them to not support someone full time with benefits and shit and just contract people for short amounts part time?
>>
>>59440265
you're being very short sighted.

you should put in at least a few years making 100k+. save and invest it. you can always spend more time later doing your own thing, but the time to prove your worth, and earn money, is now not later. it's very hard to go into the industry if you don't have the right experience form the get go.
>>
>>59440265
>>59440320
Don't listen to this guy. If you want to do your own thing just do it. Doing X because your family/friends told you to is possibility the worst thing you can base your decisions on.

If you want to pursue your own decisions, then go for it. Just own your own decisions and don't blame others if you fail later down the road.

That being said, you can work part time somewhere and earn just enough to still claim benefits. That should give you more than enough free time to do your own projects.
>>
>>59440265
kek I work as a line cook 3 days a week and the rest 4 days is enough to get my programming going. Pays my bills just enough.
>>
>>59440265
>>59440354
if you're confident you can live of 20k you'd only have to work for ~9 years making 100k and saving 50k of that every year, investing in index funds, to never have to work again for the rest of your life.

after 9 years you could be effectively financially independent, 30 years old, and free to do all the programming for yourself you want.
>>
>>59440381
9 years is a long time to do something you dislike even if it brings in good money. I worked at an IB when I was in college for an internship. They paid me 8k per month for those 6 months. Every single day I wake up and I wanted to shoot my brains out.
>>
>>59440450
if you want to shoot your brains out every day then yeah, that's a terrible job.

but there are plenty of good paying coding jobs that are, at worst, tolerable that can be used as a vehicle to financial independence in a relatively short amount of time if you're diligent and keep your eye on the price.
>>
>>59440132
Rust is a fad. Everyone who shills it is either an attention whore or a hysterical worrywart. Hype for "safety" is completely unwarranted. On the list of reasons your software is insecure, being written in C is at the very bottom.
>>
>>59440514
>Security concern is a hype
gee I wonder who sponsored this post
>>
>>59440511
All coding jobs are the same. So long as you can tolerate coding it is fine. What makes it good or not is the working environment, company culture and team members. But that anon talks as if he hates the idea of coding as a job. So yeah he is going to want to shoot his brains out if you ask him to code for 9 years doing something he doesn't want to do. Also depending on the type of company you work for, it might make working on side coding projects restrictive or downright nonviable.
>>
File: vee sauce.png (1MB, 1267x675px) Image search: [Google]
vee sauce.png
1MB, 1267x675px
Say I am writing a program in C that reads in a (unknown length) file, splits the file into 4 equally sized chunks, and throws the 4 chunks into child processes to sum, and return back to the parent.

I've gotten all the fork and pipe business, but I was wondering if there was any way to do this without reading the file into a huge array initially? Essentially what I'm doing is this:

1. Read file, each line into an element in an array (resizing as needed, and counting how many elements)
2. Split array into 4 arrays, pass each subarray into the child process via pipe
3. Sum as usual
4. have each child return their sum
5. have the parent sum the sums
6. show user

Would there be a way to directly read 1/4 of an unknown file size into the child processes?

It's for an assignment that requires me to demonstrate knowledge of forks + pipes, so that part cannot change.
>>
>>59440555
nice trips fag
>>
>>59440555
>It's for an assignment
Not doing your homework
>>
>>59440566
thx
>>59440579
I already technically did it but I was just wondering if there was a more effective way since I never use C
>>
>>59440555
You could always start with 4 arrays and round-robin the lines you read if order doesn't matter.
>>
>>59440539
Nice strawman, Schlomo.
>no goyim use our """"safe"""" language
>>
>>59440604
Your epic /pol/ memes are not working and we already know you and your co workers post in /g/
>>
>>59440604
The CIA has more day 0 exploits for C than they do for Rust.
>>
Is there any point in using a dynamically typed language that isn't a lisp?
>>
>>59440640
Catering to retards
>>
>>59440594
I'll give that a shot and see if it affects performance much, thank you.
>>
>>59440644
But anon, half of all people have above median intelligence.
>>
>>59440634
If more people start using Rust, do you think that would change, or stay the same? Are the even interested in putting in the time with so few developers using Rust?
>>
>>59440634
Have you audited the rust compiler?
>b-but you d-didn't audit gcc
Not an argument.
>>
>>59440662
Not an argument
>>
>>59440634
There are WAY more C programs than Rust programs.
Not even comparable.
Typical tricks, Schlomo.
>>
>>59440659
Problem is not there and you know it full well.
>>
I wouldn't use C for space stations or banking system.
>>
>>59440670
>Safety doesn't matter
>You are the jews
Lmao
>>
Haskell is the minimum acceptable language. Idris is preferred.
>>
>>59440689
Their pattern of posting is pretty obvious, pretending to be a /pol/-fag and giving away the fact that they are newfags
>>
>>59440704
Any retard who says safety doesn't matter should be brought out and executed. We are on fucking /g/ FFS. I bet those retards are posting from windows 10 or something.
>>
>>59440728
>Any retard who says safety doesn't matter
You haven't probably seen the influx of these people
>Nothing to hide, nothing to fear
>Linux is shit use Windows
>Botnet wants me to starve
>Who needs safety
etc etc

These are the kind of people that advocate against your privacy and data safety.
>>
>>59440689
>he didn't even address the argument
If you knew anything about Jews, you'd know that's exactly what they would do...
>>
>>59440728
>Sent from my Botnet
>>
>>59440728
What class of errors does rust actually prevent? Buffer overflows? I've never used it or had any desire to read about it.

Is it GC'd? Optional GC?

Most of the "serious" errors you've heard about in the news are not buffer overflows but mistakes in implementation or logic/control errors.

There is quite a bit of information on how to write C without buffer overflows, or you can use existing libraries for your needs.

When it occurs in the wild it can very rarely be leveraged into code execution.
>>
>>59440748
There you go >>59440753
>>
>>59440749
>>59440753
I see you called your colleague to help you out as well. Too bad vault7 let the cat out of the bag.
>>
>>59440779
>There is quite a bit of information on how to write C without buffer overflows
Rust's type checks is even more strict than F# if that gives you an idea
>>
>>59440779
Here is an interesting thread
https://www.quora.com/How-does-Rust-enforce-safety
>>
>>59439636

from what I'm seeing all the free ones aren't real time but are like 15 minutes delayed. As long as you aren't hitting their api several times a second you should probably be fine. Since it's not realtime though I don't see why you would have to.
>>
>>59440798
How do types have anything to do with buffer overflows?
>>
>>59440864
>What class of errors does rust actually prevent?
>>
>>59440819
I'm not quite clear on what ownership means, is it like a union?
>>
>>59439684

can't you just pass in a lambda as a callback function and have it invoke that?
>>
how do I learn c++?
>>
>>59440876
Not really
https://chrismorgan.info/blog/rust-ownership-the-hard-way.html
>>
>>59440891
By being good at C first
>>
>>59440883
No, because that would actually solve the problem.
You've got to delay programming progress by inventing a shitty paradigm and trying to fit it where it doesn't belong, then invent awful "patterns" to try and reify the problem with your dumbass cult
>>
Where do the most mature programmer hang out? Is it Google+?
>>
>>59440947
https://discord.gg/MzjdTjU
Get in here fag
>>
File: y5.png (38KB, 629x739px) Image search: [Google]
y5.png
38KB, 629x739px
Any anons who knows psuedo code able to help me with these?
>>
>>59440967
Only manchildren use Discord.
>>59440947
Mailing lists or IRC.
>>
File: 1476468849463.jpg (535KB, 1445x2048px) Image search: [Google]
1476468849463.jpg
535KB, 1445x2048px
I wanna learn git but this scares me I feel like I'll spend more time fucking with it than doing my projects
>>
>>59440728
rust isn't safer you fucking retard
>>
https://openlibrary.org/api/books?bibkeys=ISBN:0451526538&callback=bookInfo&jscmd=data

If I run this URL as a script, this runs the function "bookInfo" with a single argument.
However the function needs a second argument which I can only include as part of that URL.
Is there a way I can modify the URL so that it adds a second argument?
>>
>>59440967
Fuck off >>>/v/
>>59440986
I already use IRC and that's where I remain most of the times.
>>
>>59440976
No, we only know real code, so we can't understand pseudo code.
Sorry
>>
>>59440947
socializing is for normies. even /dpt/ is gay and retarded
>>
>>59440976
too small for me
>>
>>59440894
Rust is really a different way of thinking. That was an interesting blog post. I guess I'll do some reading on it now just to see, always fun to learn new things.
>>
>>59440947
Google+ and Quora, the absolute best programmers with actual knowledge are there.
>>
>>59441046
the best programmers are busy programming or dealing with their own company's issues rather than trying to show off on sites like quora
>>
>>59441007
It's not that hard, you only need the top 2 levels to be productive with it.
>>
>>59440894
>Quick and easy steps to get me to never use a language
>Step 1
>Each object can be used exactly once. When you use an object it is moved to the new location and is no longer usable in the old.
>>
>>59441098
ok
>>
for (var book in document.getElementsByClassName("book")) {
console.log(book.id);
}


I haven't a clue why, but no matter what the classname is, this piece of Javascript will print "undefined" three times.
It should really be printing a long list of numbers.
>>
>>59441228
Also, "document.getElementsByClassName("book")" is an array with a length of zero, apparently it isn't finding anything despite there being images saying class="book"
>>
>>59441065
>no rebase until level 5
haha okay, bud
>>
>>59441228
book is the iterator, doesn't store the actual element. also, are the books inside a iframe or something?
>>
>>59441335
It's not the iterator either apparently.
I tried printing book instead of book.id, and it printed:
item
namedItem
length

I have no idea what to do with that.

As for the books, they're images that are direct children of the body.
echo '<img src="" alt="Loading '.$ISBN.'" class="book" id="ISBN:'.$ISBN.'"></img>';
>>
>>59441382
>namedItem
because getElementsByClassName returns a nodelist, not an array, so it iterates through the properties. just use a normal loop, not "in" notation. also, typically you don't have a close img tag. try document.body.querySelector(".book"), and see what it says.
>>
alright retards, I'm shit at math and I want to generate primes around 1000 bits long

how do I go about this. right now I'm just making random numbers, sieving out a few, and using fermat to get a good candidate, but it isn't working

help or i'll kill myself
>>
How to prepare for job interviews?
>>
>>59441476
>>59441479
Learn Lisp.
>>
>>59441490
or learn to program. you know, either one
>>
Sudoku...

I think I have the general form of the backtracking algorithm correct, I'm just getting a weird bug where some of the columns are skipped.... Is there a glaring error here I'm too retarded to see?

bool solve(int nx, int ny, int (&gridToSolve)[GRID_SIZE][GRID_SIZE])
{

if(nx == 9 && ny == 9) //If you reached the end
{ cout << "SOLUTION!" << gridToSolve;
return true;
}
if(nx == 9)
{ nx = 0; ny++; } //If a row is solved, move to the next one
if(gridToSolve[nx][ny] != UNASSIGNED) //If there's a number there already, skip it.
{ if(solve(nx + 1, ny, gridToSolve)) return true; }
else
{
cout << "At this point..." << nx << "\t"<<ny << endl; //To check progress (col, row)
for(int num = 1; num <= 9; num++) //once per number;
{
cout << "Checking for..." << num << endl;
gridToSolve[ny][nx] = num;
if(checkForErrorAtIndex(nx, ny, gridToSolve)) //If there are no conflicts at the index
{
cout << gridToSolve << endl << "Moving to ..." << nx + 1;
if(solve(nx + 1, ny, gridToSolve)) return true;
}
gridToSolve[ny][nx] = UNASSIGNED; //Backtrack
}
}
return false;
}
>>
>>59441498
Is that all that's required? Do they just ask you to write fizzbuzz?
>>
>>59441512
>C++
Found the problem.
>>
>>59441533
no, I just thought it was funny that his solution to solving problems was learning a specific language rather than learning how to program in general
>>
>>59441479
lip balm
>>
I'm putting together a resume and in order to get my Github contributions up I've been submitting pull requests to projects without licenses to add a license.

I thought this would go well and give me a lot of activity and contributions on my GH but mostly people aren't thrilled with my PRs. Responses range from nothing to flaming me. Well these people have public projects without licenses, they deserve flaming instead of me.
>>
>>59441512
brute force will take a while won't it?

anyway, does unassigned==0
>>
>>59441596
9^3 isn't that much. And the optimized version requires using sets, which your average CS101 kiddie hasn't been exposed to yet.
>>
>>59441592
"I'd just like to interject and add a license to your program you definitely don't want in order I may bamboozle recruiters who will see recent activity on my dormant github account".
>>
>>59441512
Can't see the issue, wanna post the full shit in a pastebin.
>>
File: Concerned Luluco.gif (140KB, 379x440px) Image search: [Google]
Concerned Luluco.gif
140KB, 379x440px
>>59441596
Yes for both.

At this point, I just want a working Sudoku solver. I'm planning on making a better algorithm later.
I've read about using something similar to genetic algorithms to solve sudoku, but am not sure what I could do...

Here''s what wikipedia suggests:
Sudoku can be solved using stochastic (random-based—search) methods. An example of this approach is to:

Randomly assign numbers to the blank cells in the grid
Calculate the number of errors
"Shuffle" these inserted numbers around the grid until the number of mistakes is reduced to zero

>>
>>59441563
That's because every programming language is just Lisp in disguise.
>>
>>59441669
>every language is utter trash
Nope.
>>
>>59441592
Why though? Why not just write actual code?
I know you are probably autistic but people don't like being told how to run their project.
Legally speaking, there is nothing wrong with not having a license. It just means the creator is the only one who has rights to do anything with it.
>>
>>59441676
No matter what pathetic feature your language may have, Lisp can be seamlessly extended to incorporate it.
>>
>>59441512
Knuth has a backtracking fascicle out http://www-cs-faculty.stanford.edu/~uno/fasc5b.ps.gz

>C++
Looks like an abortion to me, if it's skipping columns there's either a problem with your loop guard or the "//If there's a num there already skip it" if statement.
>>
>>59441723
Extend Lisp to remove absolutely all traces of I/O from it. Until it can do that it will forever remain a trash language.
>>
>>59441669
Why the fuck would you name your programming language Lisp?
>>
>>59441759
Because everyone spells it differently.
>>
>>59441755
(fmakunbound 'read)

>>59441759
It at one time stood for List Processing.
>>
>>59441759
http://lmgtfy.com/?q=lisp+full+form
>>
>>59439706
Would you care to share your shader code?
>>
>>59441755
is this a new meme or is just the same retarded anon who's sperging about removing I/O
>>
>>59441512
can't you move the //backtrack outside the loop?
>>
I've heard you guys were into NN at some point.
Did you guys use https://software.intel.com/en-us/intel-mkl or any other math kernel?
>>
>>59441797
>>59441804
>>59441813
Yeah but it's called LISP you know, like the speech impediment? Why would you want that association?
>>
>>59441828
Found the problem. There was some dummy debug function being called higher in the code and if I never ended up using the value of shadow.x in the return statement, the compiler culled out all of the statements regarding it. Neato.
>>
>>59441843
Dunno, you'd have to dig McCarthy up, reanimate him, and ask him yourself.
>>
Will you guys ever make a programing wiki like the other generals on this board have? I'm lost at where to start and I don't trust google on this
>Ruby on rails
>>
>>59441850
Well I just wanted it because I'm curious.
I've missed your troubleshooting process and earlier posts. Is this some form of distance field clouds?
>>
>>59441836
the few annoying memes here are just being forced by the same people every day.
>>
>>59441853
We had one but there was a lot of complaints.
Programming is like religion. No constructive arguments and the zealots are violent.
>where to start
There's tons of ways to start. The best way to start is to find something you think you will care about. For instance if you're interested in making cool webpages you'd go program in JS, you wouldn't start learning C.
>>
>>59441839
Moving the
             gridToSolve[ny][nx] = UNASSIGNED; //Backtrack
line didn't seem to do much... But thanks for the suggestion
>>
>>59441853
What would you like to develop?
>>
>>59441912
Strong AI.
>>
>>59441853
>Will you guys ever make a programing wiki like the other generals on this board have?
No.
>>
>>59441920
You can start with Python then. It has some nice libraries for machine learning and neural networks which are the backbone for most statistical methods of "intelligent behavior". Note that AI as we think about it in popular culture is a myth.
>>
>>59441853
Ruby and Rails is meh, but if you must know there's really only 2 books you need this one:
http://patshaughnessy.net/ruby-under-a-microscope and this one: http://therubyway.io/ for Ruby then go on libgen.io and look up whatever most recent Rails book is or just read the docs that come with Rails to figure it out.

https://www.gitbook.com/book/frontendmasters/front-end-handbook/details would be easier, just write a 'React' app or Vue.js pile of shit and get it to natively host somewhere on Google App Cloud or w/e it's called these days, forget Rails.
>>
>>59441932
>Python
t. brainlet
>>
>>59441476
So you want numbers about 2^1000 in magnitude, right? Have you tried using the sieve of eratosthenes method (optimized, obviously)?

I'm not sure what you're having trouble with
>>
>>59438935
>studies this
>dies from having $0
>>
>>59440052
>this gets a interview
Cant w8 till the summer so i can finally lie tht i have a degree
>>
>>59441920
>AI
>Ruby Rails

What.

Modern applied AI is all done in python mainly, that are just wrappers for gigantic libraries like Tensor Flow (C/C++). If you want to write/design AI you want to start reading graduate papers in AI at a rate of 300 per month like a normal grad student would, and in about 6-8 months you can start implementing your own shit.

>>59441950
GeoHot, who's startup is about to sell for a few billions (and was offered a job by Elon Meme Musk w/a 3 million signing bonus) is entirely in AI, and uses Python wrappers too. (I hate Python, but it's not 'brainlet')

http://comma.ai/hiring.html
>>
File: 1470282110246.jpg (56KB, 1280x720px) Image search: [Google]
1470282110246.jpg
56KB, 1280x720px
>>59441912
>>59441884

I would like to develop a HUD, sort of like Metroid or Halo Helmets showing data. Just for a side project. Currently Motorcycle helmets do it and I think it's pretty neat but I want to create my own.

this isn't me >>59441920
>>
>>59441993
>Python
>Ruby
Trash.
>>
>>59441476
Just use gmp's functions for exactly that.

Alternatively see the answer in this.
https://crypto.stackexchange.com/questions/71/how-can-i-generate-large-prime-numbers-for-rsa
>>
>>59441900
Yeah, it literally does nothing.
>>
>>59441993
>""""""""AI""""""""
gay as fuck
>>
File: imgres.jpg (6KB, 120x160px) Image search: [Google]
imgres.jpg
6KB, 120x160px
This dumb book tells me to write this. So i do and i just dont understand elif......

print ('What is your name?')
name = input()
if name == 'Alice':
print('Hi, Alice')
elif age < 12:
print('You are not Alice')
elif age > 2000:
print('Unlike you, Alice is not an undead vampire')
elif age > 100:
print('You are not alice grannie')
>>
>>59442106
elif = a stupid contraction of "else if"
>>
>>59442106
elif = ELSE IF
>>
>>59442116
Another one of python's mysteriously inexplicable decisions that makes it a pain to write in
>>
>>59442113
Okay well how do i make elif like... i dont know how to say it, but work.

If i type anything but Alice or i type anything after it gives me an error. Am i meant to define what 'age' is? It dosent tell me to in the book.
>>
>>59441993
>comma.ai
>Either way, Tesla doesn’t agree. When Hotz first made his statement about “crushing” Tesla’s and its partner Mobileye’s Autopilot system, Tesla responded with a statement:
>“We think it is extremely unlikely that a single person or even a small company that lacks extensive engineering validation capability will be able to produce an autonomous driving system that can be deployed to production vehicles. It may work as a limited demo on a known stretch of road — Tesla had such a system two years ago — but then requires enormous resources to debug over millions of miles of widely differing roads.”
lol
>>
>>59442127
Yes.

print ('What is your name?')
displays a message to the console

name = input()
gets a line from the console (the user types it in and presses enter), and then stores it in "name"

extrapolate from this to get the age
>>
>>59442127
Yes, define age.
>>
>>59442127
if this condition is satifised:
execute this code
else if this condition is satifised:
execute this code
else:
execute this code


Remember your code terminates whenever one condition is met or if it runs into the else block
>>
>>59442128
It already works though, it's open source you can build the board and try it yourself. The main difference is Geohot avoided if statements type of AI garbage that every other shitty engineer is doing. It's not self-driving either it's a kind of 'cruise control' where you can turn on self driving on a highway and it just works.
>>
>>59442145
>>59442151
Okay, cool.

I understand the code now, it was just weird how the book never told me too, i flicked through the pages and it started telling me to create a bug in the code when it wasn't even working properly in the first place?
>>
>>59442171
>if statements type of AI garbage
Neural nets were around since the 60s. Probably earlier.
>>
>>59442181
>i flicked through the pages
What?
>>
>>59442171
tesla and many other car companies are already working on this. why do you have such a boner for this guy?
>>
>>59442196
turned the pages in the book, that's where it told me to right that exact code.
>>
>>59442208
write*
>>
>>59442208
>>59442217
Did they not explain how an if, elif, else statement work?
>>
>>59441860
Yep!

I don't want to send the whole code (partially out of shame and partially out of greed) but I compute fractal brownian noise, then I do a super large pass of simplex noise over that, drop it by 0.5 per frag, then march through the clouds and add the inverse of any given point as cloud thickness. I also calculate light at each point that has thickness and alpha blend that.

Looks breddy gud and runs fairly quickly
>>
>>59442227
>a language needing elif or else at all
Garbage.
>>
>>59442247
You never NEED it but it makes programming easier, pleb.
>>
>>59442227
Yes.

Did i miss something? I knew what it meant and stuff, but i didnt understand why it didnt define what age was, maybe i missed what was said about it.
>>
>>59442247
I am not arguing the merits of python you moron. I am asking if that was taught in the book because if it doesn't teach basics and then ask you to code then it is a bad book. So I am checking when he said turned the pages, did he literally just choose a page and start there without reading the rest.
>>
>>59442267
It didn't define age because you are supposed to define age. If you learnt if else and how to assign/create variables, it should be 1+1 in terms of putting these 2 concepts together.
>>
>>59442256
(if condition
then-form
optional-else-form)

What's so hard about that?
>>
>>59442289
okay, well it didn't say "do it yourself now" and it kept going on and on for the next 2 pages with the same code
>>
>>59442292
>that FP perfection
I'm hard.
>>
>>59442303
>do it yourself now
This is implied or how else would the code run....

I mean anon. Programming requires some critical thinking skills.
>>
>>59442271
Literally don't care about anything you said. Python is trash.
>>
>>59442335
This is autism. Injecting your opinions into post that has nothing to do with your point.
>>
>>59442292
How would this look with actual code being executed by that if
>>
>>59442352
Looking back at that snippet, I'd probably use COND instead. IF in either language is too noisy in my opinion.
(cond ((string= name alice) (print "Hi, Alice"))
((< age 12) (print "You are not Alice"))
((> age 2000) (print "Unlike you, Alice is not an undead vampire"))
((> age 100) (print "You are not alice grannie")))
>>
>>59441424
So using .length on a nodelist always returns zero?
And how do I use a loop to iterate through a nodelist?
>>
>>59442342
>autism
DING DING DING DING DING
THERE'S THAT WORD AGAIN
THERE'S THAT WORD
THERE'S THAT WORD PEOPLE USE WHEN THEY HAVE NO ARGUMENT
HE WON YOU LOST LEAVE AND COME BACK WITH AN ARGUMENT
>>
>>59442399
Also, that should be
(string= name "Alice")
. If you wanted input to name, that would just require a let and a call to read-line.
>>
>>59442430
There was no argument in the first place you moron. Was I even arguing about Python or its merit? Holy shit this is legit autism. No one was arguing with you anon. Please calm down and conduct yourself.
>>
>>59442399
that looks pretty ugly. what language is that?
>>
>>59442467
It's the parens, I bet? Common Lisp.
>>
I know java, html, css, javascript, php and assembly (all from school classes). What should I learn next?

should I pick up the C programming language book?
>>
>>59442500
Common Lisp.
>>
>>59442500
Rust
>>
Hey, I'm printing out a binary heap in different traversals. Anyways, lets say someone asks if these traversals are sorted.

Does 'sorted' only strictly mean increasing/decreasing order? Or do other patterns count as sorted?
>>
>>59442579
Do you mean ordered/unordered trees? Sorted doesn't make sense.
>>
>>59442579
>>59442600
Nevermind, I think I understand you. In-order should be sorted. The others, not so.
>>
>>59442500
>should I pick up the C programming language book?
It's very handy to know.
>>
>>59442615
sure, but does "sorted" only mean like an increasing/decreasing order? Cause I did inorder, preorder, postorder but nothing is is sorted increasingly/deacresingly, so unless 'sorted' can mean other patterns im not so sure
>>
>>59442615
>>59442627

Given a binary min heap of letters A to J

My inorder heap is: H,D,I,B,J,E,A,F,C,G

How is that sorted?
>>
>>59442664
>>59442627
>>59442615
Or to make it even more simple, using the tree and traversals from here: http://www.geeksforgeeks.org/tree-traversals-inorder-preorder-and-postorder/

How are any of them "sorted" if any?
>>
>tfw to dumb to program advanced projects but I find beginner and intermediate projects boring like build an application that searches through a bunch of directories and do x operations etc

What it do?
>>
>>59442692
Your tree in that link is not a BST, so that is why you get results counter to what you'd expect from traversing a BST. Either that, or this IS a BST, and the values you see there are merely designators for the nodes (the keys are hidden).
>>
How do I do a recursive algorithm for multiplying five numbers? I have got it done for two. In C++.
>>
>>59442771
binary min heap isn't a BST, just BT. The only thing that matters is the the root is less than its childs.
>>
When can I pretend I am good enough in a language to market it as a skill? I feel like it never ends. For example in C I have a decent knowledge of hardware architectures, I can write compilers and implement advanced algorithms and medium sized projects. Yet when I see how much the language can accomplish that I don't know I just feel lost. Same with Haskell, I can comfortably use all features, implement new type systems and non trivial concepts pulled from academic papers, I even unironically studied category theory yet competency looks so far.
Should I just kill myself?
>>
>>59442799
Yes
>>
>>59442799
Youre overthinking it. If youre competent, market it.
>>
>>59442797
Right, so you shouldn't expect an in-order traversal of something that is not a BST to give you sorted results like traversing a BST would. Post-order in your case might work.
>>
>>59442832
So if someone asks if its sorted, that would only be correct if its in increasing or decreasing order?
>>
>>59438776
nonlinear regression of kepler flux/time data with gaussians fitted on the loss to determine if there was an exoplanet transit at a certain time.
in python :^)
>>
File: 4ch.png (154KB, 1478x701px) Image search: [Google]
4ch.png
154KB, 1478x701px
>>59443004
>>
>>59443004
>using the smiley with a carat nose
>>
>>59443084
((( :^)m )))
People forget what that smiley even means in the first place
>>
>>59442106
Throwing in there that a much better solution is to use case/switch

Python technically doesn't have this though an the way you're supposed to implement it is a weird thing with a function. Look it up
>>
>>59443097
what? is it supposed to be moon man?
>>
common lisps's case is so shitty
it can't even match against strings
>>
>>59443178
What other caricature has a pronounced nose and holds their hand like this 3
>>
File: 88a.png (9KB, 215x215px) Image search: [Google]
88a.png
9KB, 215x215px
>>59443194
ohhh
>>
>>59443097
>>using the smiley with a carat nose
>>
>>59443222
Oy Vey :^)m
>>
>>59443190
Why are you using case with strings you shit? It uses EQL. Use pcase, or better yet, cond.
>>
File: 1471693734478.gif (143KB, 500x400px) Image search: [Google]
1471693734478.gif
143KB, 500x400px
>>59438776
Under libcurl, do all setopt options get reset after calling curl_easy_perform?
>>
>>59443274
test and find out
>>
File: 1419436544084.jpg (28KB, 245x245px) Image search: [Google]
1419436544084.jpg
28KB, 245x245px
>>59443320
This is the cold hard truth I didn't want to hear.
Next.
>>
For good code design, should anything be "single-purpose"?

I'm writing character recognition software and trying to make functions as general purpose as possible. I'm trying to avoid special case functions, but I've run into a problem:

- recognizing words is general purpose
- recognizing math is general purpose*
- recognizing matrices is general purpose
- recognizing cursive is general purpose
- recognizing square roots is single purpose

My methodology cannot lump square roots in with the general purpose math recognition. I need to hotfix it in, it's jank as fuck.

Is single-purpose code bad?
>>
>>59443507
you'll need single-purpose components for anything complex, like you're making character recognition software, then you can't just make one function to recognize all characters, you have to add complexity to your software to deal with square roots etc
>>
https://kukuruku.co/post/i-do-not-know-c/

How many questions did you get correct, /g/-chan?

Don't lie anon!

Maybe Rustfags were right about C all along, maybe it is a hellish trap of undefined behavior and double frees waiting to happen!
>>
>>59443531

That's the thing. I'm wracking my brain around trying to make square roots lumped into math recog. Square roots are hard to divide into smaller constituents so I need to make a special case for it.
>>
File: why.png (20KB, 484x72px) Image search: [Google]
why.png
20KB, 484x72px
Web-"devs" will defend this.
>>
>>59443576
>not using monads
>>
>>59443597
and comonads for the document
>>
>>59443533
It's obvious C has design flaws that stayed as is for backward compatibility, because Unix got very popular and was the main vector of spread for C.

However, Rust is still a despicable language, backed by morons and nowhere attaining both the ease of use and implementation that characterize C. Hell, despite 7 years of development, the set of language features are still not stabilized. If you plan to replace C, at least, try to keep it simple, so you can actually label it as a programming language.
>>
>>59443631
>C
>ease of use
>despite >>59443533
It's time for this meme to die.
>>
>>59443660
By ease of use, it also means it's easy to blow it. I mean, there's no dark magic in C. Don't be stupid, and you may avoid undefined behavior.

Actually, undefined behavior exists because of implementation-defined behavior, C doesn't enforce a behavior where there's no common way across machines to do something, eg. passing arguments to a function. Of course, this facilitates the work of the implementator, not so that of the user, I agree. Other than that, it's still fucking easy to start with C when you actually have a CS background.
>>
>>59443728
If a tool makes it easy to shoot yourself in a leg it doesn't mean the tools is easy to use, on the contrary, the tools is hard to use properly. Unless ofc your idea of "using" is "quickly write some half-assed code what appears to work and call it a day". Then again, according to the list of 0-days CIA collected, this appears to be the typical mindset of a C programmer.
>>
>>59443773
I am sure Rust has plenty of exploits as well. It is just safer from 0-days in the same way Mac is safer than Windows when it comes to viruses. Lack of people using it makes it a non-target.
>>
Found this. https://youtu.be/D7Sd8A6_fYU
This is disgusting. A C++ advocate that openly claims that you shouldn't argue about C++ vs C, within the first two minutes. You should persuade people to switch to C++, ignoring argument.

I didn't need more proof that the C++ community is just an an misanthropic cult. But the zealots are usually not this blatant.
>>
>>59438935
If you are actually interested in making money:
>Java
>C# / XML
>JS / HTML / CSS
>Python
>Swift / Obj-C
>ASM (optional)
>>
>>59439113
Fuck off Bjarne, nobody likes you.
>>
>>59443836
Why do you think a language specifically designed to prevent security vulnerabilities and to be as safe as possible is as unsafe as a language designed to be as primitive and as close to the typical machine of the 70s as possible?

I'm not saying you can't write safe code or C, I'm saying it requires much less effort to do so in Rust, thus significantly reducing the probability of actually screwing up.
>>
It would seem that the 5 key on my laptop keyboard is now dead. While I have a numeric keypad, I am still unable to type the modulus key without copy and pasting from another source. This is rather irritating. I hope none of my other keys die, as I would rather not have to replace yet another machine.

Oh well. I don't use modulus THAT much in my code...
>>
>>59443921
You do know you can buy and replace laptop's keyboard without replacing the laptop itself?
>>
File: 1488459447829.gif (2MB, 360x360px) Image search: [Google]
1488459447829.gif
2MB, 360x360px
>>59443921
5%
>>
>>59443921
fuck outta here with that shit
>>
>>59443533
>UB
Complaints about UB are usually not sane.

The discussion we had about function parameter evaluation order (which is UB in C and defined in many other languages) is a fairly good example.
https://warosu.org/g/thread/S59209636
It was very constructive.
It's there for a reason. The alternative is worse for the target you have with C as a language.

Same goes for most of it. Smart people made C. It's a well considered language which doesn't extend past its bounds. It's extremely convenient for programmers who care about performance. Most other languages don't have those facilities. You're completely stranded if you have any semblance of standards for computation speed.
>>
>>59443866
I think he meant once the conversation devolves to arguing its over. And that you should attempt to persuade peacefully.
But leave it to a c-fag to automatically take that as an attack.

t. dont even use c++ anymore
>>
>>59443950
>conversation devolves to arguing its over
Because there's no good arguments for sepples.
>>
>>59443962
Strictly c & c++ theres plenty.
But given we now have a decent few alts to the c family, then youd be correct
>>
>>59443950
>I'm gonna interpret him as favorably as possible from what little information I have
The rest of his talk makes it perfectly clear though.
He doesn't present a fair argument. He points at issues with C claiming its bug prone (most of the complaints really only cover the issues novice programmers face). He doesn't compare the two in any capacity and appeals to the audiences bias by claiming that they all know C++ is better, so he doesn't need to motivate it.

He's explicitly relying solely on rhetoric and ignoring argument completely. As he said he would. Most disturbingly he looks at a trend graph showing C growing and C++ falling in embedded systems and expresses that that's a problem. Doesn't even consider that maybe C++ has issues appealing to these people. He admits that market powers would draw people to C++ if it's such a great language. But he then claims that maybe you shouldn't let things develop naturally towards an optimal solution but rather insert propaganda (such as his talk) to encourage things move in the directly he wants it to move.

They are zealots. No question about it.
>>
>>59443921
You are one of the more tolerable tripfags, but don't push it.
>>
>>59443989
>They are zealots. No question about it.
Thats literally all lang cons.
Theyre all a circlejerk.

The sad part is the people who come in and break up the monotony are usually worse than the zealots. And just throw out a bunch of strawmans and naive anecdotes.

Social events for programming are a mistake.
programming getting popular was a mistake.
>>
could someone help with this?
    print('How old are you?')
age = int(input())
elif age < 12:
print('you are not jack, kid')
else:
print('You are not jack or a kid')


'if' works but it HAS to be 'elif' why won't it work?
>>
>>59444045
soz, this is the whole code

print ('What is your name?')
name = input()
if name == 'Jack':
print('Hi, Jack')
print('How old are you?')
age = int(input())
elif age < 12:
print('you ar enot alice kid')
else:
print('You are not alice or a kid')


Is it cause i need and if before elif?
>>
>>59443533
C id synonymous to undefined behavior
>>
>>59444048
You need to put an offset before
age = int(input())
.
>>
>>59443933

Finding a replacement keyboard for a laptop line that is no longer being manufactured isn't exactly easy...
>>
>>59444048
You need an if before elif or else.

That code won't work though.
I think you meant this
name = input()
if name == 'Jack':
print('Hi Jack')
print('How old are you?')
age = int(input())
if age < 12:
print('you are not alice kid')
else:
print('You are not alice or a kid')
>>
hey /g/, I'm trying to understand the copy function in C (or maybe it's a particular copy function just for bmp images). There's this bit right here, and I understand what it does, but I don't understand how. Basically, how are these nested loops iterating through everything? the i and j are not used after they are declared, I don't get it. Shouldn't there be something like triple[i][j] somewhere in there?

// iterate over infile's scanlines
for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight; i++)
{
// iterate over pixels in scanline
for (int j = 0; j < bi.biWidth; j++)
{
// temporary storage
RGBTRIPLE triple;

// read RGB triple from infile
fread(&triple, sizeof(RGBTRIPLE), 1, inptr);

// write RGB triple to outfile
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
}
>>
>>59444145
> RGBTRIPLE
Why it's in caps?
>>
File: 1486752513923.jpg (270KB, 750x728px) Image search: [Google]
1486752513923.jpg
270KB, 750x728px
>>59438776
serious question: how do you get stuff done when you have an internet addiction (which I'm sure a large percent of you guys have)?

I'm a pretty decent programmer when I'm actually productive, but I have serious problems getting to that mode and staying there.
>>
>>59444116
Yeah i know, i tried just 'if'

but the book example uses 'elif'
This is the example

if name == 'Alice':
print('Hi, Alice')
elif age < 12:
print('You are not Alice, kiddo')
else:
print('You are neither Alice, or a little kid')
>>
>>59444145
Um... That's not C.
>>
>>59444159
Fuck off back to your subr*ddit.
>>
>>59444162
In that case, then >>59444074
is correct.
>>
>>59444182
I'm not to sure what that is
>>
New thread:

>>59444191
>>59444191
>>59444191
>>
>>59444156
it's not my code, it's homework for cs50x. It's in caps because it's a typedef struct and they just went all caps.

>>59444164
yeah it's C. It's not the whole code, not gonna paste 100+ lines here, that's just the bit that I don't get.
>>
>>59440132
>>59440139
had to double take before I read replies 3rd image should be an immediate red flag
>>
>>59444200
It's not C. I've written many compilers for it and I can assure you that isn't standard C.
>>
>>59444156
Type declaration.
>>59444145
The i and j variables are just there for the for loop, they aren't used. The comments explain what the for loops are there for.
>>59444189
It means this
print ('What is your name?')
name = input()
if name == 'Jack':
print('Hi, Jack')
print('How old are you?')
age = int(input())
elif age < 12:
print('you ar enot alice kid')
else:
print('You are not alice or a kid'

the age = int(input()) statement needed to be indented.
>>
>>59444217
>needed to be indented.
i will never understand why people willingly learn that shit.
>>
>>59444145
Each time you read a RGBTRIPLE from file inptr, its file position indicator advances by sizeof(RGBTRIPLE) bytes. Same with fwrite.
>>
>>59444217
huh? If i write any age when it asks me it goes blank... the program ends?
>>
>>59439397
Yahoo stocks and then download as .csv

That's how I got data for my nn
Thread posts: 320
Thread images: 28


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