[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: 318
Thread images: 43

File: 1467387907257.png (1MB, 1000x1400px) Image search: [Google]
1467387907257.png
1MB, 1000x1400px
Old thread: >>56536249

What are you working on, /g/?
>>
>>56540659
First for D
>>
Still working on dependent elimination of Church encoded data.
>>
>>56540678
Can you explain elimination?

>>56540659
Thank you for using an anime image
>>
nth for i love you all
>>
i think i've realized something. generals where people hate making the new thread and often only do it after the thread archives aren't cancerous, while generals where people make the new thread exactly at or even before bump limit are cancerous
>>
Learning Haskell, having a great time
>>
>>56540721
ask if you need anything
>>
>>56540685
With ordinary inductive types, very informally:
Formation = type construction
Introduction = construction
Elimination = pattern matching & recursion

Dependent elimination is where you eliminate into a type that depends on the term being eliminated.
>>
>>56540659
>be hime
>get blackmailed into crossdressing by cute schoolgirls
>have to live with a tail buttplug inside you all of your life because all of the pegging by the student council has stretched your anus way too much

In other news, I have started learning Haskell. It's pretty comfy until now.
>>
Hey /g/ I have a question. Do You feel sometimes that some posts are written by neural networks on other boards?
>>
>>56540702
Thanks for sharing
>>56540721
Good luck, my dude
>>
>>56540731
What, like /r9k/?

I mean, in all seriousness, a brain is literally a neural network.
>>
>>56540702
That's the difference between slow generals and fast generals.

/dpt/ isn't a general tho
>>
>>56540734
No, but I hear voices from the wires talking to me.
>>
>>56540685
>>56540727
And Church encoding is basically describing data by how it is eliminated. For example, Church numerals encode the natural numbers, and their elimination is applying a function N times to a value where N is the encoded number.

However, dependent elimination is tricky because it can only be derived from parametricity, i.e. the free theorem of the data type (which is a polymorphic function type). Actually having parametricity internalized in the type theory is a very new development - it's previously been only suitable for metatheorizing.
>>
>>56540761
I guess You replied to wrong numbers. I mean I saw once one Anon goofing off on /x/ by kinda making new posts from sentences and single words from previous posts. It did't make any sense but it made me thinking. I also sometimes have uncanny feelings from readings some posts.
>/x/ shilling
no
>>
I want to stop programming, it's not fun anymore
>>
Anyone /Lua/ here?
>>
File: r5zqcoQ.jpg (60KB, 600x486px) Image search: [Google]
r5zqcoQ.jpg
60KB, 600x486px
>>56540810
Don't like to yourself, it was never fun.
>>
trying to figure out how to put writing shell scripts on my resume
>>
>>56540835
put "bash" under your programming languages/technical skills/whatever
>>
>>56540861
thats what i was going to go with. thanks
>>
>>56540830
I made a patch for an open source game.

People liked it.

A few asked me to add some features, I didn't really have time to do that because of work.

They got mad at me over it and I ended up quitting the game altogether because it was no longer fun.
>>
File: snap_neural.jpg (389KB, 1366x671px) Image search: [Google]
snap_neural.jpg
389KB, 1366x671px
Posting this again only for (You)'s.
>>
>>56540935
That looks a lot worse than just writing the fucking script.
>>
>>56540928
Just make hacks for that game now to spite them : ^ ) Assuming it is multiplayer...
>>
File: 2016-09-10-164008_700x471_scrot.png (38KB, 700x471px) Image search: [Google]
2016-09-10-164008_700x471_scrot.png
38KB, 700x471px
Here's a small fibonacci problem. It says time complexity is O(n) but I was typing not thinking, it should be O(lg(n)).

Basically it says write a higher order function that when provided P,Q,B it returns the function for finding the appropriate Lucas Sequence's nth term.
>>
can anyone give me some god-tier android development resources? i'm currently going down a road of transcribing and running from online tutorials and i feel like it's a waste of time
>>
>>56540945
Nah man, I'm done, I don't want to put any more time into it. I've got a big list of other games to play.
>>
>>56540928
you made a minecraft mod, didn't you
>>
>>56540962
What game?
>>
>>56540970
Nope

I didn't realise it was even open source
>>
http://github.com/deeepaaa/hachidori
>>
>>56540978
I don't want to say, the community is small enough that you could identify me.
>>
File: Selection_055.png (71KB, 1385x747px) Image search: [Google]
Selection_055.png
71KB, 1385x747px
hey anons, why i can't add android sdk in netbeans?
>>
>>56540928
What game?
>>
File: shid.png (34KB, 714x476px) Image search: [Google]
shid.png
34KB, 714x476px
lol
>>
>>56541004
link?
>>
how do I tail call optimization so that recursing doesn't change the stack?
>>
>>56540999
divided heart on play force one, google it
>>
>>56540984
It isn't, the mod frameworks are reverse engineered as far as I know.
>>
>>56541025
its http://learnyouahaskell.com/
>>
>>56540999
See >>56540994
>>
>>56541004
Mister 004 You have licence to kill.
>>
>>56541035
i had no idea that they were such biggots
>>
File: 5Vat1UK.jpg (103KB, 622x486px) Image search: [Google]
5Vat1UK.jpg
103KB, 622x486px
>>56540994
Don't be a pussy ):
>>
>>56540991
How is this programmable? And how is it any useful? Do you just minimize everything and stare at your desktop?
>>
>>56541004
the best part of my life right now is being hours into reading a boring technical book and finding a joke the author put in there. at first i thought computer scientists have a really great sense of humor, but now i realize it's because the stuff surrounding it - the majority of the work - is so dull
>>
>>56541073
yeah
lyah is pretty darn casual though
>>
>>56540991
Still shilling your non-free shit?
>>
>>56541115
It's GPL, though.
>>
>>56541057
yes.
>>
i'm bored and listless, decide what i do
http://www.strawpoll.me/11199302
>>
is there a standard function that copies an array into another array?
>>
>>56541261
std::copy(std::begin(src), std::end(src), std::begin(dest));
>>
>>56541261
That would depend on the language. For example, D has dup and idup
>>
File: pepe inquisitive.jpg (122KB, 1278x1181px) Image search: [Google]
pepe inquisitive.jpg
122KB, 1278x1181px
>>56541261
>a standard function
>>
Can I use div to make a fizzbuzz in c++?
>>
>>56541261

http://en.cppreference.com/w/cpp/string/byte/memcpy
>>
>>56541281
what about c?
>>56541286
you wouldn't wanna write
the for int i=0,j=0; i < whtaver
seems tedious
>>
>>56541309
then it depends on the language. java has a function copyOf that you use to copy an array
>>
>>56541309

memcpy
>>
>>56540942
Not him, it looks exactly the same to me
>>
>>56540991
Hey NEET, github precaches all images that show up in markdown README files, so your pageview counter doesn't work because it's not actually requesting the image from flagcounter, it's being loaded from camo.githubusercontent.com
>>
>>56541261
memcpy works and is type-agnostic
you're copying the raw memory bytes to another location.
>>
>>56541363
bummer, seems memcpy only works for 1d arrays
I wanted to avoid for loops
don't get me wrong, I know I can loop over the arrays and do memcpy(dest[i],src[i], size)

and I assume that the size is a storage unit*n
>>
>>56541409
uh all arrays are 1d...
>>
>>56541472
[ [2,3,4], [8,9,10], [2,20] ]
>>
>>56541489
Let that sink in you retard...

< int a[4] = {1, 2, 3, 4};
> 0 [1], 1 [2], 2 [3], 3 [4]

< int a[2][2] = {{1, 2}, {3, 4}};
> 0x0 [1], 0x1 [2], 1x0 [3], 1x1 [4]
>>
>>56541489
1. Yes, you will need to deep copy that.
2. Don't store 2D arrays like that you retard.
>>
>>56541472
>>56541498
I'd just like to let you know that your autistic pedantry didn't add anything to this discussion
>>
>>56541498
if it contains arrays, then its more than 1d
>>
>>56541489
>>56541409
memcpy still works on 2D arrays.
2D arrays are stored sequentially in C.
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int main()
{
int arr1[3][3] = {{1, 2, 3}, {2, 3, 4}, {3, 4, 5}};
int arr2[3][3];

memcpy(arr2, arr1, sizeof arr1);

bool matches = true;

for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j)
if (arr1[i][j] != arr2[i][j])
matches = false;

puts(matches ? "Matches" : "Does not match");
}
>>
>>56541511
woooooo

fUKEKIng magic

2 dimensions
no loops

how could this
even ??

can we descend into the third dimension

woooooooo???

#include <stdio.h>
#include <string.h>

int main(void)
{
int a_src[4] = {1, 2, 3, 4};
int a_dst[4] = {0, 0, 0, 0};

memcpy(&a_dst, &a_src, sizeof(a_src));

int b_src[2][2] = {{1, 2}, {3, 4}};
int b_dst[2][2] = {{0, 0}, {0, 0}};

memcpy(&b_dst, &b_src, sizeof(b_src));

// verify
for (int i = 0; i < 4; ++i)
fprintf(stdout, "%d ", a_dst[i]);

fprintf(stdout, "\n");

for (int i = 0; i < 2; ++i)
for (int j = 0; j < 2; ++j)
fprintf(stdout, "%d ", b_dst[i][j]);

fprintf(stdout, "\n");

return 0;
}


are aliens behind this????

>>56541524
not in memory
>>
>>56541543
I see, I forgot that, nevermind, pham
>>
>>56541287
pls respond
>>
>>56541409
>>56541489
>>56541511
>>56541524
you're retarded. there's nothing special about arrays having their elements as arrays that would make memcpy not work on it
>>
>>56541572
wow, why did you give memcpy the address of the address of the start of the arrrays?
>>
>>56540659
Working on approaching a girl that I saw.
>>
>>56541601
Taking the address of an array will give the address of the first element.
Pointless, I know, but what he did isn't wrong.
>>
>>56541599
I just started c, give me a break
>>
>>56541608
he did &array, not &array[0]
>>
>>56541601
i don't really C
im a python babby
i just wanted to get a point across
>>
>>56541543
What about an array of char ** where each char ** pointer is a malloc'd char array?

Try memcpying that without a for loop.
>>
>>56541409
this is where the distinction between multidimensional arrays and arrays of pointers to array comes in

a true contiguous multidimensional array is fine to memcpy in one go
>>
>finished codeacademy

What next?

I want to build websites and create forums.
>>
>>56541659
>>>/g/wdg
>>
>>56541622
Yes, I know.

>>56541636
That's not a 2D array. That's an array of char pointers.
Yes, for a deep copy, you would need to use a loop.
Is this what you actually meant?
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
int arr1[3][3] = {{1, 2, 3}, {2, 3, 4}, {3, 4, 5}};
int (*arr2)[3][3] = malloc(sizeof *arr2);

memcpy(arr2, arr1, sizeof arr1);

bool matches = true;

for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j)
if (arr1[i][j] != (*arr2)[i][j])
matches = false;

puts(matches ? "Matches" : "Does not match");

free(arr2);
}
>>
one quick qeustiion
is sizeof arr[2][5] == 10 or 5
is it allways n*m if arr[n][m]?
>>
{-# LANGUAGE TypeInType, GADTs, TypeFamilies, ConstraintKinds, NoMonomorphismRestriction, RankNTypes, ExistentialQuantification, TypeOperators, FlexibleInstances, FlexibleContexts  #-}
>>
File: 1470651530676.jpg (143KB, 850x1201px) Image search: [Google]
1470651530676.jpg
143KB, 850x1201px
>>56541664

Thanks nigga
>>
>>56541771
Who is this buttslut?
>>
File: 1470010951376.jpg (10KB, 256x267px) Image search: [Google]
1470010951376.jpg
10KB, 256x267px
>>56541779
wow
i cant believe you called her that

rude
>>
Finished reading The C Programming Language today. Pretty good book
>>
wait, wtf, memcpy requires the dest to be void?
why
>>
File: 7212086.jpg (60KB, 700x700px) Image search: [Google]
7212086.jpg
60KB, 700x700px
>>56541779

I don't know. There is never any sauce.
>>
>>56541790
Yeah, but who is she?
>>56541795
Nice, now make me a kernel
>>
>>56541757
It depends on what type 'arr' is.
But what you're getting is the size of the element at arr[2][5], not the size of an 2D array of 2x5 elements.
#include <stdio.h>

int main()
{
char arr[3][6];
printf("%zu\n", sizeof arr[2][5]); // 1
printf("%zu\n", sizeof(char[2][5])); // 10
}
>>
>>56541801
because C has no generics so you pretend that void pointers are generics with implicit cast
>>
>>56541801
void * is a pointer to any type. It doesn't really have anything to do with the void type.

>>56541824
Are you suggesting that there should be object code generated for every single type that memcpy is used for?
Don't be retarded.
>>
>>56541821
so
 memcpy(st,nst, sizeof nst);

would be good?
both are the same dimensionsm and are 2d arrays
>>
>>56541874
>so ... would be good?
Yes, unless nst is a pointer type.
>>
>>56541885
explain
I thought array names are pointer to first elem
>>
>>56541858
>Are you suggesting that there should be object code generated for every single type that memcpy is used for?
no, i'm saying that had C been a good language it would support generics
>>
>>56541900
>I thought array names are pointer to first elem
Don't be fooled by people that say pointers and arrays are exactly equivalent in C.
Arrays will decay into pointers when passed into a function, but there are several situations when they act differently.
When you sizeof an array, you get the sizeof type * number of elements. When you sizeof a pointers, you get the size of the pointer itself.
>>
can I do stuff like
int main () {
short y,x;
while(1)
getmaxyx(stdscr, y,x);
_Bool st[y][x];
do_whatever with st
>>
>>56541947
in C99 yeah
>>
>>56541947
Yes. It's called a variable length array (VLA).
C++ and C89 don't support them.

>>56541922
How do you propose that generics are supported without having object code bloat?
>>
Writing scrapers for porn sites. That's all I can seem to care enough to write.
>>
>>56542004
but finding them is most of the fun
>>
>>56541942

This was a mistake. Even Ritchie admitted it, but I can't find the interview.
>>
>>56542035
Why didn't Ritchie put the bare minimum STLC into C?
Then all these C-likes would have had it from the start too
>>
>>56542047
or rather the common form of STLC where you have binary sums and products

rather than fucking unions and structs
>>
>>56541942
A stack-allocated array is not a pointer.
>>
>>56542071
Yes, that is what I was saying.
Actually, any array is not a pointer. Arrays are their own thing.
>>
>include <math.h>
>compiler says no "ceil" functio available
>>
>>56542104
You need to link the math library, -lm.
>>
>>56541922
memcpy doesn't need type specified pointers though since you only need the memory location, you still have to specify the number of bytes to copy over anyway. All you'd get out of a template for memcpy would be not requiring a product with sizeof(type) when specifying number of bytes. There are indeed uses for templates in C, but memcpy isn't one of them.

>>56541984
>How do you propose that generics are supported without having object code bloat?
Writing 'generic' macros creates preprocessor bloat and writing multiple functions that do the same thing for different types also contributes to object code bloat. I believe linkers deal with code bloat from c++ templates these days by merging matching templates in different compilation units.
>>
>>56542104
int ceil(float n) {
int a = (int) n;
return (a == n) ? a : a + 1;
}
>>
Why does this segmentation fault in printList7()?
#include <stdio.h>
#include <stdlib.h>

struct listnode {
struct listnode* left;
struct listnode* right;
int data;
};

struct listnode* add7(struct listnode* head,int data);

struct listnode* reverse(struct listnode** head);

void printList7(struct listnode **head);

int main(){
struct listnode** head;
struct listnode* headVal;
head=&headVal;
*head=add7(*head,2);
*head=add7(*head,34);
*head=add7(*head,1);
*head=add7(*head,45);
*head=add7(*head,43);
*head=add7(*head,78);
*head=add7(*head,4);
printList7(head);
/*head=reverse(head);
printList7(*head);*/
}


struct listnode* add7(struct listnode* head,int data){
struct listnode *temp;
temp=(struct listnode *)malloc(sizeof(struct listnode));
temp->data=data;
if (head== NULL)
{
temp->right=NULL;
temp->left=NULL;
}
else
{
head->left=temp;
temp->right=head;
temp->left=NULL;

}
return temp;
}

void printList7(struct listnode **head){
struct listnode *temp=*head;
while(temp!=NULL){
printf(" %d",temp->data);
temp=temp->right;
}
printf("\n");
}
>>
position += velocity * dt;
velocity += acceleration * dt;


Should I be dividing by mass in my physics integration even if mass is already being taken into account in my gravity and collision calculations?
>>
I feel like every other day I discover a new amazing GHCI extension
>>
>>56542216
whats the latest you've found
>>
why does rand have the same value everytime the binary is executed?
>>
>>56542219
pattern synonyms and view patterns, haven't really used them before
>>
>>56542249
The default seed value is 0.

Try srand(time(NULL) + clock()) if you want to randomize the seed.
>>
>>56542249
If you don't seed it by calling srand, it will start at 0.
>>
File: 2016-09-10-231503_514x456_scrot.png (12KB, 514x456px) Image search: [Google]
2016-09-10-231503_514x456_scrot.png
12KB, 514x456px
>>56542258
I love viewpatterns
try pic related
>>
>>56542322
>Lambda case
Used it before, it's in F# as "function"

>Records
don't use them enough for this to be a problem

>TransformListComp, ParralelListComp, BangPatterns
Know about these
>>
>>56542180
You never initialize headVal.
>>
>>56542249
Use <random> instead.
>>
I have a war story, if this is the place for it.

At work, we wanted to get rid of Qt. We had this little thing that was basically just a web browser with no window decoration, and it took custom CLI args to play nice with the rest of our shit.

In the old version, it was using some Qt WebView thing. I needed to port it to Java, and decided to use JavaFX's WebView, and the rest of the stuff is pretty normal.

One thing that was an unexpected hurdle was the app was not using our normal "--geometry" flags to set the window size/location, which is just x,y,width,height. Instead, it was passing in this fucking base64-encoded string to the generic "data" flag. What the fuck?

So I dig, and it turns out Qt's base widget class offers a "saveGeometry()" method, which returns what's essentially a binary blob, which the C++ code was just base64-ing and then saving. Then, to restore geometry, all it had to do was load this thing by blindly passing it to loadGeometry().

I was obviously not so lucky as to be able to do this, and it would be best if I could maintain backward compatibility with the old persisted geometries. So I try to track down some Qt docs to figure out how the fuck they're packing this blob.

Of course, there is nothing. So I cloned the Qt base source repo and started grepping for where this damn method is, and had to drill down to see what widths of ints and in what order they were appending them to this buffer.

So now I have this project that's a very thin wrapper around the JavaFX WebView, and like 60% of its code is me decoding and then slicing up this stupid fucking blob from ARGV.
>>
>>56542411
This doesn't sound all that difficult, and you sound like a massive fucking crybaby.
>>
File: 2016-09-10-233449_644x82_scrot.png (4KB, 644x82px) Image search: [Google]
2016-09-10-233449_644x82_scrot.png
4KB, 644x82px
somebody halp
>>
>>56542524
parentheses
>>
>>56542476

Of course it wasn't hard. It was boring and tedious and involved reading C++.
>>
How effective would it be to use the latest post on /b/ as a source of randomness for a program?
>>
What is the name of that website that lists the popularity/stats/usage of a programming language.

Basically, its a hierarchy of all the languages
>>
>>56542574
You could at least use a post from /r9k/, it's guaranteed to be unique because they block duplicate posts and people will type extra gibberish to get around it.
>>
>>56542524
do
nst[row][col] = (count == 2 || count == 3)

remember true == 1 and false == 0
>>
>>56542574
not very
/b/ is just "pics you shouldn't share"
>>
>>56542574
Take the latest post from /b/ and hash it
>>
>>56542574
Not very
>>
>>56542574

Using only the text of the post?
>>
File: 1472937160601.jpg (45KB, 640x480px) Image search: [Google]
1472937160601.jpg
45KB, 640x480px
>>56542578
>popularity/stats/usage
>heirarchy of all the languages
>>
>>56542574
/b/ is probably the least random board on 4chan though.
>>
>>56542574
Language structures are pretty deterministic. Topics are not.
You can't use topics as a source of randomness because you have to encode them into a deterministic language structure for them to be sensible.
>>
>>56542574
Every post on /b/ is the same fucking bananarama
>>
>>56542657
Obviously he'd only use text and/or images
>>
>>56542578
There's a few that come out every year.
Stackoverflow
O'Reilly (for different topics/uses)
IEEE
Independent blog posts that analyze Stackoverflow, Github, etc.
>>
>>56542668
Yeah, was just trying to make clear the why about why languages suck for sources of randomness.
>>
File: 2016-09-10-235002_654x738_scrot.png (27KB, 654x738px) Image search: [Google]
2016-09-10-235002_654x738_scrot.png
27KB, 654x738px
im fucking garbage
can somebody find out why my shit barely works?
>>
>>56542695
Oh, gotcha. Great point.
>>
https://wiki.haskell.org/Salsa

You have no excuse GTP
>>
>>56542714

My only excuse now is that I'm not smart enough for monads.
>>
>>56542702
>7: !(count=0)
This will always eval to true, did you mean ==? or even !=?
>>
File: pih.jpg (966KB, 1012x1345px) Image search: [Google]
pih.jpg
966KB, 1012x1345px
>>56542720
This is released September 30th, get it
>>
>>56542720
You don't need to know monads to get started
>>
>>56542733
its for initializing c to 0 every time, not just oncce
>>
>>56542596
Might be cool...

>>56542611
Well obviously you'd need to hash it. It needs to be convertible into a random seed anyways...

>>56542620
Eh, it could be just text or text and picture. Not sure. Just pondering if some source of entropy could be extracted from it...

>>56542635
This is... sadly true.

>>56542714
Why not just use F#?

>>56542720
Not smart enough or not dumb enough?
>>
>>56542702
Stop using so many ternary statements.
You only want to seed your random number generator once.
Should you be calling erase()?
>>
>>56542746
>Why not just use F#?
It doesn't compare
I suppose you could start with F# and work your way up
>>
I'm almost falling for the Lisp meme. Should I learn it? Is it that good?
>>
>>56542746
>Well obviously you'd need to hash it. It needs to be convertible into a random seed anyways...
I thought you were talking about the post number desu
>>
>>56542754
I need to failsafe if it goes out of bounds, thats why ternaries are good there
and yes, I need erase so that it erases the previous gen
>>
>>56542746
>Not sure.

I'd use both. More likely to get something closer to random, then. You could also include the timestamp, but that's cheating.

>Not smart enough or not dumb enough?

Perhaps it's both.
>>
>>56542765
(((((((((((((no))))))))))))))) and ((((((((((((((((no))))))))))))))))
>>
>>56542743
In that case it's clearer to use
count =0, col < m
>>
>>56542771

That would be less effective than using the current unix timestamp as a random seed.

>>56542765

Everyone should at least try a lisp. It's a fun language family, and it's inspired a ton of languages. You might enjoy it.
>>
>>56542743
Never make use of short circuiting
>>
"One alternative is to return some simple data structure, such as a map. A map works, but it forces data to be
copied out of the record set that comes from the database into the map. I think that using maps to pass data
around is bad form because it defeats compile time checking and isn't a very explicit interface, leading to bugs
as people misspell what's in the map"

What does Martin Fowler mean by this?

Maps aren't compile time checked? I'm not getting this...
>>
>>56542816
even better would be
for (short col = 0; col < m; count = 0, col++)
>>
>>56542816
0 == false
!(count=0) is true
it needs to be true
>>56542834
count is more in place there
>>
>>56542702
What do you mean barely works? What's wrong with it?
>>
>>56542845
As in whether a key-value pair exists in the map or not is only knowable at runtime.
>>
>>56542629
>>56542680
Not what I was looking for.
>>
>>56542702
>33: short y, x;
>35: getmaxyx(stdscr,y,x)
Functions in C are pass by value. By that I mean that line 35 won't change the values of the y and x in main().
Does getmaxyx() actually take pointers to int? Perhaps you need to call getmaxyx(stdscr, &y, &x)
>>
>>56542578
www.tiobe.com/tiobe-index/
>>
>>56542890
Looked it up, it's a macro, nevermind
>>
>>56542890
getmaxyx is a macro.
It's disgusting, I know, but that is now ncurses is written.
>>
>>56542702
>indexing with short instead of size_t
I guess you tought that would be quicker, but guess what? It is not.
>>
File: o.webm (74KB, 480x270px) Image search: [Google]
o.webm
74KB, 480x270px
>>56542861
webm related happens
I think it has to do with rand
I essentailly want to make random elements of the array 1, but I don't know much about rand()
i just copy pasted from here

>>56542920
less bytes == faster, right?
also, whats size_t
>>
>>56542860
That's not how the comma operator works. The comma operator just evaluates both expressions and then returns the RHS.
>>
>>56542949
I realize that you moved it to the step part
>>
>>56541004
lol
>>
>>56542743
>>56542816
>>56542846
but the very first statement in the for loop is an assignment to count, count = 0 isn't even needed
>>
>>56542968
It doesn't matter which of the two parts it's in. Comma isn't some special thing that only works in the update part of a for loop, it's an operator that can be used anywhere.
>>
>>56542938
your fill() is pretty slow, do this
for i in 1..n
do
row <- rand() % x
col <- rand() % y
while (st[row][col])
st[row][col] = 1

And I presume it's not the rand(), but your printing in ncurses.
Try just printing grids to stdout like normal and see how that looks
>>
>>56542938
>less bytes == faster, right?
No. Unless you're on a 16-bit machine, these variables get resized to the width of address buss of your architecture, so 32-bits on x86 and 64-bits on x86_64.
Why? Because that's how addressing works. So your code actually compiles into more instructions.
And it's not like loading two bytes from memory to register is faster than loading four or eight.
>>
>>56542996
but won't rand be the same if you don't change the seed?
>>
>>56542891
Thanks, I thought I had it bookmarked, but evidently I did not.
>>
>>56543059
No.
The seed is updated every time you call rand.
>>
>>56543059
No, it's a bit different from random in Haskell.
doing this:
srand(time(NULL);
int[5] arr = [rand(), rand(), rand(), rand(), rand()]

is like doing:
let arr = take 5 $ randoms (mkStdGen 100)
>>
>>56543128
>the binary to output different rands
what
also you only have to call srand() once in your program, unless you're running your program more than once every second
>>
>>56540659
Trying to figure out how to detect if a source image has an alpha channel in Racket. Turns out there isn't currently a publicly-facing way to do so, but I'm going through the relevant library files to see if I can make one.
>>
Playing with ASP.NET Core today. Mostly C# right now, but considering throwing in some F# to help learn. We'll see.

Anyone have any good pointers/resources on TDD? Despite working in industry for a few years now, I'm having trouble grokking it entirely.
>>
i give up, c is too hard for me in these moments
>>
>>56543294
did you try just printing to stdout? could be the ncurses
>>
>>56543201
tdd is harder than people think. You actually have to plan a bit more. You can't just start writing code and figure it out as you go.

On the plus side, it can really help you understand what it truly means to modularize your code.
>>
>>56543332
Sort it? What?
replace line 42 with
 putchar((st[j][k])? '*' : ' ')

then add a
putchar('\n')
after line 42
>>
File: gun_laws.jpg (48KB, 500x500px) Image search: [Google]
gun_laws.jpg
48KB, 500x500px
>>56540659

Can someone elxplain how/why hashing works, please?

thanks.
>>
>>56543387
same output as with ncurses
I wonder why
>>
>>56543407
Hashing in the cryptography sense or the hashmap sense?
>>
>>56543427

the hashmap sense.
>>
>>56542702
found it boy
line 19
sizeof nst is only the size of the first array, not the size of the entire grid
try to only use sizeof with types and not arrays
>>
>>56542765
Racket is amazing. It's my absolute favorite language.
>>
>>56543450
You just take some value and apply some operation to it to transform it into the index of some array.
"Operation" is pretty vague, but it really depends on the type of data you're hashing. It's usually followed by a modulo so it will fit into the size of the hashmap.
For example, if you're hashing strings, you may add all of the characters together (as numbers) as a hash and then modulo it.

You want a hashing function that will produce few collisions (two or more data values mapping to the same array index) and be quick to compute.
>>
>>56543475
>sizeof nst is only the size of the first array, not the size of the entire grid
That's wrong though.
>>
I've posted this before. Any feedback on this function to figure file extension?

extension get_extension(char* &str) {
char* ext_pos = nullptr;
int len_ret = 0;
size_t length = strlen(str);
auto read_pos = length;
while (read_pos > 0) {
--read_pos;
if (str[read_pos] == '.') {
++read_pos;
len_ret = length - read_pos;
ext_pos = &str[read_pos];
break;
}
if (str[read_pos] == '\\' || str[read_pos] == '/')
break;
}
return {len_ret, ext_pos};
}
>>
>>56543527
no idea then lol
>>
>>56543578
That line is still the problem. The sizeof is equivalent to sizeof(_Bool *), because it's a function parameter. Instead it should be n * m * sizeof(_Bool)
>>
File: hammer_bro.jpg (145KB, 807x605px) Image search: [Google]
hammer_bro.jpg
145KB, 807x605px
>>56543511

yes, but why is that faster than just going to the item that you were looking for in the first place?
>>
File: free monad example.png (89KB, 692x800px) Image search: [Google]
free monad example.png
89KB, 692x800px
Monads in a pure language are nice because they give you personal control over effects

You can write your own limited DSL and write functions to translate them into IO (or other) actions

The top half defines the DSL, the bottom half is the actual usage
>>
>>56543612
>just going to the item
How would you just "go to the item" in an array if you don't know where it is?
>>
>>56543612
Imagine your array has 1000000 entries in it. To "just go to the item you're looking for" you have to scan through the array, checking each entry one-by-one. On average you'll do 500000 checks. Versus doing the hash where you compute one cheap hash function and then use that to go straight to the item without searching.
>>
File: yes.jpg (20KB, 426x345px) Image search: [Google]
yes.jpg
20KB, 426x345px
>>56543628

a = [1, 2, 3, 4, 5, 6}

like this:

a[0]
>>
>>56543606
nst, not st

What you said is what I first thought, but I looked at it again. If that's what you meant when you said that what I said was wrong, then maybe I'm right; regardless, it should be n*m*sizeof _Bool
>>
File: tom&jerry.jpg (50KB, 728x636px) Image search: [Google]
tom&jerry.jpg
50KB, 728x636px
>>56543630

but then you still have to scan though the keys, and then the lists that the keys represent...right?
>>
>>56543664
No, the key is the index in the array
array[hashfunc(5)] == 5
>>
>>56543574
what if you pass something like "asdasda." to your function? if will return len_ret as 0 and len_ret pointing to '\0', so I guess you should be careful when using it.
I can't see any other problems, but C++ (?) isn't my thing, and I'm not used to C / C++
>>
>>56543656
Oh right, it's nst. Yeah the sizeof is fine then.

>>56543664
Sure. And if you have lots of keys hashing to the same value then that's a problem. But a good hash table will reduce this by a) having an appropriately sized array backing the hash table, and b) having a good hash function with few collisions. This way you only have to scan through a few elements at most.
>>
>>56543681
hashfunc(keyfor5)***
my bad
>>
File: darth_trump.jpg (26KB, 539x538px) Image search: [Google]
darth_trump.jpg
26KB, 539x538px
>>56543681

so why have the hashfunc in there at all? it seems like you're adding to the work, really.
>>
>>56543720
>>56543694
>>
>>56543574
>C++
Disgusting. Also, you should learn about some of the functions in your language's standard library.
char *get_file_extension(const char *str)
{
char *dot = strrchr(str, '.');
if (!dot || strpbrk(++dot, "/\\"))
return NULL;

return dot;
}
>>
File: what_the_world_owes_you.png (179KB, 392x395px) Image search: [Google]
what_the_world_owes_you.png
179KB, 392x395px
>>56543693

...but if you have a large number of items, then either the list of keys will be long, or the the lists within the keys will be long. i don't see where you're making up any time?
>>
>>56543692
It returns a nullptr for ext_pos if it never encounters a ".". The caller then checks if it's a nullptr and if it is, it checks the file header against signatures it knows can be handled.

Might do something about the caller having to check explicitly, but probably not. Seems fine for now.
>>
>>56543743
You don't have a list of keys.
Please learn something instead of "arguing" with someone in a /dpt/
https://en.wikipedia.org/wiki/Hash_table
>>
>>56543739
I knew about strrchr, but figured reading backwards would be marginally faster for long strings (assuming it all is pulled in on one cache line).

Have to do some tests to see if GCC is apt to generate better code when it detects use of certain standard library functions. Like memcmp.
>>
File: 1449195392748.png (81KB, 495x398px) Image search: [Google]
1449195392748.png
81KB, 495x398px
>>56543778

i'm not arguing. it obvously works. i want someone, who isn't butthurt, to explain why it does.

thanks.
>>
>>56543574
There's no need for str to be a reference here.

The while loop would be clearer as a for loop.

Rather than initializing len_ret and ext_pos to your "no extension" values at the start, why not just get rid of them and return directly from the places you are breaking? e.g.:

return {length - read_pos, &str[read_pos};
...
return {0, nullptr};


Doing it the way you are just makes the control flow confusing, and introduces more variables you have to keep track of.

>>56543743
>the lists within the keys will be long
No. As an example, imagine your hash table looks like this:

[0] -> [{a, b}]
[1] -> [{c, d}, {e, f}]
[2] -> [{g, h}]
[3] -> [{i, j}]
...
[n] -> [{w, x}, {y, z}]


If this was an array, you'd need to search through every key-value pair until you found your element. Here, if you're looking up "e", you hash "e", get 1, then search through only two elements that hash to 1 to find the value.
>>
>>56543786
strrchr does read backwards. Also, you're using strlen, so you're iterating over the whole string anyway.
>>
>>56543791
>who isn't butthurt
Do you seriously think people are arguing with you?
You clearly don't understand anything, so people are just trying to explain it, but you seem to be too mentally deficient to grasp it.
>>
File: i_ain't_laughing.jpg (15KB, 480x345px) Image search: [Google]
i_ain't_laughing.jpg
15KB, 480x345px
>>56543797

> Here, if you're looking up "e"
> you hash "e", get 1,

so that's O(n) to find 1, right?

>then search through only two elements that hash to 1 to find the value.

this feels like another O(n), to me. is the idea that we're shaving time on the ones that aren't overloaded?
>>
File: drop_out.jpg (21KB, 500x500px) Image search: [Google]
drop_out.jpg
21KB, 500x500px
>>56543815

>Do you seriously think people are arguing with you?

>>56543778

>Please learn something instead of "arguing" with someone in a /dpt/
>>
>>56543874
I think you should fuck off.
>>
>>56543856
n is the amount of elements in the table dude

hashing is an arithmetic function, so it's O(1)
>>
>>56543874
>>>/reddit/
>>
>>56543856
>so that's O(n) to find 1, right?
No. The runtime of the hash function is completely independent of the runtime of the number of entries in the hash table. Generally hash functions are O(m), where m is the size of your *key*, not the table.

>this feels like another O(n), to me
Worst case, yes, all your entries could hash to the same value. In practice, like I said, with a good hash function and a well-sized table, you minimize the number of collisions to a small value. Hash tables will often keep track of the max number of collisions and use this to rehash (resize the table and put the elements in their new places).

So in total you have O(m), where m is usually a constant, to do the hash, then a search through a small number of values that doesn't grow in proportion the the total size of the hash table. Hence O(1) lookups.
>>
>>56543913
>independent of the runtime of the number of entries
independent of the number of entries*
>>
>>56540659
Working on an input handler for a video game.

It has to handle arbitrary configuration, multiple actions per input, multiple inputs per action, arbitrary combinations of inputs, keyboard/mouse + controllers, various gamepad-related issues like using an axis as a button and vice-versa, and a (configurable) sub-frame polling rate.

It's about 75% done.
>>
File: smile_boys.jpg (128KB, 500x302px) Image search: [Google]
smile_boys.jpg
128KB, 500x302px
>>56543887

OH! i get it now. i think. is it because the hash function is the search function?
>>
File: 50_star_post.jpg (39KB, 392x372px) Image search: [Google]
50_star_post.jpg
39KB, 392x372px
>>56543913
>>
>>56543955
What do you mean by "search function"?
>>
>>56543955
>>56543971
Never come back here, you fucking faggot.
>>
>>56543981
In the faggot's defense, hash tables generally do require searching because of the possibility of hash collision.
>>
File: cherry-pie.png (518KB, 744x540px) Image search: [Google]
cherry-pie.png
518KB, 744x540px
>>56543913

so how is it O(n), if you still have to search another list, once you get to 1?
>>
Fucking around with Taylor series approximations. Made a trig library that doesn't use any math headers.
>>
>>56544000
A linear search is O(n)
>>
File: magnetic_field.jpg (627KB, 2048x1505px) Image search: [Google]
magnetic_field.jpg
627KB, 2048x1505px
>>56543981

If you want to find an item in the list, you run the hash function, which takes you to the smaller list.
>>
>>56543988
Yes. As has been discussed at great length...

>>56544000
It's not O(n). It's O(1). Searching through the bucket is O(k), where k is the average number of elements in a single bucket. The point of a hash table is to make k stable as the hash table grows in size, by choosing a good hash function and resizing the hash table as necessary.
>>
>>56544008

i meant O(1), sorry.
>>
>>56544022
That doesn't answer the question.
>>
>>56544031

Searching hash table is O(1) in the average case, O(n) in the worst case.
>>
>>56544032

?

i'd rather you tell me that you didn't know, than to pretend like you do, if you don't.

explain why a hash map is faster than indexing, please.
>>
File: windows_malware.jpg (132KB, 880x550px) Image search: [Google]
windows_malware.jpg
132KB, 880x550px
>>56544061

why is searching a hash table O(1)?
>>
>>56544083
The hash function runs in constant time, and the computed hash gives you the index where your key-pair is.
>>
>>56544068
>explain why a hash map is faster than indexing, please.
I have been, on and off, for the last 45 minutes. It's seeming pretty futile though, as you just keep asking the same fucking questions which I've already answered. If you want to learn about it then just read what I've already posted because I'm done.
>>
reminder that searching your entire harddrive is O(1)
>>
File: hackerman.jpg (58KB, 540x531px) Image search: [Google]
hackerman.jpg
58KB, 540x531px
>>56544099

why to you need the computed hash to give you the index, when you can just type it in when you're typing in the computed hash? it feels like that would just be saving time.
>>
>>56544115
What's the point of files? I still have to search a list of files to find something on the hard drive, which is O(n). Just give me a hard drive with data, no files needed, and I'm happy.
>>
>>56543623
that's some really pretty code.
almost makes me want to learn it.
>>
>course in c++
>vim instead of ide
will see how long until i regret this
>>
>>56544083

Emphasis here is average case. With a good enough hash function, and re-hashing as the hash table grows in size, the number of elements in any given bucket should be mostly below a certain constant. Outliers may arise that may have, say, a very large list in one bucket, which would make searching O(n) in a worst case scenario, but in most cases, search time can be bound to a constant factor.

It's very important to understand the difference between average and worst case. To put things into perspective, Quicksort is O(n^2) in the worst case, but for most inputs, it can be constrained to operate in O(n log n) time, and regularly outperform merge sort.
>>
>>56544126
You're trying too hard now
>>
File: zero_fucks.png (35KB, 625x626px) Image search: [Google]
zero_fucks.png
35KB, 625x626px
>>56544159

i can't stand posers. they assume that everyone is trying to do what they're doing.

if you weren't bullshitting you would be trying to learn something in here, not be fucking around trying to turn this into 9gag.
>>
>>56544228
>>>/reddit/
Seriously. Fuck off.
>>
>>56544228
I consider someone who said
>when you can just type it in when you're typing in the computed hash?
to just be trolling
>>
>>56544236
>>56544228
samefag
>>
File: haha_don.jpg (5KB, 164x158px) Image search: [Google]
haha_don.jpg
5KB, 164x158px
>>56544236

...pretty sure this is your entire vocabulary.
>>
how do hash tables really work? it's not a fuckhuge array by default and then the hash is the array index? when the hash table is empty or only has a few elements it's not necessarily a fuckhuge array is it? but how do you get an O(1) search if you don't have a fuckhuge array which you can simply index with the hash?
>>
File: jeb_hoodie.jpg (29KB, 400x428px) Image search: [Google]
jeb_hoodie.jpg
29KB, 400x428px
>>56544253

nope. i'm done. i'm just reading this: http://interactivepython.org/runestone/static/pythonds/SortSearch/Hashing.html?lastPosition=6797.333333333333, and wanted to take a break. let things marinate.
>>
>>56544279
You grow the backing array as necessary. Growing the array is O(n), but it's amortised.
>>
>>56544332
but how do you go from the key to finding the entry. if you can't simply jump into a giant array then don't you have to do a binary search into the small array or something?
>>
You have a fuckhuge array/vector of "buckets". Hash function takes your input string or integer or whatever into an index within the range of the valid indices of that array. The buckets can contain vectors, linked lists, or BSTs to allow for further searching if two or more elements hash to the same index. It is generally expected that most buckets will not contain a rather large list. If many elements are inserted into the hash table, the hash function can be modified, and the number of buckets can change. This factor allows the number of elements per bucket to be kept to a minimum, giving random access an average computational complexity of O(1). In the worst case, however, if you somehow managed to have half of the elements in a hash table in one bucket or something, your access times would be O(n), or O(log n) if you used a balanced BST instead of a list or vector.
>>
>>56544356
>Hash function takes your input string or integer or whatever into an index within the range of the valid indices of that array.
>within the range of the valid indices of that array
ohh i think this was the crucial part for me. so you actually use different hashes depending on the current size of the array?
>>
File: radiation.png (87KB, 1134x1333px) Image search: [Google]
radiation.png
87KB, 1134x1333px
I meant here:

https://www.quora.com/Why-is-it-quicker-O1-to-find-an-item-in-a-list-through-hashing-hashmap-than-it-is-do-go-directly-to-the-item-that-youre-looking-for
>>
>>56544349

# O(1) relative to the size of the table.
index = hash_function(key)

# O(1) in general. This is just an array indexing.
bucket = table[index]

# In the average case, this is O(1) in the number of elements in the entire table,
# because each bucket should generally contain very few elements relative to
# the size of the table as a whole.

# In the worst case, this is O(n) in the number of elements in the entire table.
# This might occur when a bucket contains, say, a third of all elements in the table.
value = search_bucket(bucket, key)


>>56544382

Yes. That's the point of hashing -- to index an array.

>>56544392

Quora's a shit site. Try linking to a site that doesn't hide everything behind an account wall.
>>
>>56544382
You can use the same hash, but take the remainder by the size of the backing array.
>>
File: themoreyouknow.png (808KB, 1280x931px) Image search: [Google]
themoreyouknow.png
808KB, 1280x931px
>>56544413
>>56544427
neat
>>
>>56544409
>image
In their ironic ignorance, they had to throw that line about cell phones in there.
>and does not cause cancer
>implying the majority of the microwave band doesn't alter voltage gradients across the cell membrane via its interaction with L-type voltage dependent calcium channels
>implying the result of this isn't an influx of Ca2+, degredation of cellular machinery, and an elevation of hsp70 expression
>Implying it doesn't increase rates of protein misfolding
>Implying chronic elevation of cellular stress and repair proteins doesn't act as a cancer promoter and elevate risk of carcinogenesis
>Implying it doesn't also cause double and single strand breaks
>Implying cells in their S and G2 phases aren't most vulnerable
>Implying this hasn;t been demonstrated repeatedly, and the author isn't just a physicist trying to play molecular biologist and suffering from the Dunning-Kruger effect, severely deluded to the point of naively assuming they understand every single machine in existence

Pathetic.
>>
File: do_your_best.jpg (82KB, 500x333px) Image search: [Google]
do_your_best.jpg
82KB, 500x333px
>>56544413

you're always here helping out, and you've been here for a while. i appreciate that.
>>
>>56544471
Your best is not always good enough.

>Source
Long term personal failure despite attempts at maximum output.
>>
File: never_lose.jpg (90KB, 300x250px) Image search: [Google]
never_lose.jpg
90KB, 300x250px
>>56544490
>>
>>56544515
I never lose because I cannot truly win. The dualism is discarded.
>>
>>56544471

Helping out noobs helps me not to lose my knowledge. I don't want to be the guy that, 15 year down the line, can't even reverse a goddamn binary tree. That said, hopefully I will be settled down with a career 15 years down the line and not have to answer interview questions that are mostly based on the shit I'll have done during my bachelor's degree.
>>
File: progress4.png (105KB, 1247x1171px) Image search: [Google]
progress4.png
105KB, 1247x1171px
Building a calendar widget for my budget tool

The gregorian date library makes it way too easy
>>
How'd I do?

static ArrayList<Integer> generatePrimes(int n) {
ArrayList<Integer> primes = new ArrayList<>();

if (n <= 1) {
return primes;
}

if (n <= 2) {
primes.add(2);
return primes;
}

else if (n < 5) {
primes.add(2);
primes.add(3);
return primes;
}

primes.add(2);
primes.add(3);

numLoop:
for (int x = 5; x <= n; x += 2) { //Skip even numbers
for (int prime : primes) {
if (x % prime == 0) {
continue numLoop;
}
}

primes.add(x);
}

return primes;
}
>>
>>56544738
bad
>>
>>56544764
Care to elaborate?
>>
File: 1407391263684.jpg (46KB, 400x400px) Image search: [Google]
1407391263684.jpg
46KB, 400x400px
>>56540727
>Church encoding
>when you have inductive types

Also, you can define dependent sum without W-types in Andromeda: https://github.com/Andromedans/andromeda/blob/master/examples/dependent_sum.m31

constant Σ : Π (A : Type) (B : A → Type), Type
constant existT : Π (A : Type) (B : A → Type) (a : A), B a → Σ A B

constant π1 : Π (A : Type) (B : A → Type), Σ A B → A

constant π2 : Π (A : Type) (B : A → Type) (p : Σ A B), B (π1 A B p)

constant π1_β :
Π (A : Type) (B : A → Type) (a : A) (b : B a),
(π1 A B (existT A B a b) == a)

constant π2_β :
Π (A : Type) (B : A → Type) (a : A) (b : B a),
(π2 A B (existT A B a b) == b)
>>
booooooooooring
>>
>>56544738
not too bad for a newbie and if you came up with it yourself but you might want to look at other algorithms

https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
>>
How'd I do?
primes :: Int -> [Int]
primes n = sieve 2 [2..n]
where sieve _ [] = []
sieve p [o] = [o]
sieve p ns = p : sieve (head rest) rest
where rest = filter (\x -> x `mod` p /= 0) ns

I feel like there's a way I can keep myself from repeating "rest" but I can't recall.
*Main> primes 0
[]
*Main> primes 1
[]
*Main> primes 2
[2]
*Main> primes 200
[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199]
>>
>>56545085
>p ns
I swear this was unintentional.
>>
How do I pass an argument to this bad boy?
>>
>>56545193
./a.out arg1 arg2 "arg 3 with spaces" arg4
>>
>>56545208
Thanks, not really sure what's going on in this section of the book.
>>
>>56545259
here's a simple example
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
int a = atoi(argv[1]);
int b = atoi(argv[2]);
printf("%d + %d = %d\n", a, b, a + b);

return 0;
}

$ ./a.out 5 10
15
>>
How can I successfully make a generic that takes a slice of blank interface{}?

No matter what I try I get type errors.

func test_array(data []interface{}) {
for i := range data {
data[ i ] = 0xff
}
return
}

....

x := make([]byte, 10)
test_array(x) // error: incompatible type


The above should work, but it does not.
>>
>>56545278
err, prints "5 + 10 = 15"
>>
>>56545259
You pass arguments through the command line.
argv It is basically a vector of pointers to the arguments (strings) you provided during the call from the command line. argv[0] being the name of the binary.
Remember, that you have to cast to the variable type before using, since c isn't smart in that way. E.g. atoi(),
>>
>>56545296
>cast the variable type
>e.g. atoi()
>>
>>56545311
>>56545311
>>56545311
>>
>>56545296
Why would you say "basically a vector" about something that actually is an array?
>>
>>56545323
He is mentally retarded/a pajeet.
>>
>>56545323
Take an educated guess, what "argv" stands for.
>>
>>56545085
Pretty bad, bro.
primes :: [Int]
primes = sieve [2..]
where
sieve (x:xs) = x : sieve (filter (dontDivide x) xs)
dontDivide d n = mod n d /= 0

*Main> takeWhile (<100) primes
[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
>>
>>56545405
Values.
>>
>>56545411
Y'all need to learn.
"The argv argument is a vector of C strings"
https://www.gnu.org/software/libc/manual/html_node/Program-Arguments.html
>>
>>56545428
It's still a pointer to array in reality, as C has no concept of vectors.
>>
>>56545428
>>56545437
Plus, GNU libc manual is not an authoritative source on how to interpret argv. I'd accept K&R or original Unix documentation. Not GNU.
>>
>>56545455
http://linux.die.net/man/3/argv
>>
>>56545480
>linking to perl docs this time
leave my sides alone
>>
>>56542791
shouldn't it be (and (((((((((((no)))))))))) ((((((((((no)))))))))) ?
>>
>>56541350
yeah i had noticed that, gonna update it lol
>>
>>56541211
Except that it is not. None of the files contain the GPL header, you were explained that in the past.
Thread posts: 318
Thread images: 43


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