[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: 31
File: orangutan_1600x1000_279157.jpg (418 KB, 1600x1000) Image search: [Google]
orangutan_1600x1000_279157.jpg
418 KB, 1600x1000
Previous thread: >>53932281

What are you working on, /g/?
>>
            IF ISTRUE(g_Grid_HLines_Enabled) THEN textCanvasRectF.height -= .5
IF ISTRUE(g_Grid_VLines_Enabled) THEN textCanvasRectF.width -= .5

GdipDrawString(g_oGrid.pGraphics, textStr, -1, pFont, textCanvasRectF, pImageTextStringFormat, pBrush_Text)

>>
thinking about falling for the ruby meme
>>
>>53941441
Do it. It's one of the better meme languages.
>>
Lua or Perl /dpt/?
>>
>>53941426
>a = 22, b = 22
start
>a ^= b
a is 0, b is 22
>b ^= a
b is still 22, a is still 0
>a ^= b
a is now 22, b is still 22

So where's your problem?
>>
Did anyone do the first codejam challenge? I wasn't here so I missed it.
>>
>>53941442
Nigger, it exists for a reason.

But I forgot I'm in /dpt/ - Reinventing the wheel general
>>
I wish I could be as good as you guys at programming
>>
>>53941513
kek no you don't
>>
>>53941513
but just how good are these so called "programmers"?
>>
>>53941513
are we good at programming?
>>
>>53941461
The guy didn't put it right.
The problem isn't the same value, but when the variables point to the same memory location.
So when a gets set to zero so does b
>>
>>53941460
wouldn't even compare the two, but for general purpose go with Perl6. if you're using an embedded scripting language, either Lua or Guile.
>>
>>53941526
why not?

>>53941558
>>53941560
You guys seem like it I can only build intermediate programs
>>
>>53941567
>when the variables point to the same memory location
as in
int a = something;
int *b = &a;
int *c = &a;

and trying to swap values of b and c?
>>
File: sweat pepe.jpg (55 KB, 500x473) Image search: [Google]
sweat pepe.jpg
55 KB, 500x473
>>53941429
>last 2 questions on quiz are takehome
>knew how to do neither
>answers to both were on first result on google
>>
>>53941668
>knew how to do neither
*didn't know how to do either
>>
>>53941668
>>53941460
>>53941513
>>53941560
>>53941596
Is this the /bpt/?
>>
I'm thinking about picking up Common Lisp because there's a project on GitHub I'd like to contribute to, but then I'd have to learn a filthy Lisp-2
>>
File: 1454377863529.jpg (666 KB, 666x666) Image search: [Google]
1454377863529.jpg
666 KB, 666x666
>
DateTime().Today
and
DateTime().Now
always return a time value, even if it's zero
>no date function that just gets the fucking date without a bunch of bullshit workarounds
M I C R O S O F T
>>
File: lisp.png (3 KB, 75x30) Image search: [Google]
lisp.png
3 KB, 75x30
>>53941746
why does this language still exist, can someone remind me?
>>
>>53941616
yes
>>
>>53941777
Because it runs banks, trains, and window managers.
>>
>>53941777
>m-muh parens
why do we let you people in?
>>
>>53941777
Come back when your language has metaprogramming as good, kid.
>>
>>53941584
Perl 6 is shaping up to be a wonderful language but I feel as though the tools aren't quite there yet which I think makes it hard to honestly recommend it.
>>
>>53941819
java has better metaprogramming than lisp, cumskin
>>
I'm so bad at programming :( How do I get better?
>>
>>53941848
Program more
>>
>>53941848
Think of a project that excites you and then just start it from the very beginning, learning whatever you need when that roadblock comes.
>>
File: h.png (38 KB, 209x250) Image search: [Google]
h.png
38 KB, 209x250
Just finished my rootkit. What now?
>>
I have structures in a header file that looks like this
typedef struct {
int val;
} data;

typedef struct {
struct node_data* data;
struct node* next;
} node;


When I try to make a head node with this code
node* head = NULL;
head = malloc(sizeof(head));

head->data = malloc(sizeof(data));
head->data->val = 5;

head->next = NULL;


On the lines where i'm assigning a value to data->val it throws
error: dereferencing pointer to incomplete type


I'm brand new to C and trying to get linked lists working. What am I doing wrong?
>>
>>53941848
start building a portfolio of code snippets that are perfect. so you can first make a perfect hello world, then do a perfect insertion sort. stuff like that. it helps in the future too because if you actually need to use a heapsort or something you can just copy and paste your old code into a new class or function or whatever and use it
>>
>>53941790
in that case it's obious. even zeroing a register is often done by xoring it with itself
>>
>>53941429

I want a terminal application the connects to a irc network, joins a channel and sends to standard output only user messages with minimal formatting.

Never written anything worthwhile in my entire life. How would I go about this ?
>>
>>53941936
install it on Sony's servers
>>
>>53941954
python
sockets
parse strings
loops
>>
>>53941954
C
sockets
parse strings
loops
>>
>>53941962
B-but that means I have to root them. :(
>>
>>53941981
why would you such a thing in C lol
>>
>>53941985
I doubt their security has changed at all since the leaks. Shouldn't be too difficult.
>>
>>53941999
>terminal app
>sockets are nice in C
>>
File: 1436993271883.jpg (68 KB, 515x698) Image search: [Google]
1436993271883.jpg
68 KB, 515x698
>>53941848
Wear girly clothes.
>>
>>53941754

What's the problem, chief?
>>
>>53941940
>struct node_data
You didn't define that struct, so C is complaining that it doesn't know what it is.
I assume you meant the line to be
node *data;

Also,
>struct node* next;
is also wrong. You haven't defined 'struct node' either.
typedef struct node {
...
}

>head = malloc(sizeof(head));
This is allocation space equal, to the size of the pointer, not the size of what's being pointed to.
head = malloc(sizeof(*head));
>>
>>53942038
>python
>bash
??
>implying sockets aren't nice in python
??
>>
>>53942066
this
>>
>>53936045
Thank you anon. And good luck with your project too.

>>53936643
And thank you too. I'm taking a look at nosql meme and I think there might be something in there that fits my needs better than relational.
I really thought those were only for people running TB+ databases in RAM distributed in datacenters all over the world until now.
>>
File: laininabearsuit.png (148 KB, 332x450) Image search: [Google]
laininabearsuit.png
148 KB, 332x450
>>53942066
>tanuki
>not a bear suit
You'll never get good at programming like that, don't listen to this faggot
>>
>>53941754
What's the problem?
Use DateTime.Now to get the current date
What's wrong?
>>
>>53942192
>What's the problem?

There isn't one.
>>
>>53941848
take drugs
you know the ones I'm talking about
>>
>>53941940
>
typedef struct {
int val;
} data;

??? And I think it's name is supposed to be node_data anyway.
>>
>>53942363
sorry that was just a typo, I'm still having the same problem
>>
>>53941940
Once you typedef a struct you don't need to add 'struct' before the type specifier. Are you compiling with -Wall and -Wextra? You should ALWAYS.
>>
>>53942541
I am compiling with Wall and will with Wextra.

I'm also getting warnings for invalid pointer types. it's getting to the point where I'm considering rewriting the linked list part of this project
>>
>>53942571
typedef struct data {
int val;
} data;

typedef struct node {
data* data;
struct node* next;
} node;
>>
first for D
>>
>>53942701
Is there a single language LESS relevant than D?
>>
>>53942688
To explain.
'node' as a type defined in the typedef is not defined until the end of the statement. The struct tag (the 'node' after the struct keyword) is defined before the end of the statement and so you can use that to specify the struct type.
>>
>>53942740
When you use a struct tag to define the type of struct you specify the full type as
struct tag variableName;

While if you typedef a struct it can be used like other types like int, double, etc.
struct_type variableName;
>>
>>53942718
Haskell
>>
>>53942718
There's always Mindfuck.
>>
>>53942779
*Brainfuck
>>
how would you sort 2 different lists where one or more elements in each list are shared. for example
ArrayList<Entity> e1 = new ArrayList<>();
ArrayList<Entity> e2 = new ArrayList<>();
Entity someEntity = new Entity();

e1.add(someEntity);
e1.addAll(e2);

Collections.sort(e1);
>>
>>53942768
found the butthurt python coder
>>
>>53942910
Set e1 = e2. Then sort either one of them (since they are aliases)
>>
ayy fucking lomo
>>
>>53942910
What? HOW is the repeated elements important. WHY does that change how the sort should function?
>>
>>53942910
what's wrong with that approach?
>>
Is anyone participating in codejam? if so what was the first challenge, I wasn't here so I didn't get to see it.
>>
>>53942981
>>53942988
>>53943040
i want to take the "someEntity" element and sort them inside each list without duplicates and use different sort methods for each list
>>
>>53943076
That still makes no sense.
>>
>>53941429
At least shoop SICP into the image, OP.
>>
>>53943076
I cant understand what you are saying. Are you indian, by chance?
>>
We need /bpt/ back! anyways,
what makes an IDE bad besides bloat?
what makes a compiler bad?
>>
>>53943230
>what makes a compiler bad?

being part of the GNU project.
>>
>>53943230
>/bpt/
bad programming thread?

>>53943076
>>53942910
This is an XY problem. Stop asking us for the answer to Y and tell us X.
>>
>>53943230
1. nothing
2. optimization
>>
File: CIC11C5UsAAPrK1.jpg (29 KB, 599x439) Image search: [Google]
CIC11C5UsAAPrK1.jpg
29 KB, 599x439
>>53943272
>>
>>53943285
wrong thread buddy
>>
>>53942541
>>53942571
What do the -Wall and -Wextra flags do? When I work in C I use

gcc -std=c89 -pedantic -Wformat source.c -o executable_name
>>
>>53943363

Turns on a bunch of extra shit. Turbo nerds also use werror.
>>
>>53943311
int* var = 5;

or
int *var = 5;


First makes more sense to me, but I see it much less frequently.
>>
>>53943382

The latter is correct. The former is incorrect.
>>
File: CMAOk-AWwAEjxbH.jpg (33 KB, 575x556) Image search: [Google]
CMAOk-AWwAEjxbH.jpg
33 KB, 575x556
>>53943138
>>53943229
>>53943272
>>
>>53943382
The pointer is being applied to the variable, even though the type is called an int pointer, so the latter actually makes more sense.
>>
>>53943395
shut up faggot

>>53943382
first makes more sense, but the latter lets you do stuff like: int *var1, *var2 ... ;
if you do it the other way, then only the first in the declaration list will be a pointer, the others will be regullar ints
>>
>>53943230

>IDE
IDEs are bloated by nature. Those that avoid this are reasonably usable

>Compilers
What makes a compiler good or bad can be defined by the following qualities:

* Standards compliance
* Optimization in output code
* Speed of compilation
* Ease of use / comprehensible error messages
* Multiplatform support

MSVC fails hard on the first two, as well as the last one. Clang does best on all of them, and GCC does better than Clang on some of them while worse on others.
>>
sorry stallman but sublime is max comfy
>>
>>53943484
>shut up faggot

It's not my fault, fag-boy. Why don't you hop into a fucking time machine, go back to late '60s, stroll into bell labs, and interrupt dmr's j-bird sesh to set him straight.
>>
In C++ how can I receive a line from a file and get each element before a comma?

file.txt:

var1.var2.var3
>>
>>53943590
i want to be your catgirl gf
>>
Is Python a good language to work with math? I need to write some numeric method algorithms to approximate integrals and derivatives of a function. And by good I mean easy to work with, I don't need the code to be pretty I just need it to just werk.
>>
>>53943619

Sounds pretty gay, m9.
>>
>>53943638
i'll wear a skirt
>>
>>53943647

It really hinges on one thing: are you black?
>>
>>53943664
no
>>
>>53943680

No thanks, then.
>>
>>53943721
i can be whatever you want bby
>>
>>53943634
Absolutely! Python is the language most used for data science.
>>
>>53943725

GTP is straight and has jungle fever. You're not going to be able to seduce him, even if you're giving Bailey Jay.
>>
>>53943727

At least where performance isn't relevant. If you just need to get some quick proven solving done, Python's libraries will serve you well. Otherwise, I've seen C, C++, and Fortran all finding use in huge number crunching applications.
>>
>>53943778

Isn't 4chan supposed to turn you gay? How am I not gay yet?
>>
File: 1391741386630.gif (591 KB, 480x270) Image search: [Google]
1391741386630.gif
591 KB, 480x270
>that one fag in your class who can't program for shit and has failed all of the exams, yet blames the compiler every time his program won't work right

How do these people even exist?
>>
>>53943828

Not a lot of black traps. So your fetish was never satiated. On that note, cute black girl sitting across from me on the bus right now.
>>
>>53943865
post pics
>>
>>53943853

Unless your class is in Ada or C++, there isn't much reason to bitch about the compiler.
>>
>>53941429
Give me a 250 word or more answer to this question.

>Q3. Even though we found recursion a little complicated and hard to learn, still we use it very commonly. What can be the reason for that?
>>
>>53943865
>cute black girl sitting across from me on the bus right now.

she wants some fuk.
>>
>>53943865
pics to prove she's cute please
>>
>>53943881

Too late, just got off. A bit rude to snap pics of strangers anyways, even if they're so focused on their phones that they'd never notice.
>>
File: 538a4072493e0.png (261 KB, 512x512) Image search: [Google]
538a4072493e0.png
261 KB, 512x512
>>53943919

She was interested in your free software contributions and you didn't even try.
>>
>>53943919
rubes what city you in?
>>
>>53943972

Bellingham, WA.
>>
>>53943990
word. is western washington a good school?
>>
>>53943972
>>53944009
kill yourself
>>
>>53944023
come make me faggot.
>>
never been a better time to filter trips desu
>>
i have an idea for a game. it will teach computer science concepts (not syntax) through puzzles. for example, you have to sort a set of tiles into ascending order, but you can only carry one tile at a time, and only the tile you're standing on has its number illuminated. to simulate insertion sort. stuff like that

[spoiler] i'm out of ideas for any other puzzles please give me some more [/spoiler]
>>
>>53944009

WWU is pretty decent for CS. We average like... 90th percentile for the major field exams, and have some extremely knowledgeable professors, especially in the areas of machine learning.

That said, we've had a few odd hiccups in the past couple of years. At one point about 5 years ago or so, someone had the bright idea that we should close either the CS, Physics, or Geology departments. The next day, the CS department basically just told everyone to declare their major, even if they hadn't met their requirements, because the university would more or less be contractually obligated to provide the classes anyways. Then the university got some angry phone calls from I think Google and Microsoft and backed off (MS hires quite a number of our graduates).

Also, some SJWs on campus are starting to get annoying. But the adminstration isn't really giving them much attention, mainly because they broke into a board of directors meeting to demand the creation of a "college of power and liberation" that nobody fucking wants.
>>
>>53944143
i know who you are
>>
File: awoo~.png (762 KB, 1000x1000) Image search: [Google]
awoo~.png
762 KB, 1000x1000
I figured out how to avoid peppering my code with #ifdefs.

#ifdef _OPENMP
#include <omp.h> /* If OpenMP is not supported, multithreading is disabled */
#else
/* Single-threaded mode: OpenMP calls will be replaced with dummy functions */
#define omp_init_lock(mutex) ;
#define omp_destroy_lock(mutex) ;
#define omp_set_lock(mutex) ;
#define omp_unset_lock(mutex) ;
#define omp_test_lock(mutex) 1
#define omp_get_num_procs(void) 1
typedef unsigned char omp_lock_t; /* dummy mutex type */
#endif
>>
>>53944154
>SJWs on campus are starting to get annoying.

There was a Bernie Sanders rally on my campus today.
>>
>>53944143

Something something traveling salesmen.
>>
>>53944187
bryan?
>>
>>53944143
RoboZZle with more features
http://www.robozzle.com/

The community seems pretty dead now, unfortunately. I played it so much a few years back.
>>
>>53944204
thanks for reminding me, gotta go reactivate my bernie bot
>>
>>53944197
pretty cool

>not using pthreads
>>
>>53944204

Bernie is fairly popular here as well, although about a month back, someone basically started writing pro trunk stuff all over campus in chalk. The campus responded by not trying to get rid of their right to do so, and instead, using chalk of their own to change Trump to Drumpf.
>>
>>53944262
>change Trump to Drumpf.

That whole Drumpf thing is probably the gayest mud-slinging campaign of all time. People who get all their "news" from Oliver should jump off a cliff.
>>
>>53944293
OMG DUDE I TOTALLY LOVE JOHN OLIVER I HAD NO IDEA YOU WATCHED HIM HE'S THE BEST! I EVEN GET ALL MY POLITICAL OPINIONS FROM HIM FOR FREE!
>>
>>53944293
it's just retarded niggers thinking that using someone's ancestor's name is an insult.
>>
File: flatbush-zombies-website.jpg (49 KB, 670x400) Image search: [Google]
flatbush-zombies-website.jpg
49 KB, 670x400
>>53944154
interesting. i've never been west of like kansas but wash sounds pretty chill. seems weird that like some old logger foresty area is turning into a tech hub, guess it's just bleed off from the bay area. i def need to check it out sometime, i know i'm a fan of the taxes if nothing else.

>>53944204
did the zombies come out to play?
>>
>>53944318
what are you black
>>
File: akari2.jpg (58 KB, 514x524) Image search: [Google]
akari2.jpg
58 KB, 514x524
Rate my tripcode generator!
$ ./tripforce -i "akari"
tripforce 0.2.0
Utilizing 2 threads.
----------------------------------------------------------------
TRIP: '!bQA4UAkARI' -> PASS: 'lTB0;|w ' @ 306103 trips/s
TRIP: '!FOw8cAKArI' -> PASS: 'w`z8.:'Z' @ 305572 trips/s
TRIP: '!akaRIOtVbo' -> PASS: '/xLPo:{G' @ 306886 trips/s
TRIP: '!akaric2CO6' -> PASS: '*H1}5Y]E' @ 280218 trips/s
TRIP: '!EevakarIjk' -> PASS: '"U;d1ymZ' @ 299606 trips/s
TRIP: '!aKArIm2HVU' -> PASS: 'ha%QT00f' @ 242522 trips/s
TRIP: '!wjnAKarINo' -> PASS: '|:WalDH7' @ 290004 trips/s
TRIP: '!yPakARI50o' -> PASS: 'g-[GLpJA' @ 298228 trips/s
TRIP: '!aKariYvA6g' -> PASS: '"6k?u6S'' @ 283115 trips/s
TRIP: '!plJaKaRIT.' -> PASS: '^kBc<5Q'' @ 298015 trips/s
TRIP: '!BaKARi9.oI' -> PASS: 'HS`[h>W3' @ 280771 trips/s
TRIP: '!RAkaRIi87E' -> PASS: 'BqUg.?(z' @ 289596 trips/s
TRIP: '!mztonAKarI' -> PASS: 'v?:xQj@L' @ 289596 trips/s
TRIP: '!AKaRiH5Y4E' -> PASS: 'RH"YOiCi' @ 308770 trips/s
TRIP: '!VFCraKARIg' -> PASS: 'h'@]IDEc' @ 306007 trips/s
TRIP: '!QEDBaakarI' -> PASS: 'h4kqyOf%' @ 305202 trips/s
>>
>>53944318

You should probably avoid washington. People like you infect that poor state with liberal progressive mental illness.

I594 was the fault of hyper-liberals shitting up all the states they move to.
>>
>>53944343
>QEDBaakarI

cute!
>>
>>53944358
I'd usually say "go back to /o/" at this point, but you seem like a pretty cool guy
>>
>>53944318

How to avoid most taxes in Washington:

Live in Vancouver, WA. No state income tax.
But shit in Portland. No sales tax in Oregon.

Many people do this.

>>53944358

I594 I think is being challenged.
>>
File: 1446149035655.jpg (65 KB, 513x1018) Image search: [Google]
1446149035655.jpg
65 KB, 513x1018
>>53944368

I might be mentally ill myself (with the jungle fever and all) but at least I'm smart enough that hyper-libs think I'm a "right wing extremist"
>>
>>53944343
nice! >>>/a
>>
>Tfw it's too hard to make a good useful application
>>
>>53944327
>on /dpt/
>black
not a chance.

>>53944358
>I'm a fan of their taxes
>somehow liberal
nope. MAGA motherfuckers. I wear the hat outside and get spat at in my liberal city.

>>53944378
not a bad plan anon. I bet I'd like portland too. Not at the point where I can work wherever I want yet though.
>>
Ask an Australian programmer anything.

>>53944397
Applications are easy, it's the settings dialog (or option parsing) that can kill you.
>>
>>53944403
>nope.

You used the word "chill" so I just assumed.
>>
>>53944385
>shiieeet can't even tripfagging
I guess is because different IP, was replying with your trip
>>
>>53944411
>Ask an Australian programmer anything.

What do you think about guns?
>>
>>53944419
They go pewpewpew.
>>
>>53944411
I've been thinking of how to write a decent option parser.
Keep a global array of structs that contain all the option flags + an enum value that represents that option.
Run through them in a loop.
>>
I'm learning haskell, and I'm having a slight issue understanding something

zipWith (+) thing (tail thing)

zipWith (+) thing (the last element of thing)

can someone please explain to me why exactly these two lines are different?
I may have a fatal misunderstanding of how zipWith works
>>
>>53944416
>>
>>53944426
plop click clack a pow pow
>>
Ask a tranny programmer anything

>>53944411
are we doing this?
>>
>>53944439
>I'm learning haskell
stopped right there.
>>
>>53944462
pls post boipucci
>>
>>53944462
do you prefer to specify the gender pronouns in your code in the readme file or the comments?
>>
>>53944514
nah
>>53944518
nah
>>
>>53944462
Go back to teddit.
>>
>>53943727
>>53943821
Cython supports numpy/scipy already. You can squeeze quite a bit of performance by optimizing with it, at the cost of filling your beautiful Python code with static-typed garbage.
C++ on the backend, a SWIG generated interface and Python to control the flow, perform the final calculations and make pretty plots is something I have done in the past too.
>>
>>53944585
never been to teddit
>>
>>53944463
thanks for not wasting my time
>>
>>53944594
>static-typed garbage
this is what a snek actually believes.
>>
>>53944518
its read from the $GENDER_PREFRENCES environment variable during initial setup and automatically inserted into all comments.
>>
>>53944604
You'll love it there. They have tons of boards devoted to faggot men who think they are women. Go away!
>>
>>53944605
no problem m8, I can already see you're wasting enough of your time with that fettuccine alfredo nightmare.
>>
>>53944462

What is it like to program for a transmission system?
>>
Post your programming progress /dpt/
>>
>>53944648
all I'm hearing is that you don't like trying new things and think nobody else should enjoy trying new things either.
>>
>>53944378
>But shit in Portland
pajeet...
>>53944439
the tail is not the last element. remember, Haskell's lists are linked lists ("cons-lists" as they're called in Lisps). so the each node is made up of a head and a tail. for example:
[1, 2, 3, 4]:
head = 1
tail = [2, 3, 4]
head = 2
tail = [3, 4]
head = 3
tail = [4]
head = 4
tail = []

in fact, the [1, 2, 3, 4] type of syntax is just syntactic sugar for the (:) operator (pronounced "cons"):
-- (:) associates to the right hand side
[1, 2, 3, 4] = 1:2:3:4:[]

so basically, for [1, 2, 3, 4] the tail is [2, 3, 4] and the last element is just 4
>>53944659
didn't do much today other than documentation. i finally got around to installing NixOS though. it's pretty nifty, but i wanna try Guix before I fully commit to it
>>
>>53944668
>have fun, friend. it looks like you already are.
>>
>>53944439
zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (+) [a1, a2, a3, ...] [b1, b2, b2,...]
= [a1 + b1, a2 + b2, a3 + b3, ...]
>>
>>53944673
>head
>tail
I think you mean car, cdr, caar, cadr, cdar, cddr, caaar, caadr, cadar, caddr, cdaar, cdadr, cddar, cdddr, caaaar, caaadr, caadar, caaddr, cadaar, cadadr, caddar, cadddr, cdaaar, cdaadr, cdadar, cdaddr, cddaar, cddadr, cdddar and cddddr
>>
>>53944673
>>53944755

okay, so I think I'm getting it now

zipWith (+) thing (tail thing)

would add every element in thing to the element to the right of it, because it's really grabbing the tail of the element, making a list that is equally long

thing = [1,2,3,4]
would result in two lists with a = [1,2,3,4] and b = [2,3,4]. Which means [1+2,2+3,3+4], and it doesn't go any farther because list b is only 3 elements long

zipWith (+) thing [the last element in thing]

adds the first element in thing to the last element in thing because you have two lists [1,2,3,4] and [4] so you only get [1+4] and it doesn't go any farther than that.

is this right?
>>
>>53944795
yep, sounds right
>>
>>53944809
cool, thanks
>>
You guys have to admit Indians make really good Indian food
>>
>>53944819
depends, a lot of them are vegetarian
>>
>>53944673

Typo. Meant to write "buy shit in Portland."

Although I've heard some terrible things about Portland, so I might as well encourage people to be pajeets there.
>>
just looked at google code jam
i cant program guys
>>
>>53943363
>
std=c89

KILL YOURSELF.
>>
File: 1512431241.jpg (72 KB, 375x515) Image search: [Google]
1512431241.jpg
72 KB, 375x515
>>53945074
>tfw no qt 80's gf
>>
File: 5953017_f520.jpg (27 KB, 520x269) Image search: [Google]
5953017_f520.jpg
27 KB, 520x269
>tfw
>>
Finished code jam qualifiers just now using c++ lol. Pretty easy so far.
>>
I'm a bit confused on how people use the output of trained neural nets. Let's say you have a neural net for recognizing capital letters. Does the net output numbers 1-26? If the it recognizes the letter as an M for the mostpart, would it output something like 12.6, even though M and L are very different? Thanks.
>>
>>53944795
I'm back

is there a way I can do this better?

is there a way I can eliminate the variable 'i' using this method? Should I?

factors :: Int -> Int -> [Int]
factors n i
| i^2 > n = []
| mod n i == 0 = i : quot n i : factors n (i+1)
| otherwise = factors n (i+1)


I don't need the elements sorted in order, but I tried this

| mod n i == 0 = i : factors n (i+1) : quot n i

and depending on where I put parenthesis, I get different errors saying that I have the wrong type in places. If someone feels like answering this one, how would I get them sorted in order using this method?
>>
>>53945737
too lazy to think about what it's actually doing, but ill explain the type errors:

mod n i == 0 = i : factors n (i+1) : quot n i 

factors n (i + 1) has the type of the return type of factors (which is [Int])

quot n i is an Int

the (:) operator requires the first operand to be a normal value and the second operand to be a list of that type:


(:) :: a -> [a] -> [a]


However, to get the order you want you need to add a single item to the end of the list. We can still append to the back of the list without using (:) at all, using the ++ operator. Of course to do that, we have to also return the result of quot into a list:


mod n i == 0 = i : factors n (i+1) ++ [quot n i ]
>>
>>53946146
oh dear god what went wrong with this post
i swear the code tags were right
>>
>>53944403
>>on /dpt/
>>black
>not a chance
funny, i actually know a black guy who used to post on here
dunno if he still does though
>>
>>53946158
that's alright, I'll get back to you after I sort out the information in the post
>>
Am I still able to access the vga buffers at 0xb8000 and 0xa0000 when in protected mode?
I'm aware that I have to switch back to real mode to change the video mode.
Also, when switching the video mode, do I have to set the IVT back to 0 in order to call BIOS functions again?
>>
>>53946174
>>53946146
>>53946158

>mod n i == 0 = i : factors n (i+1) ++ [quot n i ]

okay so let me make sure I'm understanding things

(:) adds the element before it to the list after it
(++) adds the list before it to the list after it

is there an infix operator like these that would add the element after it to the list before it?

also is
mod n i
alright or should I be doing something different here?

It feels like I'm trying to shoehorn iteration into a language that uses recursion, and I'm not sure if that's even okay practice, let alone best practice.

I'm using haskell purely to learn, not for a specific problem, so if I'm doing things 'wrong' I'd like to know
>>
>>53941616
No, they mean swapping *b and *c. Yes: a with itself, basically. So meaningful.
>>
>>53946254
>>(:) adds the element before it to the list after it
>(++) adds the list before it to the list after it
yep

>is there an infix operator like these that would add the element after it to the list before it?
you can search on Hoogle for the type signature ([a] -> a -> [a]) https://www.haskell.org/hoogle/?hoogle=%5Ba%5D+-%3E+a+-%3E+%5Ba%5D.
None of these match exactly, so apparently not. However, you can define one yourself:
-- Replace (++:) with a nicer operator, just a random name I came up with
(++:) :: [a] -> a -> [a]
(++:) xs x = xs ++ [x]

-- Use as:
[1, 2, 3] ++: 4


>also is
mod n i
alright or should I be doing something different here?
I mean, from a Haskell standpoint, sure. Idk if algorithmically that's correct

>It feels like I'm trying to shoehorn iteration into a language that uses recursion
i think the way you're doing it is fine (it's still recursion). as you get more proficient in Haskell, you might come up with shorter ways to right it, but those aren't necessarily as nice if they're significantly harder to read. any time you need some kind of iteration, you'll end up doing either explicit recursion (like what you have) or some combinator that evaluates things recursively for you (like map, filter, fold, etc.)

>I'm using haskell purely to learn, not for a specific problem
I don't think you're doing anything really wrong at any point here. Your code seems fine honestly. Don't get caught up in writing the shortest possible functions just for the sake of it.
I will say, if you're trying to learn Haskell the best way to grasp a lot of the more abstract concepts is to find something to make with it. the best way to learn is out of experience. it doesn't need to be a specific problem, maybe just translate a small shell script into Haskell when you want a challenge.
>>
thinking of falling for the vala meme
>>
>>53946254
>
mod n i

use rem
>>
>>53945737
use filter
>>
int data;
for (int i = 0; i < 10; i++) {
data = some_function(i);
do_something(data);
}
// data no longer needed


... or...
for (int i = 0; i < 10; i++) {
int data = some_function(i);
do_something(data);
}

?
Is there an efficiency problem with making a new variable every iteration? My colleague says there's no reason for the variable to have a higher scope but it feels off.
>>
>>53946318
>Hoogle for the type signature
this is something I'm going to start using, I didn't know that

>Idk if algorithmically that's correct
It gives the correct result, if that's what you mean

>i think the way you're doing it is fine (it's still recursion). as you get more proficient in Haskell, you might come up with shorter ways to right it, but those aren't necessarily as nice if they're significantly harder to read. any time you need some kind of iteration, you'll end up doing either explicit recursion (like what you have) or some combinator that evaluates things recursively for you (like map, filter, fold, etc.)

>explicit recursion
I've learned a new term, thanks.
I don't know, explicit recursion feels a little dirty to me for some reason

>Don't get caught up in writing the shortest possible functions just for the sake of it.
That's not really what I'm doing here, I'm trying to learn the "best" functional programming ways to do things, not necessarily the shortest


>the best way to learn is out of experience. it doesn't need to be a specific problem, maybe just translate a small shell script into Haskell when you want a challenge.
I'm currently running through euler until I get a good grasp on the language, I might start up a project later once I do have a grasp on the language

>>53946336
when should I use mod and when should I use rem?

what is the advantage of one over the other

>>53946392
filter is a good tool, I use it in a lot of other languages, and I'll use it after I get really really used to defining functions of haskell
>>
>>53946421
there is literally no difference
it's still only one local variable
>>
>>53946421
All modern compilers will optimize it properly. Do the latter.
>>
>>53946421
Don't worry about optimization until you need to.

The latter properly scopes 'data' and makes it obvious that it is irrelevant outside the loop, so do that unless you have a need to do otherwise.
>>
>>53946330
Anon, please do! I'd love to hear what you learn from it!
>>
>>53946237
You have access to them in protected mode in the sense that you can map one of your pages to point to them unless I'm missing something?
>>
Will cocaine help me program?
>>
So I'm trying to make something that downloads videos off of youtube and creates a playlist of converted audio files, I'm using youtube-dl and ffmpeg, I got everything working in java, but ffmpeg hung for some reason after the song finished playing, so now I'm trying in c++.

Basically is there a good way to call an executable that runs in the command line? It doesn't seem like the system() call will let me get data back after it's finished running.
>>
>>53946741
fork exec
>>
>>53946727
yes
>>
>>53946741
If you're just exec'ing binaries you might as well be using python. Look at the subprocess module.

Or just use bash, this is the kind of thing it's good for.
>>
>>53946677
are you from the GNOME team?
>>
>>53946772
I've sent patches to Cinnamon, but that's about as close to being a member of the GNOME team as I've been.

Really I just want to know what vala even do.
>>
>>53946766
I'll try in python, thanks.
>>
>>53946782
from what i can tell it seems like a decently designed high-ish level language similar to c++ used mainly for writing gtk+ apps. it compiles to C so that's cool
>>
>>53946727
I'd suggest an amphetamine based stim for programming. Cocaine might have you jerking off for hours insteading of programming.
>>
Using snek. Can I dynamically construct variable names using user input?

So that, if I have
varibleNumber = raw_input("What is the number of your variable? :")
I can use somehow concatenate
variableNumber
with some pre-determined name to make lots of variables called, for example,
variable1, variable2, variable3
?

Searched Stack Overflow but I'm too much of a pleb to understand many of the answers.
>>
>>53946893

>posting :")
>not :^)
>>
>>53946893
I really don't know what you're trying to say.

Could you give some examples of inputs and outputs you're looking for here?
>>
so senpai what kinda GTK frontend you need for your commandline programs?
>>
>>53946924
I want the user to be able to create a user-specified number of variables, that all start with the same words.
Let's say all the variables should be named
variable
, and the user inputs some number N. I then want to produce variables named
variable1, variable2, ..., variableN
. I don't want just strings, I want the variables, maybe a loop that - given the input N - takes some user specified value for each variable to hold. Pseudocode:

userVariableRange = raw_input("Input range of values: ") #n must be a number
using userVariableRange
for i in range(userVariableRange):
variable + i =
userVariableValue = raw_input("What should variable " + i + ":s value be? ")
, noting that I want variable and i to be concatenated as a variable.
>>
>>53946693
Yeah, that's what I thought.
>>
File: reimu_chibi.jpg (144 KB, 850x972) Image search: [Google]
reimu_chibi.jpg
144 KB, 850x972
>>53946995
What you're looking for, my friend, is a list.

<https://docs.python.org/2/tutorial/datastructures.html#>
>>
>>53947024
Wow. I can't believe I didn't think of this.
Can't thank you enough, senpai.
>>
>>53946928
>>53946928
cmon familia tell me what gtk "app" to make
>>
This is just silly. I'm spending another day looking for a complete Spring tutorial for creating a more complex web application (like blog or online store) without fucnking obsolete xml, but with annotations.

Has anyone ever seen something that might fulfill my needs? I don't need tutorial about what is DI, bean lifecycle, application context etc. because there is plenty of them out there. I want tutorial from A-Z creating a blog or online store.
>>
>OpenGL context creation on Linux
Should I use GLX or EGL nowadays? I'm creating a Core 3.3 context.

GLX has the benefit of not needing libEGL to be available, but running through X compatibility mode if the OS is running wayland/mir/etc. right?
>>
>>53943379
>Ignoring warnings
>>
File: webdevs.webm (37 KB, 640x433) Image search: [Google]
webdevs.webm
37 KB, 640x433
>>
File: webdevs.gif (627 KB, 640x433) Image search: [Google]
webdevs.gif
627 KB, 640x433
>>53947408
well that didn't work
>>
File: webdevs.webm (205 KB, 600x406) Image search: [Google]
webdevs.webm
205 KB, 600x406
>>53947421
what the shit?
they both work perfectly on my end
I blame webdevs
>>
Are there BSD style "licenses" for software patents? Or should I just publish?
>>
>>53947365
I just use SDL2 to initialize my GL context, It's cross platform.
Why are you making your GL program Linux specific?
>>
A simple webapp that I'm stuck on because I don't have a good idea on how to do the UI
>>
>>53947864
I just looked up what EGL is and it's cross platform.
Forgive my retardedness.
>>
>>53947874
>I don't have a good idea on how to do the UI
Have you heard of model-view-controller? Or Controller-View-Backend? A web app is only different from your usual desktop applications because you also have to literally create the view instead of letting something to do it for you..

Write it the same way you'd write a desktop app.
>>
I'm wondering if I should replace some complicated file reading stuff with memory mapping.

Some sources I've read say memory mapping should be used when the file is being read sequentially, but this isn't how I'm reading the file. I'm fseeking all over it and reading from various places (don't blame me, I didn't design the format).

I'd love to test and measure this, but it's not a trivial change, it'd take the whole weekend to modify every file read operation and make sure they still work correctly. Only then I could measure it.
>>
File: qqqqq.jpg (127 KB, 500x500) Image search: [Google]
qqqqq.jpg
127 KB, 500x500
Sooooo I have created a library in java that uses Jaunt as a resource. I want to export my library as a jar file and include the Jaunt resources so that only my library is needed to be added to the build path in other programs. My library has no main() method because I don't think it needs to have one, but to export it as a runnable jar it needs a main method. What do I do?
>>
>>53947963
Do jars 100% have to be runnable?
>>
>>53948011
No, there's regular jars. My problem is that runnable jars ask to include the external resources but require a main() method, while regular jars don't ask to include the external resources but don't require a main() method. I'm wondering how I get around either of those.
>>
Does the order in which you declare variables in C matter?
The same programs give different results when reordering the variables when they are being declared
>>
I made a basic synth in C++ using SDL. The thing is, the code is a pretty shitty mess, and I wouldn't know how to abstract it and make it cleaner because I don't know much about audio programming.
How should I go about it?
>>
I'm learning my first programming language right now (C), and was wondering if there were any must reads after I make it through my first book?
>>
>>53948298
only if you rely on aliasing, surely
int a[3];
int b;

a[3] = 1234;
printf("%d\n", b); // 1234

obviously won't work if you swap them around, but you shouldn't be doing this sort of shit anyway
>>
>>53948400
actually I just checked with the latest gcc and it still worked with b before
changing to -O3 made it not work in either case. Definitely undefined
>>
>>53947885
I'm writing backends as appropriate (even EGL requires a bit of platform-speific to make a window). Purely as a learning exercise.
>>
File: cute anime pic 0627.png (148 KB, 418x310) Image search: [Google]
cute anime pic 0627.png
148 KB, 418x310
>tripcode speed counter overflows at 4.29 GTrip/s
i actually tried seeing how far the counter could go and it went up to 18.44 GTrip/s before overflowing a size_t.
I couldn't leave it like that tho, it actually made my program run worse, about 3 KTrip/s slower.
>>
>>53948513
I meant 18.44 ETrip/s.
>>
>>53948298
In C variables aren't necessarily initialized to 0. Sounds like you're relying on this, or the variables are initialized after an array and your program is accessing the last element of the array + 1.
>>
>>53948566
main()
{
printf("Temperature from Fahrenheit to Celsius \n");

float fahr, celsius;
int lower, upper, step;
step = 20;
lower = 0;
upper = 300;

fahr = lower;
while (fahr <= upper) {
celsius = 5 * (fahr-32) / 9;
printf("%3.0f %6.1f\n", fahr, celsius);
fahr = fahr + step;
}
}
[/cpde]
doesn't work if I say 'step = 20;' after lower and upper, it just thinks step is 0
>>
>>53948596
are you sure? I just compiled it and ran it in both configurations and it works
>>
File: rsim01.png (67 KB, 960x912) Image search: [Google]
rsim01.png
67 KB, 960x912
>>53941429
I'm evolving virtual robots to avoid obstacles using 9 sensors.
The prototype is written in javascript/node.js and runs on 6 cores (100% utilization).

I'm thinking about moving the heaviest part (fitness function) into standalone C++ binary and interacting with it via standard IO / JSON. That can wait though.
>>
>>53948645
it does run, still i swear that changing the order of declaration did fix it the first time, that's why i asked about the order, i must have done something stupid beside that too
oh well
>>
>>53948513
>>53948542
got a github page for this? Is it using cuda or opencl?
>>
Still trying to download files to get media info.

Spent the last few hours trying to put together data and (yEnc) decode it, only to end up with a single file with 26MB of nothing but the character "" and an occasional space here and there.

It's only going to get more fucky from here.
>>
why is this on page 10
>>
>>53945085
Her clothes seem to suggest something.
Thread replies: 255
Thread images: 31

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.