[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: 319
Thread images: 35

What are you working on, /g/?

Old thread: >>57997596
>>
>>58002840
You've got things the other way around here. It's not conceptually OOP at all. It's similar to how C++ compiles method calls (which are not particularly OOP either if they're not virtual and don't use encapsulation), but in no way, shape or form does that make that code object-oriented.
>>
File: .jpg (125KB, 800x720px) Image search: [Google]
.jpg
125KB, 800x720px
Can ANSI C using be justified nowadays?
>>
>>58002915
Yes.
>>
>>58002925
How?
>>
>>58002845
>>58002679
Uh, the X kinda seems to be 7 repeating values
The Y seems to be growing and then shrinking again in a non-linear manner

>>58002707
The function is 10x faster without Math.Pow

>>58002809
Function call overhead isn't the bottleneck

>>58002918
I'm already caching the results but I need to make the initial calculation faster
>also consider that x^y = b^(y*logb(x))
I have no idea how to write that in C#
Accuracy shouldn't be an issue though
The final result is stored as byte
>>
>>58002934
C ANSI is the only relevant C.
>>
File: 1463991037226.jpg (17KB, 480x480px) Image search: [Google]
1463991037226.jpg
17KB, 480x480px
>tfw using experimental C++17 features
>>
>>58002915
No. C was deprecated by Lisp back in the 50's.
>>
>>58002991
Never mind the fact that both GCC and Clang default to C11.
>>
>>58003009
I believe you mean GCC defaults to GNU11.
>>
>c++ library that does not export C api
Why is it even legal to distribute such shit?
>>
>>58002783
I don't know what's going on in your first block of code, but yes, that's how it works in C++. A member function has a hidden parameter called "this" that it uses to know what object it's working on.

So

class A 
{
public:

int x;
int y;

int total()
{
return x+y;
}

};

A a;
a.total();


Would look like this in C, at least I think, I don't really know C.

struct A
{
int x;
int y;
};

int total(A* a)
{
return a->x + a->y;
}

A a;
total(&a);
>>
File: Sad Barn Owl.gif (896KB, 500x750px) Image search: [Google]
Sad Barn Owl.gif
896KB, 500x750px
I'm trying to figure out how to modify XMP tags. I can turn the XML into something I can more easily work with (XEXPR's) and I can search through and find a tag, but I haven't the foggiest idea on how to replace parts of the XEXPR.
>>
>>58003009
I don't give a shit. I know how to fix that and use the only C standard.
>>
>>58002845
EVA would have been decent if shinji wasn't a fag that cried all the time
>>
>>58002984
I meant having precalculated values for log(x) in an array, maybe like 100, and some function that takes your x, lets say 0.4, and maps it to an index into that array, e.g. 40. then you get the value of log(0.4) from the array, multiply it by y and get a value p. now you have a second array with precalculated values for 2^p, and again get your value from there without the need for calculating anything. These arrays would either be filled during initialization of your program or better yet just in the sourcecode. I have used something similar for sin and cos and just wrote a shell script to print an array initialization that I could just copypaste into my code.
>>
>>58003072
a.total() and total(&a) are very different.
>>
>>58003093
I only watch anime starring real men who work out for fun and kill/rape people who disrespect them.

I'm a C programmer.
>>
Does anyone know any resources on motion compensation and estimation?
>>
>>58003165
>I'm a C programmer
No, you're a faggot. I only read gender bender manga with traps and identity swap.

I'm a Haskell programmer.
>>
>>58003145
Well, theres the v table and various C++ only features like static members. But that's still basically how methods work.
>>
File: 1480187072128.png (521B, 163x209px) Image search: [Google]
1480187072128.png
521B, 163x209px
show me your shittiest C project

you can link a github repo if you want
>>
>>58003222
>traps
>haskell
Boys can't be Girls.
>>
>>58003236
Wait 6 months and I'll link you the final project for my C class.
>>
if you would create an app for android devices wich sdk / version would you target?

im a .net guy , so tipically for me its either .net 4.6 or for uwp apps just windows 10.12XX build and it just werks in all devices, now im in charge of porting something to android and its giving a headache all the java skds and android versions.
>>
>>58003236
rate the usart code from my first project
#include "general.c"
inline void usartInit( unsigned int ubbr)
{
UBRRH = (unsigned char)(ubbr>>8);
UBRRL = (unsigned char)ubbr;
UCSRB = (1<<RXEN)|(1<<TXEN);
//frame format: 8data, 2stop bit, no parity
UCSRC = (1<<URSEL)|(0b11<<UCSZ0);
}
inline void usartSendChar( unsigned char data )
{
while ( !( UCSRA & (1<<UDRE)) );
UDR = data;
}
inline unsigned char usartGetChar( void )
{
while (!(UCSRA & (1<<RXC)));
return UDR;
}
void usartSend(void* dataPointer,unsigned char size)
{
char* data =(char*) dataPointer;
for(unsigned char i=0;i<size;i++)
usartSendChar(data[i]);
}
void usartGet(void* varPointer, unsigned char size)
{
char* var = (char*) varPointer;
for(unsigned char i=0;i<size;i++)
var[i]=usartGetChar();
}

>>
>>58003232
you are confusing how methods are implemented with how they work software engineering wise. what you described here >>58003072 is nothing else than a data type.
>>
so very beginner git question I've made a folder wrote all my code and now made the repo, I plan on git cloning the repo then dragging all my files from folder a to folder b is there a better way? if so what do I do or what should I look into?
>>
>>58003300
lol just realized that header's totally unnecessary
>>
>>58002845
Trying to figure out how this works. It's a 2D ragdoll that balances itself standing up only using joint torques. I think I've almost got it figured out but I don't want to start implementing it until I'm sure.

https://www.youtube.com/watch?v=tb-t4j9wt7E

It uses inverse kinematics to place the feet so they are equidistant from the center of mass which allows the body to balance over them. That's the basics but I'm trying to fill in the blanks.

I think when calculating the X positions to move the feet to it will always try to keep them as close together as possible, or pretty close some arbitrary number. (standing up straight) But there are joint limits so when it starts falling over, to maintain equal distance from the center of mass, one leg will cross over the other and possibly be forced to take a larger step if the other leg can't bend that far. Pretty sure that's all you have to do for the X positions.

The Y positions I'm not so sure. Pretty you simply extend the leg as far down in the Y direction while staying within the range of motion. Not entirely sure about that though. Anyone got any input?
>>
>>58003307
That's what the guy was asking about. How they're implemented.
>>
>>58003442
he didn't ask anything.

>>58002615
>>58002623
>>58002783
>>
I'm trying to compile and run C on Notepad++ using MinGW. I think I've managed to compile it, but it won't run anything i.e. it won't display "hello world" in console.
What do I need to do to get it to run the program?
>>
>>58003525
you need to call the executable generated by the compiler, by default it's named a.out (maybe something different on windows, just check with "dir" if there's a file that wasn't there before), so to run it just type ./a.out
>>
>>58003525
Install emacs first.
>>
File: JUST.png (49KB, 965x593px) Image search: [Google]
JUST.png
49KB, 965x593px
JUST
>>
>>58003565
sign in boi
>>
>>58003077
I suppose I'll ask on the Racket mailing list. Hopefully the PhD's and university professors that lurk there can give me some pointers.
>>
File: images.jpg (7KB, 243x208px) Image search: [Google]
images.jpg
7KB, 243x208px
>>58002845
>What are you working on, /g/?

Trying to implement a lock-free stack in C++. Hazard pointers are a bitch...
>>
File: FEyeN0M.png (94KB, 1126x710px) Image search: [Google]
FEyeN0M.png
94KB, 1126x710px
I'm trying to make a little menu game using a python menu library called urwid.

But as i'm programming i'm starting to write everything extremely streamlined, in a lack of better words.

THe first thing i do is jump into a series of functions that creates the main menu. From those functions, depending on what i chose. I jump into a different set of functions that creates a menu. Depending on what i chose there i jump into another function that creates another function. etc, etc.

I'm pretty sure that what i'm doing is going to fuck everything up as i go along. Functions calling new functions calling new functions is going to end up crashing. right?

Can someone give me an idea of how i should do this the smartest way?

Pic related is what i'm playing with looks like.
>>
>>58003695
>60 lines to make two buttons
jesus christ either use an engine or create it yourself
>>
>>58003735
Excuse me?
>>
>>58003582
>giving up your privacy and freedom
Might as well just take down the curtains and fap in front of the window for everyone to see.
>>
>>58003236
https://github.com/zmulsion/multiuser-chat

it's not a terrible mess, but it is broken

ok it might be a little bit of a mess
>>
>>58003735

maximum autism
>>
File: 5B6B88D7.jpg (2MB, 1920x1200px) Image search: [Google]
5B6B88D7.jpg
2MB, 1920x1200px
Does anyone know or have a program written in C relatively big around 500 lines that i can test?

basically i'm doing software fault injection and mine entire programs with bugs and then do data analysis about that , code coverage, etc..

thanks
>>
>>58003892
Go to Github and search for projects by language.
>>
>>58003695
RMGUI will always suck. For the state machine, have the states be functions, but don't call the next state directly, return it. This will prevent stack overflow, and make it easy to implement delimited continuations for interesting control flow.
>>
fuck cmake

i have a headache now
>>
>>58003935
>>58003892
Remember to pick a project by an indian.
>>
>>58003892
Sounds like mansplaining to me.
>>
File: language tans.png (919KB, 960x1440px) Image search: [Google]
language tans.png
919KB, 960x1440px
What's your favorite language?
>>
>>58003935
that's what i've been doing but i need programs that read from input like
./program < big_input.txt > output.txt


and it's hard to find. i've to do test-suites for them so a program like that would be better
>>
Anyone done CUDA coding?

I'm looking to learn a bit of it, but only have an 8600M GT to work with for now. Is CUDA 1.1 too old to be of any use in learning the basics?
>>
>>58003976
search for SPOJ or Project Euler on github
>>
>>58003972
>tfw my waifu is more than two times older than me
>>
What are some functions in java that you usually need to provide, but never write a function call for?
>>
>>58004190
mane
>>
>>58004225
..........
>>
Can I program a boyfriend who won't get upset over trivial, pointless shit?
>>
>>58004362
you spelled girlfriend wrong
>>
>>58004434
No, I didn't.
>>
>>58003241
Of course they can. What do you think MonadTrans is really used for?
>>
>>58004190
Pls answer.
>>
>>58004453
oh my bad i dont have my contacts in

AI Gfs who don't get upset over trivial pointless shit while also being realistic enough are only about 10 years off. unless you are experienced in C++ then you need not contribute all you have to do is wait, soon we will have perfected AI waifus
>>
>>58004487
You don't understand, I don't want a waifu, I want a husbando.
>>
>>58004487
>C++
>AI
>>
>>58004499
one that won't bitch and only gives you sex?
>>
>>58004516
And that will go out and work and give me his salary.
>>
>>58004514
I want to rape this bitch
>>
>>58004529
Hmm that last part is pretty tough. If communism kicks in fully then you can live on government welfare and get some random black dude to fuck then ignore you all day, but I predict their will be a population collapse before the automation revolution has time to cause wide scale unemployment.

So it's impossible. Sorry.
>>
So if I have separate scripts that get started or ignored when you run config.py would it make sense to put them in a folder called modules?
>>
File: 293931017.jpg (200KB, 704x480px) Image search: [Google]
293931017.jpg
200KB, 704x480px
Daily reminder that C++ is the only language that you will ever need to learn in your life, the rest is pure meme trash.
>>
what's the difference between java and java EE?
>>
Why wouldn't you use a language with an advanced type system?
>>
>>58004590
and javascript too :3
>>
>>58004612
Java is taught to high schoolers
Java EE is taught to pajEEts
>>
>>58004634
At this point no type system in a usable programming language seems advanced to me.
>>
>>58004635
Why not html too?
>>
>>58004590
And COBOL
>>
>>58004590
And PHP
>>
>>58002915
No. Not at all.
>>
File: vomit.jpg (90KB, 650x650px) Image search: [Google]
vomit.jpg
90KB, 650x650px
>>58004590
>C++
>>
>>58004659
To me, no language without an advanced type system seems usable.
>>
>>58004643
are the jews behind this?
>>
#include <stdio.h>
#include <stdbool.h>

int main(int whatever, char **fuck_you) {
for (int i = 1; i <= 100; ++i) {
bool printed = false;

if (i % 3 == 0) {
printf("Fuck");
printed = true;
}

if (i % 5 == 0) {
printf("Butt");
printed = true;
}

if (!printed) {
printf("%d", i);
}

printf("\n");
}

return 0;
}


Do I get the job?
>>
>>58004787
>inappropriate language
Don't call us, we'll call you
>>
will a class object made inside a function only be available inside that function?
>>
>>58004757

Fuck off Pajeet.
>>
>>58004803
Yes
>>
>>58004803
no
>>
>>58004803
You can return it.
>>
In writing a typical Java GUI, we often have to provide certain functions for which we will never, anywhere in our code, write a function call.

What are the most common examples of such functions?

CAN SOMEONE HELP WITH THIS QUESTION.
>>
>>58004803
if you want the object to be global for all the functions to use it without passing it as a parameter, you need to declare it within the class scope, but outside any function
>>
File: 1481539961641.jpg (17KB, 353x332px) Image search: [Google]
1481539961641.jpg
17KB, 353x332px
>>58004835
>>
>>58004838
Wanna give me an example?
>>
>>58002915

On platforms where a C11 compiler is not available, yes.

But there are not too many of those. I know Amiga is only supported by an old version of GCC (4.2 IIRC), but it should still at least support C99, which is still better than C89.
>>
...
}else{
...


or

...
}
else{
...
>>
>>58004787
what
>>
>>58004849
?????? you don't know either?
>>
>>58004856
if (...) {
...
} else {
...
}


Anything else is barbarism.
>>
Makefile question.

I have 3 files, foo.c, bar.h, bar.c, where foo includes bar.h and uses those funcitons.
When I type
gcc foo.c bar.c -o foo
it compiles as expected, but when I put the same in a make file it tells me I have an undefined reference to anything defined in bar.h.

Can someone just tell me exactly what to write to get it to compile with make. No generalization please, I didn't need that additional complexity yet.
>>
File: 1476192694539.jpg (42KB, 380x400px) Image search: [Google]
1476192694539.jpg
42KB, 380x400px
>>58004864
I dont understand your question
>>
>>58004856
...
}
else
{
...
>>
>>58004856
rateLanguage :: Language -> String
rateLangauge l
| isFunctional l = "Thank you for choosing a sensible language"
| otherwise = "Fuck off, Pajeet"
>>
>>58004874
What are common java functions, that are usually written, but never called?
>>
File: 1480978097736.jpg (96KB, 500x473px) Image search: [Google]
1480978097736.jpg
96KB, 500x473px
>>58004878
>>
>>58004884
Haskell has if-then-else, dumbass.
>>
File: 1473550131786.jpg (48KB, 500x375px) Image search: [Google]
1473550131786.jpg
48KB, 500x375px
>>58004890
why write something you dont use?
>>
>>58004893
guards are much nicer
>>
>>58004890
There is one method that every Java program implements but never calls.
>>
>>58004906
I mean that you dont write a function call to.
>>
>>58004907
That depends. I'd much rather write if-then-else than a case analysis outside of pattern matching.
>>
>>58004913
What is an example of one?
>>
>>58004918
I dont get it. if its unused delete it.
>>
>>58004933
Surely you can figure this out.
>>
>>58004949
fuck you faggot
>>
>>58004873

A basic Makefile should look like this:

CC = gcc

all: foo.o bar.o
$(CC) foo.o bar.o -o foo

foo.o: foo.c
$(CC) -c foo.c -o foo.o

bar.o: bar.c
$(CC) -c bar.c -o bar.o


Okay, a lot of this is redundant because Make has some default rules, but I'm explicit here to show what goes on here. You shouldn't need to define references to foo.h unless it's in a separate folder. If it is, you might use -I path/to/foo.h in the GCC arguments to tell it to look in an additional directory when searching for headers.
>>
how do you check for auxillary carry (half carry) when writing an emulator
>>
File: a6NVCsK.jpg (46KB, 1440x1232px) Image search: [Google]
a6NVCsK.jpg
46KB, 1440x1232px
Any takers?
>>
>>58004974

easy

just make them buy you matlab and then feed it their data
>>
>>58004974
Fifty dollarydoos?
>>
>>58004971

Ach, forgot to mention that in the dependencies for the .o files, you should put foo.h so that if foo.h is updated, you will recompile. So it might look like:

bar.o: bar.c foo.h
>>
>>58004974
>budget: 50 shekels
>>
>>58005008
>>58005001
that's a lot money stupid goy
>>
>>58005023
pajeets get out get out get out getout
>>
>>58004974

$50 is only really worth it for a job that takes maybe an hour or two at most. Otherwise, you're not getting paid developer wages.
>>
>>58005023
if you are some pajeet maybe. I take 3 times that an hour or I dont even need to bother
>>
>>58004974
That's hilarious.

>predict the stock market for fifty ameribucks.
>>
>>58005041
>>58005031
this is why nobody hires american programmers, stupid, arrogant and think they are too good, glad my h-1b1 is keeping one of you on food stamps
>>
>>58005055
here is an indian doing it 8 min

https://www.youtube.com/watch?v=SSu00IRRraY

lard asses btfo
>>
>>58005074
How much do you get paid?
You could be making 3 times that if you weren't a commodity slave product.
>>
>>58004803
If you allocated it on the heap you can give a pointer to it somewhere else. So if you're writing in Java or C#, and you typed "thing f = new thing();", no, you can return f
>>
>>58005104
Also hilarious.
>>
File: 4234234.png (257KB, 640x360px) Image search: [Google]
4234234.png
257KB, 640x360px
>>58005104
I seem to be getting spammed with his videos every time I visit youtube. Why is he so popular?
>>
>>58004971
It's not working. Fuck it, can't be bothered to waste any more time on this garbage.
>>
I want to write a tier chart maker, similar to mmcafe (www mmcafe com tiermaker)

what language should I use?
>>
Yet another (You) Counter.

// ==UserScript==
// @name 4chan (You) Counter
// @license GPLv3+
// @version 1.1
// @include *://boards.4chan.org/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @grant GM_addStyle
// ==/UserScript==

function checkYouCount() {
// Couldn't find a solution to exclude own replies, so let's just count all (You)s on the page.
var match = $(document.body).text().match(/\(You\)/gi);
var youCount = match ? match.length : 0;
var youCountResult = '';

switch (youCount) {
case 0:
youCountResult = 'No (You)s found.'
break;
case 1:
youCountResult = 'You got one (You).'
break;
default:
youCountResult = 'You got ' + youCount + ' (You)s.'
break;
}

$("#youCounter").text(youCountResult);
}

var youCheckTimer = setInterval(checkYouCount, 5000);

GM_addStyle(" \
#youCounter { \
background: #111 !important; \
border: 1px solid #000 !important; \
box-shadow: 4px 4px 3px rgba(0, 0, 0, 0.3) !important; \
color: #ddd !important; \
position: fixed !important; \
bottom: 15px !important; \
right: 15px !important; \
padding: 5px !important; \
width: 150px !important; \
text-align: center !important; \
text-shadow: 0px 2px 3px #555 !important; \
z-index: 1 !important; \
} \
");

$("body").append('<div id="youCounter"></div>');
>>
>>58004974
what website is that senpai?
>>
>>58005643
m8...
>>
>>58005670
oh shit lmao
my bad
>>
>>58005387
it shouldn't count the counters (You), do this

    var youCount   = match ? (match.length -1) : 0;

simple math, fagget
>>
>>58004835
paintComponent? If your using swing for java gui. You never explicitly call it, java calls it for you automatically.
>>
File: help.png (18KB, 680x153px) Image search: [Google]
help.png
18KB, 680x153px
I've been looking into learning one of the ML languages, and I can't for the life of me figure out what the hell syntactic forms like
type blah = bleh of int | bluh of float * float

mean. Due to the search engines treat "*" and "of", I can't find anything when I look it up either.
>>
>>58005976
It's an ADT declaration
The equivalent Haskell:
data Blah = Bleh Int | Bluh Float Float

(alt. Bluh (Float, Float))

It means the type Blah has two forms:
Bleh, consisting of an int
Bluh, consisting of two floats

For instance, a bool would be
data Bool = True | False


| can be thought of as "or", while * is "and"
>blah is (=) a bleh (an int) OR (|) a bluh (a float and a float)
>>
What are the meme JavaScript frameworks I should be aware of?
>>
>>58006057
Thank you so much for clearing this up for me anon, I appreciate it.
>>
>>58005976
>>58006057
This is one of those times when I'm really glad Haskell came along and updated the de facto default functional language syntax.
>>
>>58006065
angular
>>
>>58006068
If it helps
a * b * c * d
is like a struct
a | b | c | d
is like a tagged union
>>
this is my folder structure
--- main.c
--- inputs\
------- 1.txt
------- 2.txt
------- 3.txt
------- 4.txt


i want to run the c program , main.c and write to an output folder the results so that in the end i end up with
--- main.c
--- inputs\
------- 1.txt
------- 2.txt
------- 3.txt
------- 4.txt
--- outputs
------- output1.txt
------- output2.txt
------- output3.txt
------- output4.txt


is there a sh script for this?
>>
>>58006287
Is the output from the program written to stdout? If so, you can redirect output in bash using the '>' operator.

Example assuming program is a hello world:
./program > outputs/output.txt
>>
>>58006350
>>58006287
nvm fixed
>>
>>58006384
nigger
>>
>>58005104
An indian nu-male

Never thought I'd see this...
>>
>>58006514
Pajeets are even copying numales now.
>>
File: 1374208274970.jpg (30KB, 355x266px) Image search: [Google]
1374208274970.jpg
30KB, 355x266px
>>58005104
https://www.youtube.com/watch?v=bHSDYa95mMo
>>
>>58006287
for f in inputs/*; do ./myprog "$f" "outputs/output"$(basename "$f"); done

Or using shell directions, however your program is called.
>>
File: out.png (2KB, 190x159px) Image search: [Google]
out.png
2KB, 190x159px
what interesting things would you like to know about a program?
i have:
- code coverage
- number of bugs
...

what should i had?
>>
>>58006672
i went with
for i in $(seq 1 4); do ./main inputs/$i.txt > outputs/$i.txt; done
>>
>>58006683
Documentation, pls
>>
>>58006731
yeah i have that

but i was talking about some kind of statistics people would like to know about the program
>>
What's the coolest, shortest program you've seen? Something with a high cool to length ratio.
>>
>>58006756
uh, if it's build passes at the present time?
or maybe, the time it takes to do stuff?
>>
File: tty.gif (6KB, 615x440px) Image search: [Google]
tty.gif
6KB, 615x440px
>>58006790
this is pretty good i guess. the gif is the output
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>

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

const char *s = "-\\|/";
int p = 1, i = 0, j, d;

puts("Hacking in progress:");
while (p <= 100) {
printf("\r%c %%%-3u [", s[++i % 4], p);

for (j = 0; j < 50; ++j)
printf((j < p >> 1) ? "=" : " ");
printf("]");

fflush(stdout);
usleep(100000);

d = rand() % 5;
p = (p < 100 && p + d > 100) ? 100 : p+d;
}
puts("");

return 0;
}
>>
>>58006790
programming isn't cool
>>
>>58006837
thats cool man
>>
>>58006790
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
>>
>>58006790
 (define Z 
(lambda (f)
((lambda (x) (f (lambda (y) ((x x) y))))
(lambda (x) (f (lambda (y) ((x x) y)))))))
>>
>>58006880
f = 0:scanl(+)1f
>>
File: tfw too intelligent.png (108KB, 357x368px) Image search: [Google]
tfw too intelligent.png
108KB, 357x368px
>>58002845
>tfw to stupid for code academy python
should i just give up?
>>
>>58006905
>too stupid for a language for stupid people
>>
>>58006905
maybe read zed's book where he tells you what keys to press
>>
>>58006899
nice
>>
>>58003972
JavaScript
>>
>>58006790
www.ioccc.org
>>
>>58006935
link?
>>
>>58007143
it's a shit book you retard, and can't you fucking google? kys
>>
>>58007143
https://learnpythonthehardway.org/book/

this is how the book was described to me. i don't know if it's a good idea
>>
So what happened to the regular Lisp threads?
>>
>>58007172
zed shaw is never a good idea
>>
>>58007188
died, moved to lainchan
>>
>>58005317

What is your folder structure, how are you including foo.h, and what is the exact error message you are getting?
>>
>>58007267
bix nood
>>
>>58007238
probably not, but maybe anon just needs some confidence
there's an o'reilly book that's supposed to be good, right?
>>
Some guy at my work tied api parameters to values tied to a dropdown because he couldn't figure out how to handle basic input. He never tests anything and he introduces bugs with everything he touches. He manages to work later and harder than everyone else. Everyone has been getting better since I introduced code review but this guy is a fucking wreck. What do I do with him?
>>
>>58007297
vince foster special
>>
>>58007297
By tied to a dropdown, I mean values displayed to a user. Capitalized strings. In a general api call.
>>
>>58007286
Python teaches nothing but bad habits to the beginner.
I highly recommend starting with C and working your way up.
You can only understand abstraction when you know what is being abstracted away and you'll eventually come to appreciate it when you realize how much effort it takes to implement what other languages take for granted.
>>
anyone bored enough to help a beginner with homework?

i wont paste the whole question here ill just ask one part.

i need create a date class. i also have a people class that will take, among other things, a birthday.

i was doing something like
    class Data
{
int day, month, year;

public Date(int day, int month, int year)
{
Day = day;
Month = month;
Year = year;
}

public int Day { get; set; }
public int Month { get; set; }
public int Year { get; set; }
}


how would i pass this to the birthday on people class? i may be doing something completely retarded since i had to miss the objects intro so dont bully me too much.
>>
>>58003972
C
>>
>>58007324
>class Data
>public Date
>Data
>Date

just have a Date in your person, like
class Person {
private Date birthday;
>>
>>58007324
i forgot to say its c# fuck
>>
$ telnet towel.blinkenlights.nl
>>
>>58007349
yeah it was a typo
alright thanks and how do i pass the actual day/month/year to that?

do i have to create a new person, and then add day, month, year separately or is there a way to do it at the same time?
>>
>>58007389
make a setBirthday function in Person that takes a Date, or takes three ints for month, day, year, or whatever.
>>
>>58007324
struct date {
int day;
int month;
int year;
struct date (*date)();
};
void date(struct date *d, int day, int month, int year)
{
d->day = day;
d->month = month;
d->year = year;
}
void date_init(struct date *d)
{
memset(d, 0, sizeof(struct date));
d->date = &date;
}
/* ~~~ */
struct date d;
date_init(&d);
d.date(&d, 1, 2, 2017);
>>
>>58007408
>>function pointers in a struct for no reason
Retarded. Kys.
>>
>>58007406
thanks ill mess with it for a bit more

>>58007408
i need c# not c, but it may be useful since i also have a c class, thanks
>>
>>58007188
Not enough Lispers, moved to lainchan, now on semi-hiatus because it's well, lainchan.
>>
>>58007478
Lainchan has moved on from 4chan-style BBS to a Telegram group last I heard.
>>
What are the benefits of longjmp?
>>
>>58007535
exceptions in c
>>
>>58007515
What are you talking about? It's just an imageboard. There might be a separate BBS, but the lisp threads are hosted on the imageboard.
>>
>>58003892

Assuming you're on some kind of UNIX, just download the source code to some of the common UNIX utilities. Almost all of them are written in C, they're well documented, and they've been debugged for years so you shouldn't find any surprises.

The NetBSD source code is a good place to look. Go to cvsweb.netbsd.org and browse 'til you find something that fits your needs.
>>
How can we literally hack reality?
>>
>>58007562
Help get me laid, it'll probably break something
>>
File: 1478457195657.jpg (66KB, 1280x720px) Image search: [Google]
1478457195657.jpg
66KB, 1280x720px
>>58007562
>>
noob here, can i just start writing c++ programs in the command line? can it be the text editor too? dont really want to use visual studio or other heavy IDE's
>>
>>58004803

Depends on the language and how the object is stored.

If you're using something like C++ and the object is stored on the stack, then no, you can't use it outside the function. If it's stored on the heap, you can return a pointer to the object, but you need to remember to delete it once you're done with it.

In a garbage collected language like Java, you can return references to the object from a function. Same with Python, Perl, Common Lisp, etc.

If you're using dynamic scope, you can do all kinds of weird shit, but then everyone else who works with your code will want to kill you. Unless you're working with something like Emacs LISP, this doesn't apply to you.
>>
>>58007637
vim
g++
ex:
$ vim test.cpp
1 #include <iostream>
2
3 int main(int argc, char **argv) {
4 std::cout << "hello world" << std::endl;
5 return 0;
6 }
$ g++ test.cpp
$ ./a.out
hello world
$

I wrote this in the reply box so disregard typos or whatever
I also haven't written C++ in over a year
>>
>>58007666

alright cool thanks, what are some other things to do besides hello world? still trying to figure out all the things you can make...its just a black screen so i dont even know where to begin. First time ever programming
>>
>>58002845
Continuous autofuzz found a crash in the linter I wrote. Rewriting it to check for the existence of fields *before* assuming they're in there...
>>
>>58004856
(cond (cond1 (do-something)) (cond2 (do-something-else)) (else (do-something-entirely-different))
>>
Are there any good refactoring tool in emacs for lisp? I'm getting real tired of dealing with shit like this:
>modify struct in module to add new field
>breaks everything in other module requiring it, as expected
>have to MANUALLY edit or re-add in EVERY instance of the pattern-matching against that struct, deconstruction, or reference against an instance of that struct just to handle the one new field. Shit dude, I was just reading about how ReSharper in C# can add in new parameters and reflect all calls to that method and modify them to incorporate that new parameter, and I'm starting to get pretty jelly of how other languages have so much better support while I have to hack around by hand or if I'm lucky, search-and-replace.
>>
>>58007684
Oh. I don't recommend learning C++ as a first language, it's pretty shitty and the only reason it's still used today is because large companies have large, old codebases that need maintenance, or game dev. I recommend you start with C so you don't confuse "OOP" with all programming.
Anyway, if you really need to start with C++, read the book Absolute C++. It has a pie on the front I think. If you want to start with C instead, I recommend C Primer Plus by Stephen Prata.
>>
I'm trying to write a Haskell function that can take in a list of files and return a list of their MD5 checksums. I have this function to generate the checkdum from one file:

lazyChecksum = (liftM md5) . LS.readFile


Using Data.Digest.Pure.MD5 and Data.ByteString.Lazy, respectively.

This works fine on a single file or mapM'd onto a small list, but when I try to mapM it over a large list of files, I get a "resource exhausted (Too many open files)" exception. How can I fix this?
>>
Heh. I'm in Community College and just left a review for my C programming teacher who had below a 2.8 before my review:

Wow. I've reviewed some of the COP/CTS professors on here and I've realized something... many inspiring to be in IT related fields are some of the biggest whiners. I simply don't get it. Programming is largely a self-teaching discipline so before blaming Professor XXXXXX for his teaching, you should actually pick up those textbooks and read!

Fuck, I made an A while taking four other classes. Are young men's testosterone declining?
>>
>>58007742
use a real language
>>
>>58007684
I agree with >>58007707 that you shouldn't learn C++ as a first language, but for different reasons. C++ is a very difficult language to learn and will be frustrating if you don't have any prior experience with programming (and even if you do).
>>
>>58007760
People expect to be spoon-fed. Don't worry, they will be weeded out.
>>
>>58007742
try breaking it up into segments and forcing evaluation, i.e. break the big list into small lists
>>
>>58007535

Hope you understand exactly how the stack works. longjmp() will happily drop you inside another function without the stack being set up, so when you try to return (or use local variables, or... well... anything, really) you're fucked.
>>
>>58007707
>>58007772

ok well if i were to use C, i'm still kinda stuck on what i can do. I guess math equations is a good start?
>>
>>58007822
C Primer Plus has good exercises.
With C, you can pretty much do anything.
>>
>>58007707
C Primer Plus is great. It's the book I used to learn C. Many will meme you here with "The C Programming Language" but it's definitely not friendly to newbie programmers.
>>
>>58007846
It's definitely not modern either.
>>
>>58007822
If you are looking to make interesting applications as quickly as possible I would strongly recommend learning Python. It's beginner friendly and has a great ecosystem of third party libraries. On the other hand, if you are looking to develop good fundamental skills, learn C. It will be a while before you create anything interesting, but C will teach you a lot.
>>
>>58007637

Assuming you're on Windows since you mention Visual Studio.

All you technically _need_ is a compiler and a text editor. Create a text file with the editor, then run the compiler on it.

I've heard good things about Notepad++ as a source code editor, but I'm a UNIX guy so Windows users might have better suggestions. I use Emacs when I have to work in Windows, but it's got a learning curve (great if you want to learn LISP, though).

For a compiler, GCC and Clang are both available for Windows.

Honestly though, if you plan to stick to Windows development, you're better off with an IDE. I've worked a bit with Visual Studio and it ain't bad, but there are others out there. I've heard good things about Code::Blocks.
>>
>>58007832
>>58007846
>>58007853
>>58007872

thanks anons, i'll get the latest edition of C Primer Plus
>>
>>58007908
you can find a pdf online if you search for it, don't spend money if you don't have to
>>
>>58005107
kek
>>
int i;
for (i = 10; i < 5; i++) { do_thing(i); }


Will this go through any iterations or quit immediately?
>>
>>58007822

Just find a C++ textbook and do the exercises.

There's a million C++ textbooks. Find something recent (last three years, if possible) and download it from library genesis or something.
>>
>>58007947
won't do anything, probably won't even be in the executable
>>
>>58007947
quit immediately
>>
>>58007947

i think it would just be true and move on
>>
>>58007787
That's good to here. My college has a 17% transfer rate and 24% graduation rate. Most are probably scammers who take their pell grant money and loan money, then run. Also, irrelevant; Hispanics plus "African-Americans: outnumber whites when combined but probably only 1% of them enroll in IT related fields. It's usually mass communications or something along those lines.
>>
>>58007964
>>58007973
>>58007978

Will it exhibit this behavior if the value is entered during runtime?
something like
void iterate_list(struct *list, int offset)
{
for (int i = offset; i < list->size; i++)


where offset is larger than list->size?
>>
>>58008003
if offset is greater than or equal to list->size it just evaluates to false and doesn't run anything in the loop body.
How are you this dense not to understand that?
>>
File: IMG_0753.jpg (84KB, 500x503px) Image search: [Google]
IMG_0753.jpg
84KB, 500x503px
>>58002845
Maya best Eva girl
>>
>>58007901
For C, when I don't feel like running Linux; I use Pelles C for Windows. It has a decent GUI, text editor, and compiler all in one.
>>
What inspires me is teaching African refugees how to program JavaScript.
>>
File: ai.png (43KB, 358x862px) Image search: [Google]
ai.png
43KB, 358x862px
Made a seq2seq chatbot using Tensorflow and trained it on the Cornell Movie-Dialogs Corpus. My non-CS friends are freaking out.
>>
File: donald_bot.png (19KB, 506x282px) Image search: [Google]
donald_bot.png
19KB, 506x282px
>>58008142
>>
>>58008142
Repo?
>>
Would it be worth it to bruteforce sentience? Instead of training an NN, just randomly generate them with no training data and ask it a bunch of questions and sort them by how many they get correct, but not to evolve them based on a score of how many they get correct.
This is super pop-sci 13yo faggotry but it seems feasible if it was efficient and ran on a computer with a lot of power.
>>
>>58008304
No.
>>
File: Capture.png (9KB, 436x227px) Image search: [Google]
Capture.png
9KB, 436x227px
Why does a wrong input cause the program to go between the two methods infinitely until a stack overflow?
It doesn't even ask for new input after the first time.
>>
>>58008355
b-but
>>
>>58008366
Obviously not, you idiot.
>>
>>58007810
I tried

liftM concat $ sequence $ map (mapM (tryIOError . lazyChecksum))  $ chunksOf 100


and I still get the exception. Is there a better way to split the lists up?
>>
>>58008360
stdout isn't flushed automagically
>>
>>58008372
Are you sure you're forcing it to evaluate?
>>
>>58008304
Sentience will never exist on computers.
>>
Wew lad, AoC D15 was a breeze.
Finished under 20 minutes but that wasn't enough to get to the leaderboard today.
>>
>>58008370
Okay, obviously it's not worth it, and by the time anything meaningful was generated, we'd have already gotten their, but still

>>58008387
Where does our sentience come from?
>>
File: 1461389842104.png (386KB, 1436x1652px) Image search: [Google]
1461389842104.png
386KB, 1436x1652px
>>58008399
>>
>>58008360
Because java.util.Scanner is shit. It is literally in the "util" package.
Use BufferedReader instead. it's in the "io" package which is what you are trying to do.
>>
>>58008386
How would I do that? Use seq? I'm just running it in ghci to test it, would that make a difference?
>>
>Polymorphism in all forms was invented by OOP and is part of it.
>shit AGDG says
>>
>>58008411
Seq or deepseq I think should work.
>>
>>58008410
Ok, thanks. Could you explain why does the scanner fail to even ask the next input? I'm just a pleb amateur non-programmer.
>>
>>58004961
i think he is talking about
public static void main(String[] args) {}
>>
Made my first android app.
It's just a text to bin, hex, dec, base64, sha1, md5 converter.
>>
>>58008376
>>58008410
Nevermind, solved it with sc.nextLine().
>>
>>58008168
https://github.com/jessrenteria/flowbot

Cleaned it up a little to make it more presentable. You'll have to put in a bit of work to wrap your head around setting up the config file.

Also shoutout to my first paper I published on arXiv: https://arxiv.org/abs/1612.04035

If anyone's interesting in RNNs we devised a cell which provably eliminates the vanishing gradient problem. Still need to put some more work in but the results so far have been super exciting.
>>
fun python quiz!

what does the following print?
F = set()
A = [1, 2, 3, 4, 5, 6]

for n in A:
F.add(lambda : print(n))

for f in F:
# let's say for the simplicity's sake that this iterates in the order things were added to F
# (iirc this ordering is going to be guaranteed in future versions of python)
f()
>>
File: 1480970210804.png (580KB, 862x890px) Image search: [Google]
1480970210804.png
580KB, 862x890px
>>58008592
>knowing python
embarassing desu
>>
>>58008602
this
>>
>>58008602
apparantly I don't since I had to trace the source of a bug I wrote to this. I'm beginning to remember giving up python years ago for this very reason.
>>
>>58007297
He seems to pit in the effort. Give hI'm some tips/books/tutorials to learn on after hours.
>>
>>58008615
in haskell you couldn't make this sort of mistake because of monads


a = [1..6]
f = map print a

main = sequence_ f
>>
>>58008592
Ran into this issue when I was trying to make a prime number generator in 5 lines. What are the scoping rules behind this?
>>
>>58008602
There isn't really much to know about python, reading it is easy and intuitive for the most part. Python is a shit language but it's really easy to understand written code
>>
>>58008623
Is Haskell white and based?
>>
>>58008628
I really thought I understood python's scoping rules. I have no idea.
>>
>>58008635
dunno what you mean by that

also the code I posted
here's a simpler version
main = mapM_ print [1..6]
>>
>>58008635
no, it's tranny and degenerate.
>>
>>58008592
huh
I'd think that would work but it doesn't
>>
>>58008643
>>58008623
The point of the program isn't printing things out. That's just an example illustrating the weird scope/closure rules in python. It came up in something a bit more involved.
>>
>>58003325
>including a .c file
Do. Not. Do. This.
>>
>>58008742
what actually happens in your python code example?
>>
>>58008756
Why?
>>
>>58008784
one would expect it to print out
>1 2 3 4 5 6
but it prints
>6 6 6 6 6 6
something about how after the loop every function that you created has the value of the variable at the end of the loop, so they all print the last element
>>
>>58008784
It prints 6 six times.
>>
>>58008796
>>58008797
how do you fuck something up so badly
>>
>>58008811
I have no clue, my hypothesis is mostly a wild guess
>>
>>58008811
The only other language I've used with similar scoping rules and broken-ass closures/lambdas is fucking ActionScript.
>>
Hello friends,

I have returned, I am completed with working on Java, now I must learn Python.

Can you please suggest me a good book / video resource to learn?

Thank you my friends, I will never forget your aid when I needed to pass my Java Class.

-Baby Pajeet
>>
Is there a good language that have features like Python's but actually work as expected?
>>
>>58008844
Haskell
>>
>>58008858
Haskell is good to a certain point. Purity ruins it.
>>
>>58008867
>Purity ruins it.
t. person who thought >>58008796 was a good idea
>>
Waiting for Numerai to upload their next dataset after they fucked up the last one
>>
>>58008840
>Play Video: Introduction to Computer Science and Programming Using Python
Introduction to Computer Science and Programming Using Python
from mit
https://www.edx.org/course/introduction-computer-science-mitx-6-00-1x-9

I did it a few years ago, its really good
>>
>>58008844
Racket
>>
>>58008869
What? No, that's horrible. I like Haskell a lot until you get into crazy category theory just to use a language.
What would be nice would be a language with pure functions and impure procedures.
>>
>>58008884
Haskell has impure procedures.
a -> IO b
>>
>>58008789

It's a very old, established convention that you do not include .c files.

Programmers generally run under the assumption that no one would do such a thing. I'm not sure what kind of problems you'd have with build automation tools or IDEs.

There are times when you include stuff that's not .h files (.xbm, for instance), but most tools expect .c files to be compiled separately and then linked.
>>
File: asdf.jpg (28KB, 388x378px) Image search: [Google]
asdf.jpg
28KB, 388x378px
reminder haskell is a meme language for autistic desktop ricers that don't actually do anything except jack off to anime all day
>>
>>58008894
Anime isn't a bad thing to jack off to, and desktop ricing is pretty fun. It's okay to do both of those things when you have a job at a competitive company, I think.
>>
>>58008894

Reminder that most of /g/ is fifteen year old boys who hang out here because no girls will give them any attention.
>>
>>58008930
I'm at least twice as old.
It's still correct though.
>>
>>58008592
neat, a way to make this behave as expected:
F = set()
A = [1, 2, 3, 4, 5, 6]

for n in A:
F.add(lambda n=n: print(n))

for f in F:
f()

Python closures are a bit weird and things aren't bound until they're used. However default parameters to functions are evaluated at the time of the function definition so this forces it to use the n from when the lambda was created.

I learned something new today and rediscovered one of the reasons I dislike python.
>>
How difficult would it likely be to write a custom Desktop Environment for BSD?

And what libraries would I need to use? Assume I want to primarily write it in C++ with OpenGL.

Can it be written as standalone, so that its only interaction with the Shell would be through passed Shell commands, and it just overlays itself over everything else (so, theoretically, you could close the DE, and you're left with the CLI behind it)?

Such as, double-clicking an icon on the desktop sends cd [whatever the directory is] and receives ls -a and you know, like then prints it to the screen and stuff?

In other words, not based on the X-Window System, but purely its own application?

In general, I guess my real question is: how would I go about writing a graphical application that can handle physical screens, and that is NOT a derived piece of software, but its own program reliant on nothing but its own libraries - functionally, its own API?

How much would I need to personally fuck with drivers? Assume a driver exists for, idk... an AMD Sapphire graphics card.
So, I have the driver, I have all the standard UNIX C libraries, I have 3 monitors, OpenGL, and I have a lot of time.
Is there anything else I'd need, or is that pretty much it, just look at the return values for the GPU, and use them to define things like screen size and rotation for the DE?
>>
>>58008397
In how many iterations did you find an answer to the second part if I may inquire?
>>
>>58008890
>It's a very old, established convention that you do not include .c files.

So a bunch of people don't know what include does and religiously banned inclusion of anything other than .h files?

It just puts more code into your compilation unit.

You can easily segregate implementation-specific code into a separate file per target and use conditional compilation to select which one to include.

>most tools expect .c files to be compiled separately and then linked

Depends on your build configuration. Obviously you don't build a .c file that's included by another since you're gonna get multiple function definitions at link time.
>>
>>58008397
It was a breeze except for the debugging that led to >>58008592
>>
>>58008894
Haskell processes every single facebook post to prevent spam. It also runs directly on the Xen VM.
>>
New thread
>>58009006
>>
>>58009002
COOL
>>
>>58008966

You want to write your own DE using only the standard libraries and system calls?

I'd suggest rethinking the idea, but in case you want to go ahead, here's some info that might be useful:

There's a driver called scfb that's part of FreeBSD's X install. It provides non-accelerated access to the console framebuffer. You might find the source code interesting, and you'd avoid the whole driver mess. If you want to mess with drivers, search for DRM.

That'll get you a screen to work with. The syscons driver has support for mouse and keyboard (obviously), so check how that works while you're at it.

So now you've got a screen, keyboard and mouse - now what? Well, you're going to have to write your own window management, API, applications, etc... basically, it's a fuckload of very demanding work. Unless you port one of the popular toolkits to it, you'll have nothing to run on it.

We all know X has its downsides, but there's a reason it hasn't been replaced yet. You might be better off looking into keeping X but writing a custom window manager using OpenGL/C++/xcb.
>>
>>58008966
I know I am going to sound like a dickhead for suggesting something else, but have a look at Wayland.

Wayland itself is just a way for a client to talk to a compositor and vice versa.

you can get really low level with it, like writing individual pixels on the screen without using anything like OpenGL

Also, your compositor (WM) will be able to support other Wayland clients
>>
>>58008990

>So a bunch of people don't know what include does and religiously banned inclusion of anything other than .h files?

No, a bunch of people know exactly what include does and /still/ avoid including .c files.

It's a convention, and a very widespread one. You don't have to follow it. Just don't expect other programmers to accept it, and don't expect bug-free behavior in 3rd party build tools.
>>
>>58007172
Typing up programs out of a book while simultaneously trying to understand them and then modifying it once you have the program from the book running is a perfectly legitimate way to learn a programming language. Learning a a particular programming language doesn't need to involve any sort of problem solving. It requires slowing yourself down so you can take in and practice with each new construct of the language one at a time.

Of course if you want to learn to solve problems using programming then your best reading choices are The Art of Computer Programming or SICP.
>>
>>58008884
>believing the tripe idiots spew about purity meaning no I/O or anything
>>
>>58002845
What kind of preparation do I need to take for entering prog. competitions? I am an average programmer.
Thread posts: 319
Thread images: 35


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