[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 34
File: dat boi.gif (91 KB, 312x420) Image search: [Google]
dat boi.gif
91 KB, 312x420
Previous thread: >>54682943

What are you working on, /g/?
>>
>>54690291
nothing tbqh
>>
how come you fags never post stuff related to infosec?
things like this: http://bits-please.blogspot.com/2016/05/war-of-worlds-hijacking-linux-kernel.html
>>
>>54690328
because meme popsci is autistic
>>
>>54690328
i don't find it interesting at all, i'd rather create my own software without limitations instead of trying to find some tiny loophole in someone else's software
>>
reposting because no1 replied:
im implementing behavior trees in Java right now and want to use a non-specific class as the data context, is using generics to pass the type of data context on each individual node the way to go? or is there some more elegant way to achieve this, or is it a bad idea altogether?
>>
>>54690328
If you want to share links then go to reddit
>>
File: engine 2016-05-16 13-27-27-54.png (347 KB, 1280x720) Image search: [Google]
engine 2016-05-16 13-27-27-54.png
347 KB, 1280x720
I'm finallly going to graduate.
>>
>>54690650
story?
>>
O SHIT WADDUP!
>>
>>54690791
6 long years of high school
>>
>>54690291
el test
>>
File: ivy-sif-demonstration.gif (173 KB, 800x625) Image search: [Google]
ivy-sif-demonstration.gif
173 KB, 800x625
Trying to get my image viewer to properly display gif images. The gui library does not do this natively, so displaying animated gifs is a real ordeal. I'm probably going to have to write a lot in the mailing lists because most of the time displaying a gif is nowhere near this easy/smooth.
>>
>>54690831
what does your picture (raytracer ?)have to do with it?
>>
>>54690843
What's the problem?
Deconstruct the gif into frame delay/ogl texture pairs and just play those.
>>
>>54690856
that's not me.
>>
Redesigning C++ 3D engine core in C.

Fucking hell I forgot how fun C really is. The lack of safety measures like protected, private and constructor/destructor was intimidating at first but you just feel free in this language. I was even able to drop my shitty inheritance system to an understandable struct system.
Probably gonna make the full switch.
>>
>>54690910
When you won't be scared by allocated space, you will shit on C++.
>>
File: cmd.png (9 KB, 301x300) Image search: [Google]
cmd.png
9 KB, 301x300
How do you develop on Windows?

Do you install all the needed shit locally and deal with the Windows environment or use Virtual Machines or something like Vagrant?

What about the command line? Powershell? Cygwin? or just something like Cmder that makes cmd less painful?
>>
>>54690943
Are you retarded?
>>
what should i make?
>>
>>54690867
I'm splitting the gif into its frames, grabbing the delay for each frame, and then looping the canvas draw call, sleeping for <delay> seconds. The problem is when it comes to gifs that have been optimized to have a lot of transparencies and expect the background to still be displayed so the other frames and be displayed on top of that. If I always display the background, expecting those kinds of gifs, then the Sif gif will look funny because the background frame will always be displayed.

There's also a problem with grabbing the frames of the large gifs and loading them into a bitmap% object - something about LZW compression being out of bounds, I have no idea what's going on with that. There's also a gif or two that have an "unexpected EOF" error when loading into the bitmap% object, but they load just fine in Firefox or Eye of MATE.
>>
>>54690958
a android podcast app that ACTUALLY fucking works
>>
>>54690957
calm down pajeet
>>
File: gamergate girl code dpt.png (55 KB, 534x344) Image search: [Google]
gamergate girl code dpt.png
55 KB, 534x344
make this do what she intended it to do in a language of your choice
>>
>>54690910
Do you just have a pointer to a parent in your child struct? ie
class Child : Parent {
//....
};
// becomes
typedef struct Child {
Parent *parent;
//...
};

?
It's not exactly the same though, because then the child gets everything in parent, not just protected/public stuff, but that honestly doesn't matter/make a difference
>>
File: screenshot.jpg (93 KB, 1099x554) Image search: [Google]
screenshot.jpg
93 KB, 1099x554
https://github.com/chvrn/4chan-whose-post-is-it/

Fixed it up

Adds guessing game looking like pic related to /int/, /pol/ and /sp/ catalogs
>>
File: yodabait.jpg (147 KB, 500x378) Image search: [Google]
yodabait.jpg
147 KB, 500x378
>>54691030
>>
File: rpc.webm (389 KB, 964x580) Image search: [Google]
rpc.webm
389 KB, 964x580
Working on a RPN calculator.
>>
>>54691030
#include <stdio.h>
int main(int argc, char **argv) {
FILE *in = fopen(argv[1], "r");
FILE *out = fopen("out.cpp", "w");
char c;

while (!feof(in)) {
c = fgetc(in);
fputc(c, out);
if (c == '=') fput(c, out);
}
fclose(in);
fclose(out);
return 0;
}
>>
>>54690910
>safety measures like protected, private
those are not as much safety measures as they are a useless pain in the ass
>>
>>54691034
>recreating inheritance
>>
>>54691030
 System.out.println("Block.");
>>
>>54691117
Is there an issue?
>>
>>54691091
>undeclared identifier
>>
>>54691030
#include <stdio.h>

int main()
{
if ((strcmp(Tweeter,"Gamergater") == 0) ||
(strcmp(Tweeter,"Negative") == 0))
printf("Block\n");

return 0;

}
>>
>>54691079
Looks comfy
>>
>>54691034
Pretty much. In C the Parent class would have to have allot of stuff in it to have multiple Childs with different needs, though. But nothing a little pointer magic cant fix.

>>54691111
It really seems like a "fix" for the weak base class problem that comes with inheritance, but inheritance has ended me up with a clusterfuck more times than I care to imagine.

>>54691117
Isn't it composition at that point?
>>
>>54691162
I wrote it in the reply box, heh, but which one? I've read it like 4 times now and feel retarded. Unless you're referring to the Tweeter, Gamergater, Tweet, Negative, etc.
>>
>>54691184
It is. I have to implement variable and it will start to kick ass.
>>
>>54691183
>not just !strcmp
Block
>>
>>54691209
fput
>>
>>54691242
Ah, that's a typo for fputc, nice catch
>>
>>54691254
also, "c" should be "int"
>>
>>54691212
>!strcmp
So what if strcmp returns a value less than zero? Faggot.
>>
>>54691212
>tfw gets compiled to the same thing in assembly and improves readability

 goto reddít; 
>>
>>54691277
not necessary pal
>>
>>54691030
>she
>>
>>54691277
char can be implicitly cast to int on function call
>>
anyone here do primary development in Linux? I've been working in a VM but holy damn has it been slow.
>>
>>54691358
yes why
>>
>>54691358
Most of us do, I think
>>
>>54691372
is...is it any better?
>>
File: 1462289853586.gif (1 MB, 294x350) Image search: [Google]
1462289853586.gif
1 MB, 294x350
>>54691400
You have no idea.
>>
Is there any difference regarding overhead between

static const int decent_penis_length = 12;
int my_penis_length = decent_penis_length;


and

int my_penis_length = 12;
?
>>
>>54691400
you're missing out bro
>>
>>54691400
Just dual boot, fambly.
>>
>>54691427
it would be overflow error because the value is too big
>>
>>54691400
Working with C is a dream on GNU+Linux. If you are missing a library, you can get it in a single command, while on Windows you have to open your browser, google the library, find the download link, click the download link, manually move the folders into the corresponding directories, pray that the windows download was for mingw and not visual studio or else you have to compile the library yourself.
>>
>>54691450
i'm scared senpai~
>>
>>54691539
He uses loonix in a VM so he should already know all of this.
>>
>>54691400
Miles and miles better.
>>
>>54691297
>>54691352
wasn't talking to you retards
>>
>>54691675
dat boi
>>
>>54691291
You don't know how logical negation works do you.
>>
>>54691675
I am both of them, and the anon you replied to
>>
>>54691461
It's an int you retard.

>hur dur penis jokes XD
You're stupid joke failed and doesn't make any sense, fuck off.
>>
Can someone call me retarded and help me with this issue?

for fileName in glob.glob(data_path + "/*.gz"):
record_data = None
with gzip.GzipFile(fileName, 'rb') as record_stream:
record_data = record_stream.read()

with open(fileName.replace(".gz", ".txt"), 'wb+') as write_stream:
write_stream.write(record_data)


I'm opening ~10k .gz files that contain a single file in them and extracting them as a txt file into the same directory, one by one.

I can't figure out why I keep getting exit code 137 (Killed due to memory consumption?)

Example GZ: ftp://ftp.ncdc.noaa.gov/pub/data/noaa/isd-lite/2010/010030-99999-2010.gz
>>
>>54691796
*steps out of the shadows*

Heh... not bad, kid. Not bad at all. Your meme, I mean. It's not bad. A good first attempt. It's plenty dank... I can tell it's got some thought behind it... lots of quotable material...

But memeing isn't all sunshine and rainbows, kid. You're skilled... that much I can tell. But do you have what it takes to be a Memester? To join those esteemed meme ranks? To call yourself a member of the Ruseman's Corps? Memeing takes talent, that much is true. But more than that it takes heart. The world-class Memesters - I mean the big guys, like Johnny Hammersticks and Billy Kuahana - they're out there day and night, burning the midnight meme-oil, working tirelessly to craft that next big meme.

And you know what, kid? 99 times out of a hundred, that new meme fails. Someone dismisses it as bait, or says it's "tryhard," or ignores it as they copy/paste the latest shitpost copypasta dreamt up by those sorry excuses for cut-rate memers over at reddit. The Meme Game is rough, kid, and I don't just mean the one you just lost :^). It's a rough business, and for every artisan meme you craft in your meme bakery, some cocksucker at 9gag has a picture of a duck or some shit that a million different Johnny No-Names will attach a milion different captions to. Chin up, kid. Don't get all mopey on me. You've got skill. You've got talent. You just need to show your drive.

See you on the boards...
>>
>>54691796
Why did you get so mad at him just for making a bad joke?
>>
>>54691813
Retard.
>>
>>54691828
Because it's not an overflow error.
12 fits in an int.
>>
>>54691832
Retard.
>>
>>54691850
It's too big to be your dick size, though.

How does that justify you getting mad like you have asperger's though?
>>
>>54691117
Inheritance is just syntax sugar for a very limited form of composition & interface implementation.
>>
>>54691923
>>54691832

Now that we have this out of the way, can anyone give me a hand?
>>
>>54691947
its a good way to get rich, tough.
>>
>>54691749
>baiting this hard
I SHIT WADDUP!
>>
File: 1463656361918.png (150 KB, 359x414) Image search: [Google]
1463656361918.png
150 KB, 359x414
I just recently graduated, and I'm trying to make more programs to show off when I go to job interviews. I'm terrible with coming up with things though. Anyone have any ideas on what I could make to show i'm not completely retarded.
>>
>>54691749
no i am
>>
File: 1454814073747.png (1 MB, 1116x1488) Image search: [Google]
1454814073747.png
1 MB, 1116x1488
>>54691953
Here you go.
>>
>>54692009
write a program that can average 2 ints in C
>>
File: VJYAhgG.png (227 KB, 1418x1138) Image search: [Google]
VJYAhgG.png
227 KB, 1418x1138
>>54692022
>>
>>54692009
ideas guys are a meme
>>
>>54692022
that's a big hand
>>
File: 1429938650777.png (193 KB, 680x622) Image search: [Google]
1429938650777.png
193 KB, 680x622
>>54692030
Wouldn't I just use atoi? Seems like an easy feat. Thanks for the suggestion though.
>>
>>54692109
for whom?
>>
float *foo = fizz;
float *bar = buzz;

const unsigned int diff = foo - bar;

unsigned int piss = diff - 4U; // works fine
unsigned int shit = foo - bar - 4U; // fucks up


what's going on here?
>>
>>54692182
>realize my mess up instantly after submitting the post
nvm i'm retarded
>>
>>54692182
does that crash?
>>
>>54691813
Could be system level limit of open file handles, or other system resource limit that you're crossing.
>>
>>54692182
>I just don't know
>>
File: 3.jpg (107 KB, 960x1280) Image search: [Google]
3.jpg
107 KB, 960x1280
>>
>>54692299
>mental illenss
>>
>>54691813
have you tried not reading the whole thing into memory?
for fileName in glob.glob(data_path + '/*.gz'):
with (gzip.GzipFile(fileName, 'rb') as record_stream, \
open(fileName.replace('.gz', '.txt'), 'wb') as write_stream):
while True:
chunk = record_stream.read(65536)
if not chunk:
break
write_stream.write(chunk)
>>
>>54692299
Fuck off this isn't /bst/.
>>
>>54692261
Any idea where to start looking to work around this? I'm using Ubuntu 14
>>
>>54692203
>>54692290
never mind i was incrementing foo after diff = foo - bar
>>
>>54692334
I assume the problem lies within glob that stores a gigantic list of paths, I could be wrong, but try using os.walk() which is a generator, something like this:
data = None
for root, _, name in os.walk(data_path):
path = os.path.join(root, name)

with gzip.GzipFile(path, 'rb') as r:
data = r.read()

with open(path.replace('.gz', '.txt'), 'wb+') as w:
w.write(data)


The caveat here is that the data_path will have to contain only the .gz files because you can't match just the .gz extension with os.walk() unless you add some extra check within the loop.
>>
>>54692327

I'll give this a shot now.

>>54692358

I'm outputting the txt to the same directory so i will add the check if the above doesn't pan out.

Thanks, Anons.
>>
>>54692327
>>54692388
get rid of the parentheses in the with statement, left them there by accident and it turns out they actually cause syntax error
>>
>>54692421
Didn't copy and paste your code and ended up omitting them anyway
>>
File: programming powerlevels.jpg (473 KB, 1400x1341) Image search: [Google]
programming powerlevels.jpg
473 KB, 1400x1341
why did no one tell me SICP was comfy?
>>
>>54692613
I did. You didn't listen.
>>
>>54692327

looks like you nailed it; there is a file that was downloaded as "miscellaneous" shit and is 3.5 gb - thanks Anon!
>>
File: so sorry.png (750 KB, 603x480) Image search: [Google]
so sorry.png
750 KB, 603x480
>>54692763
>>
File: 1452620651296.jpg (30 KB, 500x386) Image search: [Google]
1452620651296.jpg
30 KB, 500x386
    @Override
public void keyPressed(KeyEvent ke){
switch(ke.getKeyCode()){
case KeyEvent.VK_LEFT: left = true; break;
case KeyEvent.VK_RIGHT: right = true; break;
}
}

@Override
public void keyReleased(KeyEvent ke){
switch(ke.getKeyCode()){
case KeyEvent.VK_LEFT: left = false; break;
case KeyEvent.VK_RIGHT: right = false; break;
}
}

@Override
public void keyTyped(KeyEvent ke){
if(ke.getKeyChar()==' ')
player.shoot(bullets);
}


i made a crude space invaders mini game and for some reason the player will not move or shoot can anyone figure it out im stuck. Also im made it in java and ive noticed that the KeyEvent and KeyListener on the imports and method are glowing blue like they should.
>>
>>54692833
I'm the guy who made this is mean to say the KeyEvent and listener are NOT glowing blue.
>>
>>54692613
>indian
>Blond hair
Prajeet, some dreams never come true
>>
>>54692865
Notice the blue eyes too, I think it's the same meme as Argentina people being white.
>>
File: Clippy.png (124 KB, 362x335) Image search: [Google]
Clippy.png
124 KB, 362x335
I want to make a little desktop helper like clippy for fun. I've only programmed in java and c++, and have only programmed stuff taught in intro classes (data structures, basic algorithms, etc).
Kind of a big questiom, but where do I start?
>>
>>54693001
Windows, Mac, or Linux? All three?
>>
>>54693001
What exactly do you want it to do? Clippy and friends were integrated into a certain application, and noticed when you were doing something specific, etc. Do you want that? Or do you just want a generic 'assistant' that you can do something with? What would it do? Do you type commands to it, pick options from a menu, etc?

Anyway, if you use C++, you can use SFML or SDL for graphics. If you use Java, then libGDX is a good, easy choice. You'll probably want to learn how to use whatever graphics library you're going to use before starting your project.
>>
>>54693032
I think it would be really cool to make it available on all platforms, but I would be making it on a linux distro.
>>
>>54693001
create decorless window, place some shitty bitmap in the middle, set always on top flag, react to click events
>>
>>54691947
And what about the implications of polymorphism and encapsulation that are absent in composition?
>>
File: argentina is white 3.png (461 KB, 1168x794) Image search: [Google]
argentina is white 3.png
461 KB, 1168x794
>>54692942
>>
File: Tumblr_mkbj3tw2nu1s92zk7o1_500.jpg (89 KB, 434x575) Image search: [Google]
Tumblr_mkbj3tw2nu1s92zk7o1_500.jpg
89 KB, 434x575
Trying to make a python script which will run through atoms and can give the masses depending on the atom specified, later will be doing molecules.

names=["H","He","Li","Be"]
masses=[1.008,4.003,6.941,9.012]

Dict2={}

for i in range(names):
Dict2[names[i]]=masses[i]
print Dict2
print Dict2["He"]
print Dict2["Li"]


When I run this, I get a run error:

for i in range(names):
TypeError: range() integer end argument expected, got list.


Anyone help?
>>
>>54693066
As of now, all I have thought of is being able to ask it questions via typing that would redirect you to whatever browser/search engine and then have it say/do stupid reactions based off of what you load/do. Functionally it wont be of any real use, I just want a desktop buddy and work on something I think is fun.

I'll learn more about those graphics libraries, thanks.
>>
>>54693116

hey, you can wrap stuff in code tag here so people can read it better:

names=["H","He","Li","Be"]
masses=[1.008,4.003,6.941,9.012]

Dict2={}

for i in range(names):
Dict2[names[i]]=masses[i]
print Dict2
print Dict2["He"]
print Dict2["Li"]
>>
>>54693116
for i in range(names)

That doesn't make any sense. You want to use
len(names)
to get the size of a list.
>>
>>54693116
Why don't you just write the dictionary literal? There is zero point to this.
>>
>>54693106
>Spanish
>Italian
>White
lolno.
>>
>>54693153
>Ask it questions
This is a bit more involved than you may think, but I know there are NLP libraries for Python. You could do your backend in Python and your frontend in Java/C++ I suppose. It's really easy to open browser tabs etc and look things up in Python. Perhaps you could do "Find a grocery store" and it opens up a google maps search for "grocery store" or something.
>>
>>54693169
 for i in range(names.__len__())
>>
>>54693116
first of all, use the code tags, they're here for a reason


>for i in range(names):
names is a list, range takes an integer as a parameter, so you need to use range(len(names))


also, you can just do
Dict2 = dict(zip(names, masses))
>>
>>54692613
What is that R logo below the R logo?
>>
>>54693199
autism
use range(len(names))
Python is such shit.
>>
>>54693208
As stupid as your question is: Rust.
>>
>>54693091
>>54693192
Thanks, guys.
>>
>>54693116
range(len(names))
>>
>>54693208
Rust
>>
>>54693211
 print "__no__(self)" 
>>
File: fug.jpg (65 KB, 720x960) Image search: [Google]
fug.jpg
65 KB, 720x960
>>54693163
>>54693169
>>54693180
>>54693199
>>54693202
>>54693211
>>54693219

oh fug my apologies, didn't know the code tag was an actual text command like spoiler. what is the text for it?
>>
>>54693255


>
>{{}{}{{}{}{}
>
>>
>>54693255
[code ] [/ code]
>>
>>54693216
>>54693228
Thanks
>>
File: 1.png (23 KB, 561x570) Image search: [Google]
1.png
23 KB, 561x570
>>54693255

like this

>>
>>54693270
well FUCK

>>54693274
what this Anon said.
>>
Pleb here who only knows Matlab and a little C++. What would be the best book for me to learn me some Fortran? Also what ide and what compiler?
Thinking about using code blocks but I'm open to suggestions
>>
>>54690291
emulator for shits and gigs
>>
File: 8bit.png (43 KB, 897x994) Image search: [Google]
8bit.png
43 KB, 897x994
>>54693375
>>
>>54693375
>>54693388
Now make it play Game of Life
>>
>>54693388
wat dat
>>
I'm looking to instantiate Python objects from a string and I'm not sure of the best way to do it. Basically, my idea is to have the user supply strings representing posts from boorus and instantiate them so I can do work with them afterwards, so "d123" would create Danbooru(123). Is there any good way to do this dynamically, or do I just need to parse the string and instantiate an object manually?
>>
>>54693526
you could use eval somehow I guess
>>
>>54693367
Hello scientist. What's the point of writing a hella fast number crunching backend if other people have done it for you/you can pay people to do it for you with that grant?

Besides writing optimized code is hard and requires an intimate knowledge of computers. Start with assembly.
>>
>>54693417
An emulator. the top is the instructions being executed, along with some debug stuff. The bottom being the result of the instructions.
>>
>>54693555
neat, thanks.
>>
How do I make methods in C? I tried looking it up but I can't figure it out.

struct Class {
double velocity;
double initialPosition;
int color;

void setColor(int c) {
color = c;
}
};

int main() {
struct Class car;

car.setColor(2);

return 0;
}

It gives me this error:
car.c:6:23: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘{’ token
void setColor(int c) {
^
car.c: In function ‘main’:
car.c:14:5: error: ‘struct Class’ has no member named ‘setColor’; did you mean ‘color’?
car.setColor(2);

Obviously setColor is in car...
>>
File: code kidz.png (7 KB, 230x81) Image search: [Google]
code kidz.png
7 KB, 230x81
coder here, AMA
>>
>>54693645
Function pointers
>>
>>54693645
>How do I make methods in C?
You can't. Structs are just data.
You can emulate method calls using function pointers, but it's really not worth it.
>>
>>54693649
how do you make the facebook?
>>
>>54693645
struct Animal_Vtable{
typedef void (*Walk_Fun)(struct Animal *a_This);
typedef struct Animal * (*Dtor_Fun)(struct Animal *a_This);

Walk_Fun Walk;
Dtor_Fun Dtor;
};

struct Animal{
Animal_Vtable vtable;

char *Name;
};

struct Dog{
Animal_Vtable vtable;

char *Name; // Mirror member variables for easy access
char *Type;
};

void Animal_Walk(struct Animal *a_This){
printf("Animal (%s) walking\n", a_This->Name);
}

struct Animal* Animal_Dtor(struct Animal *a_This){
printf("animal::dtor\n");
return a_This;
}

Animal *Animal_Alloc(){
return (Animal*)malloc(sizeof(Animal));
}

Animal *Animal_New(Animal *a_Animal){
a_Animal->vtable.Walk = Animal_Walk;
a_Animal->vtable.Dtor = Animal_Dtor;
a_Animal->Name = "Anonymous";
return a_Animal;
}

void Animal_Free(Animal *a_This){
a_This->vtable.Dtor(a_This);

free(a_This);
}

void Dog_Walk(struct Dog *a_This){
printf("Dog walking %s (%s)\n", a_This->Type, a_This->Name);
}

Dog* Dog_Dtor(struct Dog *a_This){
// Explicit call to parent destructor
Animal_Dtor((Animal*)a_This);

printf("dog::dtor\n");

return a_This;
}

Dog *Dog_Alloc(){
return (Dog*)malloc(sizeof(Dog));
}

Dog *Dog_New(Dog *a_Dog){
// Explict call to parent constructor
Animal_New((Animal*)a_Dog);

a_Dog->Type = "Dog type";
a_Dog->vtable.Walk = (Animal_Vtable::Walk_Fun) Dog_Walk;
a_Dog->vtable.Dtor = (Animal_Vtable::Dtor_Fun) Dog_Dtor;

return a_Dog;
}

int main(int argc, char **argv){
/*
Base class:

Animal *a_Animal = Animal_New(Animal_Alloc());
*/
Animal *a_Animal = (Animal*)Dog_New(Dog_Alloc());

a_Animal->vtable.Walk(a_Animal);

Animal_Free(a_Animal);
}
>>
>>54693645
You can't, that's why C++ exists. You don't need to either, you can always do something like
typedef struct
{
// whatever
} class_t;

void ( class_t *object, ... )
{
object->... = ...;
// etc
}

Not quite as elegant as classes, but it does the job.
>>
>>54693709
>(Animal_Vtable::Walk_Fun)
>>
>>54693541
Civil engineering student wanting to go into earthquake engineering in the future and it seems like a lot of books on the subject assume knowledge on Fortran. Also seems like most earthquake engineers have Fortran on their CVs along with Matlab.
>>
>>54693707
do the needful
>>
>>54693678
>You can emulate method calls using function pointers, but it's really not worth it.

Sure. The proper idiom is to just do type_DoThing(type *this).
>>
>>54693778
this
>>
>>54693758
Oh that's because science and engineering has used primarily FORTRAN until recently. I wouldn't be concerned about it though. If you need to learn FORTRAN for a job or school, you will learn it then. Most people pick up specific little things like what particular software to use on the job.
>>
 
(define (helloWorld) (display "hello world"))


THIS is podracing

also what reasons can i give to why i'm teaching myself lisp other than the truthful one which is to feel superior?
>>
should you break or continue in this situation? I want to skip checking the rest of the lines (so break the highest-level for loop, not the whole while statement)

or are they the same thing?
>>
File: Capture.png (6 KB, 363x168) Image search: [Google]
Capture.png
6 KB, 363x168
>>54693848
forgot pic
>>
>>54693866
You should not be nesting that many for loops
>>
>>54693837
jobs, clojure has some
haskell is better if you don't care about getting a job
>>
>>54693837
Scheming is F U N.

Scheme is beautiful.
>>
>>54693883
Basically this. Abstract the function of at least the primary for loop into a new function. That way, when you get to i == 8, you can just say return and that will return control to the while statement. Also, I have no idea why you're using while(True), since that's usually a code smell, unless you're writing a daemon or something.
>>
>>54693866
When it's nested like that, I think you only break out of the outermost loop. Some languages like Swift allow you to label your loops, so that you can break out of a higher loop, but I guess for your case you would need a signal variable after you break.
>>
>>54693883
why not?
I don't know any alternatives

    <post name="59765995">
<line>>Honest question: How important is height to a girl?</line>
<line>>I'm 190cm/6'2 so just wondering if I should be slaying pussy</line>
<line>>It's fairly important to me</line>
<line>HAHAHAHA THANK YOU AISHA YOU BABE</line>
</post>
<post name="59765997">
<line>Tzuyu</line>
</post>
>>
>>54693915
I think I once did something like that with a combination of map and reduce.
>>
>>54693837

LISP is one of those things where you realize we knew about useful abstraction 110 years ago, but nobody really realized how good it was until we were inundated with shitty 2/3GL languages.

It's refreshing, like an ice-cold glass of lemonade on a hot summer day.
>>
>>54693908
the while(True) actually goes around the whole process, I just moved it down so it was visible
the program is essentially a thread updater, so you never need to actually close that loop
>>
>>54693938
>>54693915
Maps and filters be the way to go. Consider S-expressions over xml too because then you can have a more intimate relationship with the data.
>>
http://pages.cs.wisc.edu/~solomon/cs537.html
>OS dev
>In Java
Absolute madmen
>>
>>54693947
why can't we have a lisp clone with c syntax?

explain why.
>>
>>54693958
No, you would have a while(threadIsAlive) instead of while true.
>>
>>54693947
Perhaps you may know about this
Lisps are old as heck, but high level as heck. Are they not 4GLs?
>>
I want to print files on Qt but i don't find a single way of doing so

I can only print QStrings QImages
is it possible to print files? Like picking a file and then printing it? What if i export files and then print a PDF through Qt?

I'm on wangblows how do i go about this? Any tool that will export pdfs
>>
>>54693947
no, it's that the performance back then was really bad and only now it is good enough
>>
 
1 ]=> (define (fizzcheck x) (if (= (modulo x 3) 0) (display "fizz") (display x)))

;Value: fizzcheck

1 ]=> (fizzcheck 2)
2
;Unspecified return value

1 ]=> (fizzcheck 3)
fizz
;Unspecified return value

1 ]=> (define (buzzcheck x) (if (= (modulo x 5) 0) (display "buzz") (display x)))

;Value: buzzcheck

1 ]=> (buzzcheck 15)
buzz
;Unspecified return value

1 ]=> (buzzcheck 14)
14
;Unspecified return value

1 ]=> (define (fizzbuzzLoop x) ((fizzcheck x) (buzzcheck x) (display " ") (if (< x 101) (fizzbuzzLoop (+ x 1)) (display "."))))

;Value: fizzbuzzloop

1 ]=> (define (fizzbuzz) (fizzbuzzLoop 1))

;Value: fizzbuzz

1 ]=> (fizzbuzz)
. 101101
;The object #!unspecific is not applicable.
;To continue, call RESTART with an option number:
; (RESTART 2) => Specify a procedure to use in its place.
; (RESTART 1) => Return to read-eval-print level 1.

2 error>


well that was pretty disappointing
>>
>>54694026
>a literal embodiment of the "/dpt/ can only fizzbuzz in 900 languages" meme
kill yourself
>>
>>54694053
kys
>>
>>54693947
Lisp has no abstraction at all. Macros can distinguish between code written with if and the equivalent written with cond. Researchers abandoned Lisp because they wanted abstraction.
>>
>>54694053
kys
>>
>>54693984
It's called python.

And removing the syntax means the magic is lost.

>>54694026
Brotips: install and use rlwrap if you aren't already. Use chicken or guile instead of MIT. If you use chicken you turn on the full numeric tower with
(use numbers)
>>
>>54694096
>It's called python.
>>c syntax
>>
>>54694026
((fizzcheck x) ...

Nigga that's a procedure application and fizzcheck returns nothing. Do you mean
(begin (fizzcheck) ....
?
>>
>>54694129
i don't know what those words mean. i intended it to fizzcheck x as in print fizz if x%3=0, then buzzcheck as in do the same with 5, and then if x is less than 100 run fizzbuzzloop again incremented by 1. and now i realize that it will be doing fizz3 instead of fizz but still i want to get my wrong implementation working. installed guile and i dont see how its any different from mit scheme
>>
>>54693837
>other than the truthful one which is to feel superior?
Lisp dialects were taught in CS 101 for a long time, so knowing Lisp only means that you're on the level of someone who took a few CS 101 classes.

If you want to be a better programmer, you should learn about algorithms and data structures, not languages.
>>
>>54694014

There were lisp machines, duderino.
>>
>>54693984
the fuck? lisp is almost nothing but the syntax
>>
File: poo 2 loo starwars.jpg (304 KB, 574x1299) Image search: [Google]
poo 2 loo starwars.jpg
304 KB, 574x1299
>>54694202
spotted the java baby
>>
File: [tilting increases].png (27 KB, 500x500) Image search: [Google]
[tilting increases].png
27 KB, 500x500
>>54694202
this

>>54694212
stay delusional
>>
>>54694210
completely wrong. lisp has an extremely uniform syntax with a handful of exceptions that stray from the common form like "if". you obviously don't know what you're talking about and just felt like opining
>>
File: poo 2 loo.jpg (75 KB, 1024x526) Image search: [Google]
poo 2 loo.jpg
75 KB, 1024x526
>>54694222
>defending java and c# this hard
>>
>>54694014
>>54694209
Lisp machines were slower for running Lisp than a 1987 PC or Mac.

>Later desktop computers built by Apple and IBM would also offer a simpler and more popular architecture to run LISP applications on. By 1987 they had become more powerful than the more expensive Lisp machines. The desktop computers had rule-based engines such as CLIPS available.[28] These alternatives left consumers with no reason to buy an expensive machine specialized for running LISP. An entire industry worth half a billion dollars was replaced in a single year.[29]
>>
>>54694231
i said the syntax is what makes lisp, lisp. if you have a different syntax, it's not really lisp any more. please explain how you would make a lisp with C syntax.
>>
>>54694176
Procedure application is anything that isn't a special form like define, cond, if that happens with parentheses.
(+ 2 4)
is applying 2 and 4 the value of the symbol + (a procedure).
((lambda (x) (+ x x)) 2)
is applying 2 to the value of the expression
(lambda (x) (+ x x))
, a procedure which takes one argument.

Your code is trying to apply the rest of the stuff after (fizzcheck x) to the return value of (fizzcheck x). (begin ...) starts a block where the items are evaluated sequentially and the last item is returned.
 (begin 1 2 3 "GO!")
returns "GO!"
>>
>>54694257
oh yeah you right family
>>
>>54694271
ok, so i do (begin (first task) (second task) (etc)) like that?
>>
/homework/

so lets say we have an array

{5,4,2,1,3}


and using two different algorithms, Median and BruteForceMedian (implentation already done and not relevant), I need to measure the execution time and number of basic operations for both.

Specifically you are required to test both algorithms with the same data. Not only must you test both algorithms with the same arrays of data (same size and same elements) you must use the same instance of the input data. 


This is in C++. My question is, how do you use the same instance of an array when the algorithms modify it?

Do I need to be looking into pointers or something? I get OOP but trying to do this in C++ isn't clicking with me.
>>
>>54694330
you wut
just pass a copy of the array to the argument

im sure you can measure execution time, but for number of basic operations, does that mean you have to count by hand?

Or maybe check the asm output from the compiler?
>>
>>54694245

I'm not sure what you're trying to get at. Computers were, in general, slow.

Home computers got incredibly fast of the course of a few years.
>>
>>54694242
Jesus god. I see what's wrong with Yankees and south Americans now though. They're getting blasted with India's poo.

>>54694330
You don't write algorithms that modify it. your implementations of median and bruteforcemedian have to generate a copy at each iteration rather than modify at each iteration. Have fun sounds like your professor is a smug functional programming weenie.
>>
>>54694242
you're not special for using a lang like lisp or haskell, anyone could learn those languages if they wanted to
>>
i want my program to count the pages in a file to print them out however it can't read files like docxs and excel etc so i was thinking about converting the files to pdf and then it can process them,

I'm on windows is there any command line tool to convert files to pdf?
>>
>>54694363

If we could pass a copy they wouldn't have said what they said.

>Not only must you test both algorithms with the same arrays of data (same size and same elements) you must use the same instance of the input data.

int []a = {1,2,3}
int []b = {1,2,3}

is not allowed according to the specifications.

>>54694370

>You don't write algorithms that modify it.

The arrays were given in pseudocode and we're not allowed to change them. They MUST modify the arrays.
>>
>>54694386
>I can't read files like docx and excel
Aren't they open source formats? I know docx and xlsx are. Look it up. I'm sure you can count sheets in an xlsx, not sure about pages in a docx.
>>
>>54694330
>>54694412
your professor is retarded if what you're saying is true
>>
>>54690291
i'm writing a cross-platform email client because i cannot stand what currently exists.
>>
>>54690291
o shit it's that boiii
>>
>>54694412
Unless you find a clever way to break cache coherency with assembly bullshit it's impossible then.
>>
>>54694412
same arrays imply there are more than 1
just email him
>>
>>54694412
>>54694438


edit: scratch that...

bruteforce doesn't modify, median does.

I'll just run the tests on bruteforce first then do median.

>>54694449

yeah they are just retards at wording shit.
>>
File: steroid progress fit poo.jpg (71 KB, 1011x818) Image search: [Google]
steroid progress fit poo.jpg
71 KB, 1011x818
>>54694380
>>
>>54694503
kys
>>
File: poo to loo 3 revelations.jpg (151 KB, 780x848) Image search: [Google]
poo to loo 3 revelations.jpg
151 KB, 780x848
>>54694526
>telling people who don't use java to kill themselves
>>
>>54694537
>he's a smug lisp weenie
lol fag
>>
>>54694557
i'm not going to continue but imagine i reply to every post you make with a picture relating to indians
>>
>>54694599
>i'm not going to continue but imagine i act like an obsessive retard with nothing useful to say
>>
>>54694619
>anyone who doesn't use java or C# is an obsessive retard
>>
>>54694660
>Lisp dialects were taught in CS 101 for a long time, so knowing Lisp only means that you're on the level of someone who took a few CS 101 classes.

>If you want to be a better programmer, you should learn about algorithms and data structures, not languages.

you got rekt delusional lisp fag
>>
>>54694688
>i-it's not too hard for me to get, i just like j-java! it's not that i don't get it, i swear i do! i swear MOTHER FUCKER SON OF BITCH FUUUUU I FUCK UR MOTHER BASTURD!!!!
>>
>>54692853
late but assuming you mean glowing blue like in eclipse, you've probably forgotten to import the class correctly
>>
>>54694688
>he thinks lisp isn't cool because, god forbid, normies touched it
You don't really like CS. Go back to >>>/r9k/
>>
>>54690291
Oh shit whaddup
>>
>>54694702
>babby's first cs101 lang is hard to understand
delusional as fuck
>>
How complex can a regular program in C++ get?
Like how long and how many pages.
>>
>>54695124
>pages
>>
>>54695124
millions of lines of code
>>
>>54695261
You know what I mean

>>54695270
So is a regular program like a month of work or what
>>
>>54690943

>How do you develop on Windows
Personally...

MinGW-w64 / Git Bash (although I've heard MSYS2 is a bit better)
Sublime Text

And that's it. Sometimes I use Powershell for a few things, but otherwise, just GCC/Make/Bash/Sublime.
>>
>>54695304
depends on the program, a hobbyist program/library with around 1-10 thousand lines of code might be a few weeks or a few months, a big program could be in development by dozens or hundreds of programmers for years or decades
>>
>>54695304
A "regular" program is very vague. Say you did 80 lines in 30 days, that would be 2.4K lines. 1 mil would be 33K lines per day. This is assuming one developer.
>>
File: 1463548041188.jpg (40 KB, 960x960) Image search: [Google]
1463548041188.jpg
40 KB, 960x960
how the fuck do i get the determinant in a NxN matrix? i've been trying all day to make it work and destroyed my code multiple times without any result
>>
>>54695490
https://en.wikipedia.org/wiki/Determinant
>>
>>54695502
i know about those but formulas like Laplace and cramer are to complex for a simple code, when i did it with cramer i had 2000+ cycles in 50 lines
>>
>>54695525
Wow a complex operation has a complex solution. Who would have thought.
>>
>>54695490
import determinant
>>
>>54695525
Look at the process to calculate determinants at the top. It's recursive, and it seems like it calculates the same thing over and over, like recursive fibonacci. You might be able to simplify it there.
>>
File: mill.jpg (16 KB, 500x375) Image search: [Google]
mill.jpg
16 KB, 500x375
imagine being so insecure and desperate to feel superior to somebody, ANYBODY that you shit on a useful language used by millions worldwide the second it's mentioned
>>
>>54695694
don't even try to defend java
>>
>>54695635
nah, like in the example at the top with the 3x3 matrix, there are no duplicate expressions

>aei + bfg + cdh - ceg - bdi - afh
>>
>>54695694
>>54695719
>I LOVE C
>DO YOU EVEN KNOW FIZZBUZZ?
>PAJEET
>PAJEET
>PAJEET
>>
>>54695525
Permutations, parity of the permutation, some sums. The laplace looks non-trivial but not impossible.
>>
>>54695741
When you're calculating the 3X3 expressions for a 4x4 there should be repetition in the 2X2 matrices.
>>
>>54695748
t. a java user
>>
guys! guys! guys!
the next .io hit is just around the corner, its in the testing phase.
you construct your own contraption, ski, fly, roll, whatever, with multiplayer, free for all kill, webGL so anyone can play in any browser and it's 3D so no more 2D view locked shit
>>
>>54695748
Go home, pajeet.
>>
>>54695741
It's about duplicate calls though. A matrix might have duplicate minors, so you implement memoization in your determinate function.
>>
>>54690291
[code/# Print each in line
line4 = '\n'.join(youtube_results)[/code]

This code prints out each of the strings in youtube_results in a new line. Is there anyway to make it print out numbered? like 1,2,3 and so on...
I cant use a loop for this
>>
>>54695775
>PAJEET
>>
Can anyone give me some on how to improve this code? It's a simple settings thing for a bot I'm working on. My goal is just to make it easy to add new entries and ensure that they're formatted properly and contain the right data. Is there anything obvious that any of you would improve?

settings = dict(
defaults = dict(
prune_mode = 'disabled',
scrape_from_sources = True,
scrape_from_search = False,
# sleep settings:
unfollow_sleep_duration = 12,
consecutive_error_sleep_duration = 60
),
valid_options = dict(
prune_mode = ['first run', 'always', 'disabled'],
scrape_from_sources = bool,
scrape_from_search = bool,
unfollow_sleep_duration = int,
consecutive_error_sleep_duration = int
),
example_user = dict(
prune_mode = "bark",
consecutive_error_sleep_duration = 120
)
)

def error(user_setting, valid_options):
valid_type = type(valid_options)
if type(valid_options) is list:
valid_type = str
args = (user_setting, type(user_setting), valid_options, valid_type)
message = "Invalid setting: %s %s. Valid settings: %s %s" % args
raise ValueError(message)

for entry in settings:
if entry is 'valid_options':
continue
for s in settings[entry]:
valid_options = settings['valid_options'][s]
user_setting = settings[entry][s]
if type(valid_options) is type:
if type(user_setting) is not valid_options:
error(user_setting, valid_options)
continue
if user_setting not in valid_options:
error(user_setting, valid_options)
>>
>>54695773
>>>/vg/adgdgs
Thread replies: 255
Thread images: 34

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.