[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: 313
Thread images: 29

File: casting_spels.jpg (75KB, 500x527px) Image search: [Google]
casting_spels.jpg
75KB, 500x527px
((lisp) edition)


Old:
>>54877214
>>
File: 200205132-001.jpg (126KB, 357x479px) Image search: [Google]
200205132-001.jpg
126KB, 357x479px
foris signatum puppis

java est melius quam lisp
>>
I have a copy of K&R that I've been working through (making a point to do all the exercises).
Does anyone know a good resource on more "modern" C practices? Online sources preferred.
>>
What's a really simple IDE for windows?
I've been using my other computer which has Mint on it, and greatly prefer just using gedit and compiling through shell, but Windows is more convenient overall unfortunately.
>>
>>54895357
>Modern C
It's called C++
The entire point of C is to never become "modern"
>>
>>54895408
I expected as much. If you don't know, then you needn't shitpost.
>>
>>54895408
It's called Go
>>
>>54895448
But is the truth, C++ changed radically as a language whilst C didn't. There isn't "modern C" because its just C.
>>
>>54895357
There's an Oreilly book calles 21st century C

Dunno if it's any good
>>
>>54895448
>Thinking it's a shitpost
Faggot
>>
>>54895357
C in 2016: https://matt.sh/howto-c
>>
>>54895483
This
>>54895448
Fucken fag
>>
>>54895483
>>54895493
>Get called out for shitposting
>Respond with even more shitposting
>>
>>54895490
Wasn't that post quite heavily criticized?
>>
>>54895501
We're (at least) two different persons you faggot
>>
>>54895482
>>54895490
Oh look -- Actual responses!
Thanks /dpt/
>>
>>54895482
it's not bad coming from K&R to get an update
>>
>>54895508
Yeah, but the author added critics in the page, so I thought it would be good enough if he read them too
>>
do we even still have janitors?
this is the second time from the same fucking old thread that we've had a significantly prebump thread
>>
so many folks butthurt that they can't wrap their heads around C

never gets old tbqf
>>
>>54895561
>c is hard
>>
>>54895574
apparently for /g/
>>
>>54895559
define significant
>>
>>54895561
U wot?
>>
>>54895636
10, 53
>>
>>54895468
>>54895408
Not true. C standards have changed from C89->C90->C->95->C11 and some conventions have been adopted to help structure code

i.e don't use goto, always typedef structs, #ifndef headers etc....
>>
>>54895647
53 -- sure. 10 is a slight overlap at most.
I can see why this would upset people on the spectrum though.
>>
>>54895675
>what is traditionalism
>what are /dpt/ values
Fuck off newfag, 10 is way too early
>>
>>54895702
s/newfag/neurotypical/

I get it, things didn't line up perfectly. Are you going to be alright?
>>
>>54895652
Asking for
>modern X
Is different from asking for
>list me the new stuff in the standard
Because really the changes in the C standard have been so few and so minor you can just sit and read them in 30 mins.
Furthermore, C89 is the same as C90 and what everyone learns these days. C95 isn't a thing, you probably meant C99.
>>
>>54895730
>be filthy degenerate
>break the law
>>i dont get it
>>
Quality thread so far, guys! Keep it up!
>>
>>54895827
Go kill yourself
>>
>>54895850
That's the spirit.

And remember, as long as the next thread is created PRECISELY when this one hits bump limit, all is well. The thread doesn't even have to contain programming discussion -- great, huh?
>>
What is the best language to start learning programming?
>>
>>54895907
>>>/wdg/
>>
>>54895897
After the bump limit is fine you dumbass, the point is don't fucking spam threads & split dpt posters
>>
>>54895940
You're right, that might interfere with the quality discussions going on right now.
>>
>>54895508
Yes. I follow him on Twitter and he's an obnoxious cunt, too.
>>
I'm a little confused about smart pointers in C++. It deletes the object it points to when the reference count goes to 0, but how does it know when to add to or subtract from reference count?

Sorry if it sounds like I have zero idea what I'm talking about, I've never used smart pointers before and am just reading about them currently.
>>
>>54896811
It creates a memory block for the ref counter, when you do a copy constructor/assignment, it increases the counter, when the other object goes out of scope and calls the descrutor, it decreases the ref counter, when the destrucotr is called and the ref counter hits 0, the mem blocks are freed
>>
>>54896811
Constructor adds 1
Destructor removes 1
>>
>>54895307
> melius
Cur putas quae java est neutri declinationis? Evidenter plebs es, cucule.

(defun nam-OP-homines-amat-p (OP)
(format t
(cond ((putat-java-melior-lispo) t)
(t nil)))
>>
Why doesn't base Python let me use a list of booleans as an index to a list?
>>
File: finland.jpg (909KB, 1982x1724px) Image search: [Google]
finland.jpg
909KB, 1982x1724px
Why does everyone here use such shit languages?
Everyone knows the best language is Finnish
>>
>>54896899
>>54896884
I see. Thanks
>>
>>54895402
Codeblocks
Codeblocks+mingw gives you gcc out of the box

Free. Just werks.
>>
>>54895402

Atom is pretty lightweight and close to gedit. Sublime text is also a good choice If you want .NET languages use Visual Studio

If you use Atom or Sublime text you'll have to use the compiler separately. Visual Studio has it built in
>>
>>54895561
>so many folks butthurt that they can't wrap their heads around C

Whenever someone says something bad about C, Cmen are wont to imply that they don't know it.
>>
>>54897144
> Atom
> lightweight
One. Quarter. Of. A. Gigabyte.
>>
>>54897250
think of how much memory you could've saved if you hadn't used all those full stops

or if you hadn't made such a worthless post in the first place
>>
>>54897144
Visual Studio Code > Atom and Sublime desu
>>
>>54897250
So? This would be noteworthy if it was 2000 and I still had a 20GB HDD.
>>
>>54897272
Nice argument.

Atom is still shit, and bloated shit too.

>>54897293
> Milennials
>>
>>54897250
>1980s
20MB hdds are normal, editor would be 100-200kb

>2016
2TB hdds are normal, Atom is 250MB

200KB/20MB = 0.01
250MB/2TB = 0.000125

You're an idiot.
>>
>>54897280

I tend to disagree, I think the package and module support in Atom/Sublime are a little better than Code. Just not enough community support to switch to code IMHO
>>
File: code bloat.jpg (99KB, 630x655px) Image search: [Google]
code bloat.jpg
99KB, 630x655px
>>54897337
>125%%%

>>>125%
>>
>>54897250
>Giving a shit about storage

It does take quite a bit of memory though... consistently in the top 3 out of about 12 applications
>>
>>54897337
> Being sloppy and lazy with resources is fine because we have larger storage.
>>
>>54897412
> Chrome
> Atom

Enough said.

>>54897337
The question is: why does editing text take up 250 fucking Mb.

Kids these days.
>>
>feminine kiddies using atom
>not using pen & paper like real men
>>
>>54897541
all the elements I assume
>>
>>54897541
copy
>>
python
list named 'whatever'
I see this
whatever[:]


I know that
whatever[-1] - last element
whatever[:-1] - all elements except the last
whatever[0] - first elements, duh
whatever[1:] - all elements except the first

but what the fuck does [:] do?

I see it in code

whatever[:] = [d for d in whatever if d not in yyy]
>>
>>54897559
that would be pointless I assume

>>54897562
copy does sound interesting, what do you mean?

and sorry for fucking up original and having to delete and repost
>>
>>54897586
basically if you created a new list from another list, it'd actually be a reference, so if you modified either element, both lists would get modified, with a copy you create a new list that has the same elements but do not reference each other
>>
File: 1464997529.png (140KB, 909x810px) Image search: [Google]
1464997529.png
140KB, 909x810px
>>54897562
>>54897609
seems it is equivalent of
new_list = list(old_list)


http://stackoverflow.com/questions/2612802/how-to-clone-or-copy-a-list-in-python
>>
>>54897541

list[a:b] is known as the splicing syntax.

it would be the same as defining something like

 def splice(self, a = 0, b = self.length, step = 1) 


where a is the start index and b is the end, and self is a list.

Fun facts about splicing:
- it has a return value.
- the return is a copy of the list from a to b
- step can be negative
- the indices can go in negative

So, an easy way to say "Operate on a copy of the list" is to say

 whatever[:] 


so you don't have to define a separate copy method for your list structure.
>>
>>54895408
>It's called C++
LOL!
Even the creator of C++ knows it's a piece of shit.

http://harmful.cat-v.org/software/c++/I_did_it_for_you_all
>>
>>54897627
>linking cat-v
>>
>>54897681
It's an interview, I don't care where it's hosted. Besides, I like cat-v for the most part.
>>
>>54897687
>It's a blogpost, I don't care what the source is, besides I care about the source
>>
# Evaluates as "hi", implying [] is interpreted as True:
if not []:
print("hi")
# Evaluates as no printing, implying [] is interpreted as False:
if []:
print("hi")
# The following two print, implying the populated list is interpreted as True, no matter what's in it
if [0]:
print("hi")
if [1]:
print("hi")
# Syntax error when we use the xor operator ^ or the syntactic sugar function xor() from operator
from operator import xor
xor([],[1])
# TypeError: unsupported operand type(s) for ^: 'list' and 'list'

Why the fuck is this behavior present?
>>
>>54897699
It's not a blog post, it's an interview transcript. Where it's hosted is irrelevant even if I do like the website.

You must be a terrible programmer--can't understand simple logic.
>>
>>54897627
>referencing satire from mentally ill people to the point that one of their leaders committed suicide to prove your point

uhhh
>>
>>54897721
>it's not a blog post, it's a blog post about a fictional interview
>>
>>54897687

It's made-up, you idiot.
>>
Gearing up for a weekend of building up my resume. Gonna read a chapter of my got book, gonna try to write a windows (command line interpreter) shell with flex and bison, gonna install Java server faces and mysql and apply what I've been reading about for the past few weeks.
I've done enough of C and *nix for now.
Spring vs JSF? Does this question belong in /Web Dev/?
>>
>>54897712
Makes perfect sense.
MonadPlus []
mzero = []
>>
>>54897712
Python has this implicit thing in regards to boolean evaluation that empty strings/lists etc yield False.
>>
>>54897712
and to make matters worse, evaluating a list as an implicit condition is the officially recommended way to check whether a list is empty or populated in Python
>>
>>54897712

what behaviour?

The first two lines are: if not false, which is true and if false, which is false.
>>
>>54897754
I know that it does.

My complaint is that it's not consistently implemented. If it's going to interpret empty lists as False in explicit conditionals, it should have hte same behavior in other logical functions.
>>
>>54897744
>got book
Shit. Git book
>>
>>54897781
seems like an oversight
>>
>>54897778
See: >>54897781

I don't mind that lists are implicitly logical. What I mind is the inconsistent implementation.
>>
>>54897781
Eh it's pretty common for interpreted languages to have inconsistent behavior.
>>
My code works fine until I try to output such a large number. What the fuck is up?

int main(int argc, char** argv) {
unsigned long first = 0, second = 1, third = 0;

for(unsigned long i = 0; i < 4000000; i++){
first = second + third;
third = second;
second = first;
cout << first;
cout << "\n";
}

return 0;
}
>>
>>54897627
errytime
>>
>>54897828
Overflow?
>>
>>54897796

we're not dealing with macro replacements for true and false here.

if you go
if 1 == [2] 
you wouldn't expect to be evaluating
 if true == true 
.
>>
>>54897842
Are you suggesting everything should be converted to bools before comparing?
>>
>>54897860

no, I'm saying that it's correct for that behaviour to NOT happen.
>>
>>54897876
not takes a boolean as an input so it SHOULD convert
>>
>>54897842
Given that
1==True
and the only way to do element-by-element comparisons in Python is a clunky list comprehension statement, yes actually, I would expect 1==[2] to be equivalent to
True==True
.

Now, if this were R, where comparisons between lists automatically concatenate the smaller list and perform element-wise comparisons, I'd agree with you.
>>
Got an offer today, moving to the enterprise from shitty startup, 16% raise + yearly bonus, and some actual health benefits.
>>
>>54897891

so !0 == 1 should be true? What about !0 == 100? Does this imply that 1 == 100 should be true?
>>
>>54897918
>so !0 == 1 should be true?
Yes, because ! has precedence over the comparison and converts the value into a Boolean.

>Does this imply that 1 == 100 should be true?
No, because there you're comparing integers, not Booleans or an integer and a Boolean.
>>
File: 1377082502339.gif (2MB, 265x192px) Image search: [Google]
1377082502339.gif
2MB, 265x192px
>>54897913
>>
>>54897918
What the fuck are you talking about?
!0 == 1
not(0) == 1
not(false) == 1
true == 1
1 == 1
true

!0 == 100
not(0) == 100
not(false) == 100
true == 100
1 == 100
false
>>
>>54897959
well, i thought I was posting the one where the woman is dancing and dryhumping the guy.. but whatever that ones relevant i guess
>>
>>54897976
lol, you got same-time-posted image swapped
>>
File: 6s75vtH.png (2KB, 191x91px) Image search: [Google]
6s75vtH.png
2KB, 191x91px
>>54897965
>>
>>54897997
I was talking about how it should be, not how it is

>>54897957
>>54897958
>>54897959
>>54897960
>>
>>54898006
Wait, can images be swapped across boards?
>>
File: 190wz.gif (2MB, 384x216px) Image search: [Google]
190wz.gif
2MB, 384x216px
>>54897985
nah, i just thought I recognized the thumbnail
>>
>>54898025
yes
>>
>>54897997
>>54898006
Haskell does not have this problem.
>>
>>54898025
if two images are posted at hte exact same time, sometimes 4chan shits the bed and switches them
>>
>>54897840
I thought my unsigned long can store numbers around 4.3 million.

Hmm...
>>
FFS

>SLI always switches itself off fucking magically for seemingly no reason
>Need to close Chrome to enable SLI for whatever reason
>Incognito tabs

Fuck you Chrome
>>
>>54898079

it's not 4.3 million you dingus, it's the 4000000th fibonacci number
>>
>>54898079
So what exactly is the problem?
>>
>>54898111
>falling for the multiple GPUs meme
>>
>>54898167
>falling for the ocaml meme
>>
>>54898202
>falling for the "falling for the meme" meme
>>
>>54898217
>falling over
>>
>>54898235
>>
>>54898079
>835951 digits
>less than 4.3 million

uhh
>>
>>54897997
not(0)==true==(bool)100==100!=0
>>
File: 1462369642505.png (1007KB, 1092x698px) Image search: [Google]
1462369642505.png
1007KB, 1092x698px
is the anon that developed/was developing this booru browser still around?
>>
>>54899228
kys kys kys kys
>>
>>54899246
What's wrong?
>>
Tell me what this code is supposed to do
>>
>>54899398
>typedef void

Nothing fucking useful
>>
>>54899398
>tfw "coding" is so mainstream and peddled by the kikes they made a tv show out of it
>>
>>54899398
>typedef unsigned long u64
. . P . .
N . O . T
. . R . .
. . T . .
. . A . .
. . B . .
. . L . .
. . E . .
>>
>>54899398
it's really poor quality code, the only real clues for what it's supposed to do are the function names
>>
>>54899494
and the type names (enc - encoding probably)
>>
>>54895652
>don't use goto
STOP SAYING THIS
>>
>>54899531
THIS
>>
File: laugh batman.jpg (5KB, 110x126px) Image search: [Google]
laugh batman.jpg
5KB, 110x126px
>>54899398
>TOneverDO
>>
>>54899592
https://www.youtube.com/watch?v=Qf0kC-MJZrU
>>
>>54897565
 whatever[:] 
is the same as
 whatever 


it's just two ways of representing all elements of a list

for example:


whatever =[ 123,54,65,88,77,44,11]
whatever[:] = [i for i in range(10) if i%2==0]

print whatever



whatever is now
 [0,2,4,6,8] 
>>
>>54899661
>
whatever = [i for i in range(10) if i%2==0]


Does this do the same thing?
>>
>>54899740
yes.
 whatever[:] 
is the same as
 whatever 
>>
>>54899797
>self-taught idiots on /g/

No it isn't the same. Using the slice notation makes a copy.

whatever[:] is shorthand for copying the whole list.

a = [1, 2, 3]
b = a
c = a[:]
a.append(4)


What do you expect to see:
print b
print c


You should be able to solve this.
>>
>>54899661
>>54899797
Not really. Consider the following.
>>> mylist = [1, 2, 3, 4, 5]
>>> reference_list = mylist
>>> reference_list
[1, 2, 3, 4, 5]
>>> copy_list = mylist[:]
>>> copy_list
[1, 2, 3, 4, 5]
>>> mylist[0] = 5
>>> mylist
[5, 2, 3, 4, 5]
>>> reference_list
[5, 2, 3, 4, 5]
>>> copy_list
[1, 2, 3, 4, 5]

The [:] takes a copy from the start of the list to the end. This means that any alterations in the original list do not occur in the copy.
>>
>>54899869
He's right bruh, changing whatever[:] to changes whatever
>>
File: 1464033727551.jpg (48KB, 604x453px) Image search: [Google]
1464033727551.jpg
48KB, 604x453px
what does the world need that I can make as free software? I'm an above-average C++ programmer with some free time, a one man team however.
>>
File: trash_look_at_the_time.png (48KB, 455x455px) Image search: [Google]
trash_look_at_the_time.png
48KB, 455x455px
>>54895652
>always using typedef on structs
>>
Help me DPT

I'm stuck in a shitty place where I want to be writing code to relax but everything I want to do requires too much research/documentation. I don't think anything I'd want to do would actually be too hard, but I find actually coding and debugging relaxing, not combing through documentation and trying to figure out how to use libraries I'm unfamiliar with.

The only language I truly feel like I can sit down and write without any outside reference is C, but writing anything non-trivial in C kind of sucks -- or at least I don't know enough about good design in C to make it not suck.

Aside from macros, I think I'm almost at the point of being very comfortable in Common Lisp.

Any advice?
>>
>>54897337
Sure, let's assume that's a decent argument. By your logic, big files ought to be more common nowadays than in the 90s. So why the fuck does Atom choke on a 5MB file while Vim handles it just fine?
Answer: because it's shiny bloatware garbage
>>
>>54899921
that's inconsistent as shit
>>
>>54900075
Which one?
>>
>>54900107
whatever[:] = foo should not compile or it should not affect whatever if c = a[:] makes a copy of a
>>
>>54899957
Keep learning Lisp, I guess. Common Lisp is like the C++ of lisps though. Not in a bad way really, it's just a huge ass "and the kitchen sink too" language. You could try looking into a Scheme if you want more emphasis on coding instead of reading docs. Or Racket if you want Scheme-like but with lots of modules and libraries. If you're already comfortable with CL it might be better to stick with that.

Getting to that point is just a matter of time and getting comfortable with your toolset.
>>
>>54899398
>typedef void "garbage"
>typedef int "garbage"
I wonder what enc_cfg_t is? two dude's initials who work on set and took CS 101? you can see the main function, its indented in for some reason with the closing curly on a different indent. its calling a void function that prints some int 17 times. they have a bunch of garbage operators and hex number to fancy it up a bit.

the //O(n) lol no thanks comment is a nice little easter egg though, but that loop doesn't do much.
>>
>>54897056
As far as I remember lists are indexed by ints. You can do a map instead but the key needs to be immutable. Lists are not immutable. Use tuples instead.

Could be wrong. Haven't done any serious python in a while.
>>
>>54900123

c and a are two completely different objects even though they are identical. [1]

b and a are literally referencing to the same list in the memory. Modifying the list using a means you will see the same changes when you acces b

[1] http://henry.precheur.org/python/copy_list
>>
>>54899398
>typedef implementation specific variable
>stdint.h exist
>typedef void
>indentation fucked up
> on main() call
>closing brace on same line as last statement

was this purposely made bad.
>>
>>54900230
yes but whatever[:] = foo affecting whatever makes it inconsistent
>>
>>54900292
Maybe because
whatever[:]
evaluates to itself? idk
>>
>>54900292
Not sure if we're thinking the same thing, but I didn't think slicing could be performed on the LHS, but I guess it can.

>>> whatever = [1, 2, 3, 4]
>>> whatever
[1, 2, 3, 4]
>>> whatever[:] = [i for i in range(10) if i % 2 == 0]
>>> whatever
[0, 2, 4, 6, 8]
>>> whatever[0:2] = [1, 3]
>>> whatever
[1, 3, 4, 6, 8]
>>
>>54900485
>>>> whatever[0:2] = [1, 3]
ok in that case i guess it's "intutitive" but holy shit python is such a shitlang
>>
How do you scale up an SAAS? More servers?
>>
What would be the best language to spend a year on, around 33 hours a week (going to do 3 hours a weekday, and 8 on the weekend) to get a job at the end of the year? Just managed to get on a year-long lease and after being fucking broke I need to learn a real skill to get out of this rutt. Just trying to decide between web dev, or maybe like.. Java.. just something I can do constantly and hone it over a year.
>>
Since nobody brings it up anymore, is Nim still a meme language?
>>
>>54901197
literally your own
>>
>>54901210
My own?
>>
>>54901238

Yes. Create your own memelang.
>>
>>54901252
One day there'll be a major language invented in /dpt/
>>
Hello friends, I am a beginner programmer. Here is the code I wrote to find the first triangular number obtained by n(n+1)/2 where n is an integer that has over 500 divisors, here is my code so far.

public class PEP12 {
static long startTime = System.currentTimeMillis();
public static void main(String[] args){
int i = 1;
int sum = (i*(i+1))/2;
int div = 0;
int maxDiv = 500;
int curDiv = 0;
int spe = 0;
for(int j = 1; j <= sum; j++){
while(div != maxDiv){
sum = (i*(i+1))/2;
if(sum%j == 0){
div++;
curDiv = div;
}
if(div != maxDiv){
div = 0;
i++;
continue;
}
if(div == maxDiv){
spe = sum;
System.out.println("The number with at least 500 divisors is " + spe);
break;
}
}
}
long endTime = System.currentTimeMillis();
long totalTime = endTime - startTime;
System.out.println("Sum: " + sum);
System.out.println("The number " + sum + " has " + curDiv + " divisors.");
System.out.println(totalTime + " milliseconds");
}
}
>>
what's the best book for learning c++?
do i need to learn c and c+ first?
>>
>>54901287
I would just like to get a tip on where I'm screwing up, if somebody could guide me in the right direction that would be great!
>>
>>54901198
pretty much just a C frontend
>>
>>54901287
you're using while div!=maxDiv instead of an if. Thus you're never really incrementing j.
>>
>>54901318
>all the meme features
>just a C frontend
>>
>>54901197
java and/or C++
>>
>>54901294
pls respond
>>
>>54897028

>cucule

Vev puer.

Abdomen meum in orbita ascensum est...
>>
>>54901451
C++ Primer Plus
you don't have to read the whole thing, drop it whenever you feel you can whatever project you wanted to, and go back to books later
>>
Just wanted to ask this one more time.
I'm trying to make an online multiplayer game with SDL. I never managed to get SDL_Net working with IPv6. Is there some other way I can get it to work? Right now, when the game starts, the players type in an IP address and it connects them, but since it doesn't support IPv6, I can only use 127.0.0.1. Is there any other way I can get it to work (preferably without re-writing the entire thing in another language)?
>>
>>54901516
thx m8
>>
I just made an initialization function for making SDL less cluttered, and I had to fucking reference a pointer.
SDL_Window *window = NULL; //creates a pointer to a screen right?

init(window); //This passes the pointer (NULL) to the function, but does NOT modify window

//in other function, window = sdl_window_init_blah();
//this modifies the local window, but does not assign window in main




SDL_Window *window = NULL;

init(&window); //allows editing of window, function is definied with init( SDL_Window ** window)

//in other function, *window = SDL_init_window_blah();
//this works



Fuck programming. The program didn't even throw any errors, because technically, assigning the local copy a pointer does pass initialization tests (because it is no longer null).
>>
>>54901735
this is babby stuff bruh
>>
How do I do this in haskell?
Define a type M C A where any M C is a monad
>>
>>54901538
You grab a different network library and might have to do some type conversions. Nothing crazy.

Or just have your users use tunngle/hamachi/whatever
>>
>>54901538
>>54901764
P.s:

http://www.ibm.com/developerworks/library/wa-ipv6.html

The hard way
>>
>>54901762
Here are the definitions:

unique :: Eq t => [t] -> [t]
unique [] = []
unique (x:xs) = x:uxs where
uxs = unique [y | y <- xs, y /= x]

data Categorised c a = Categorised a [c]
categories (Categorised c _) = c

return x = Categorised x []
(Categorised x c) >>= f =
let Categorised x' c' = f x in
Categorised x' (unique (c ++ c'))

Was trying
Eq c => Monad (Categorised c) &
forall c. Monad (Categorised c)
>>
>>54901764
Fucking hell, SFML doesn't support IPv6 either. I did find a fork called SDL_Sixnet but it won't compile.
I am wondering, though, why do I have two IP addresses? When I use ipconfig, it tells me that I have a IPv6 address and an IPv4 address.
>>
>>54901833
...because they're different. ipv6 and ipv4 don't represent the same information, and ipv4 can't "expand" into ipv6 by being like 0.0.0.0.x.x.x.x
>>
File: categorised monad.png (203KB, 2132x666px) Image search: [Google]
categorised monad.png
203KB, 2132x666px
>>54901819
The behaviour
>>
>>54901854
I guess I just don't understand why I need to have two of them. What information does v4 have that v6 doesn't? Why can't I use the v4 address in the game?
>>
>>54901881
>I guess I just don't understand why I need to have two of them. What information does v4 have that v6 doesn't? Why can't I use the v4 address in the game?

because v4 is going away. "soon"
>>
>>54901833
I checked the SDL_sixnet, it's meant for SDL 1.2.4, but you might be able to force it to SDL2 if you point it to the right directories.
>>
>>54895467
This
>>
File: launchpack.webm (3MB, 960x540px) Image search: [Google]
launchpack.webm
3MB, 960x540px
/dpt/-chan, daisuki~


>>54899398
>u64 HammingCtr (u64 a, u64b)
i would say that Ctr here does mean counter: Hamming weight is a technique that can be used to count 1 bits. You would have known that if you had read hacker's delight, programming literacy is a serious matter.

https://en.wikipedia.org/wiki/Hamming_weight

>>54897565
[:] returns a copy of the list.

>>54895508
It has been updated since then.

>>54895482
>Dunno if it's any good
It's not.

>>54895448
He's right.
>>
>>54901762 >>54901819 >>54901879
Anyone?
>>
File: help.jpg (60KB, 912x566px) Image search: [Google]
help.jpg
60KB, 912x566px
i heard this software could help me make programs, but i only see the option for apps

help
>>
File: mons.webm (3MB, 900x506px) Image search: [Google]
mons.webm
3MB, 900x506px
>>54902099
there an epub
http://golibgen.io/view.php?id=864155
>>
File: 659945641.png (107KB, 792x1023px) Image search: [Google]
659945641.png
107KB, 792x1023px
so how exactly do you tie in the connection between code and an actual program or use for the program outside of terminal?
just started reading this.
>>
>>54902206
What do you mean?
>>
File: fragezeichen yui.png (94KB, 396x395px) Image search: [Google]
fragezeichen yui.png
94KB, 396x395px
I have a 16-bit WAV file

What is the best way in C to consistently read it into an unsigned array of 16-bit integers?

I hear the bit depth of things like short differs according to platform?
>>
>>54902214
libsndfile

http://www.mega-nerd.com/libsndfile/
>>
>>54902210
like so far I'm only making tiny code for simple stuff, when does that turn into a real complex program with a GUI and stuff.
How do you tie all the code into one program?
>>
>>54902231
However you want to desu

As for GUIs, normally with libraries that provide core functionality
>>
>>54902228
Surely I shouldn't need an entire library for reading binary data to an array of integers in C.
>>
>>54902240
Then don't compile the whole library.

If you really want to be a cock about it, look at the wav header. Also stab yourself in the eyeballs, because it's not standardized.
>>
>>54902231
Use Win32 for GUI libraries. Everything else is shit or terrible to work with
>>
File: svvsvsv.jpg (729KB, 1920x1018px) Image search: [Google]
svvsvsv.jpg
729KB, 1920x1018px
>>54902239
I've just never seen anyone make a bunch of code go from a bunch of words and lines to an actual working executable or something real, that step has always been like shrouded by mystery for me.
>>
>>54900816
>this thing works as you'd expect it to
>such a shitty language wtf

What kind of argument is that?
>>
>>54902231
If you want maximum bang for your buck, try OpenGL. It's a pretty simple C api, but lets you draw colorful stuff in 3D.
>>
>>54899931
Better GUIs for the plebs. Pick your favorite open source software, write a GUI for it. You're awesome /g/entleman
>>
CL or scheme?
>>
My shitty function throws a segmentation fault at the return statement, but only if the file is not a png. There should be no difference in behavior.

#include <iostream>
#include <string>
#include <fstream>
#include <cstdint>

bool png_header (std::ifstream &png) {
uint8_t id[4];
png >> id;
if (!(id[0] == 137 && id[1] == 80 && id[2] == 78 && id[3] == 71))
return false;
else
return true;
}

int png(std::ifstream &png) {
using namespace std;

png.seekg(0, ios::end);
int png_size = png.tellg();
png.seekg(0, ios::beg);

if (!png.is_open())
{
std::cout << "Error opening file.\n";
return 1;
}
if (!png_header(png))
{
std::cout << "Not a png.\n";
return 1;
}
return 0;
}
>>
>>54902568
make it less shitty faggot, start using namespaces for starters you autistic bithc
>>
>>54902568
>C++ memestreams
>>
>>54902618
Why might having the function return false and going down that branch yield a segmentation fault, when the call right before it doesn't?
>>
>>54902568
fuck does it do?
>>
>>54902664
All it does right now is read the first 4 bytes and if they don't match, return 1 to the caller (eventually) signalling that creating a decompressed bitstream in memory failed.
>>
Nvm, didn't realise I needed to seperately implement Applicative and Functor

Haskell is pretty cool, Lint is fucking amazing
>>
>>54902640
I'll just ask somewhere else.
>>
>>54902568

Anon, no one's going to judge you if you just use libpng instead of rolling your own, possibly buggy implementation.

https://refspecs.linuxbase.org/LSB_4.0.0/LSB-Desktop-generic/LSB-Desktop-generic/libpng12.png.sig.cmp.1.html
>>
>>54902734
I can't program anything to begin with, so it doesn't matter what I use. If that which is called isn't broken, it'll just switch to the thing that's calling.
>>
You can now debug your Rust programs in gdb
Debugging Rust on just about any platform (even embedded) has now gotten easier with this

Is Rust still a meme language?
>>
>>54902717
Do you have a debugger? Can you be more specific where it faults?
>>
>>54902695
Try to simplified it, I can think of just ONE function to do all this, more efficiently and not to mention, use std namespace for sake of readability and debugging.
>>
>>54895080
The lisp general moved to lainchan.
>>
>>54902551
Scheme for learning functional programming
CL for actually making your programs do useful things

>doing useful things in a functional language
>>
>>54902767

It will be a meme language until someone other than Mozilla uses it for something serious. That said, it's not a terrible language.
>>
>>54902767
>Is Rust still a meme language?

Absolutely.
I didn't say that makes it a bad language.

Coincidentally it is also a bad language.
>>
>>54902776
I don't know anything about debugging beyond generating builds with the right information. Tried to use gdb but was too impatient / stupid to figure how to make it run the program with the right arguments.

It faults at:
if (!png_header(png))
{
std::cout << "Not a png.\n";
return 1;
}

This return, and never successfully returns to the caller. I can't see what might be corrupting the stack or altering the return address. If the test doesn't fail it seems to return correctly.
>>
>>54902825
Does it ever output?
>>
>>54902779
I don't see how simplifying it will fix the segfault.
>>
>>54902850
Yes. I added another output after the original call, which never executes.
>>
>>54902825
return 1 doesn't mean a successful return. that's return 0
>>
>>54902877
It's not supposed to be successful.
>>
>>54899398
From "The Go Programming Language", see: https://github.com/adonovan/gopl.io/blob/master/ch2/popcount/popcount_test.go
>>
>>54902873
What the fuck. It's not the return statement, it's just that the call evaluated as false. It segfaults even with the return commented out.
>>
>>54902783
Scheme isn't functional just fyi
>>
File: 1464616114468.jpg (1MB, 1000x1412px) Image search: [Google]
1464616114468.jpg
1MB, 1000x1412px
What are some great programming related movies?
>>
>>54903706
Erlang and Erlang 2
>>
File: lay_the_foundation_pupper.jpg (133KB, 500x553px) Image search: [Google]
lay_the_foundation_pupper.jpg
133KB, 500x553px
>>54895080
Which is better for variable names and functions/methods/routines?
camelCase
underscores_as_spaces
alllowercase
>>
>>54904021
Underscore followed by numbers
>>
>>54904021
The superior naming scheme
x
xx
xxx
xxxx
xxxxx
>>
>>54904021
>variable names
lowercase
>functions
lowercase
>types
Titlecase
>enums and #defined constants
Titlecase
>macros
UPPERCASE, whatever
>>
>>54904021
>using named functions
I only use combinators
>>
>>54904021
I use camelCase when doing C++/Java, and underscore_as_spaces when C.
>>
>>54904021
camel case
>>
Do I need to construct a tree to solve Project Euler 18
>>
>>54897337
250MB for a fucking text editor that does no more than a 1980s text editor.
>>
>>54904312
>does no more than a 1980s text editor
>>
>>54904356
Yes, doing less with more.

Drawing a shitty scrollable shrunken outline of the text is not a useful feature, by the way.
>>
>>54904434
someone's got no taste
>>
>>54904186
No, there's a much simpler way.
>>
>>54904458
What is it?

My idea is get the sum of each path then store sum if it is bigger than the previous sum. My idea is how to make the "paths".
>>
java or python?
>>
>>54904502
>then store sum if it is bigger than the previous sum
You're on the right track. You don't need the total sum for every path. Work with partial paths, and you can eliminate some paths immediately.
>>
>>54904561
Sounds complicated. But I'll try this one. What structure can this be done with?
>>
>>54904450
Yeah because I don't like your hysterically bloated pre-riced editor that runs like a drunken slug because it's some HTML & JS nightmare.

>>54904560
Go. Python if not.
>>
>>54904583
>Sounds complicated.
It's not.
>What structure can this be done with?
You don't really need any data structures. All you need is to keep track of the partial sums, so an array is enough.
Here's a hint: work row by row.
>>
>>54904312
minimap
>>
>>54904560
Neither.
They're both meme langauges.
>>
>>54904643
So a 2D array?
Something like this?
int arr[] =  { {3},  
{7, 4},
{2, 4, 6},
{8, 5, 9, 3}


This doesn't seem legal
>>
>>54904675
>Drawing a shitty scrollable shrunken outline of the text is not a useful feature, by the way.
>>
>>54904823
    int arr[][4] = {
{3},
{7, 4},
{2, 4, 6},
{8, 5, 9, 3}
};

This works in C and C++. But that's just how you store the input data. To get the solution, you can work with just a single array to contain the partial sums.
>>
>>54886193
Got any sites I can look for it once it's finished? Like github or something?
I'm really interested
>>
>>54904948
How do you check left and right with this without going out of bounds?
>>
>>54904948
Wouldn't this create gaps?
>>
>>54905087
At row r and column c
parent: [r-1][c-(c%2)]
left child: [r+1][c]
right child: [r+1][c+1]

You just need to make sure you're not at the first or last row.

>>54905093
Yes, it wastes about half the assigned space, but that doesn't really matter for this problem.
>>
>>54902270
you sounds like you are in terrible need of installing gentoo


jk just install ubuntu and learn the unix way
>>
>>54905159

#include <stdio.h>

#define HEIGHT 15

int main()
{
int row, col;
int triangle[HEIGHT][HEIGHT] = {
{ 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 95, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 17, 47, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 18, 35, 87, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 20, 4, 82, 47, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 19, 1, 23, 75, 3, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 88, 2, 77, 73, 07, 63, 67, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 99, 65, 4, 28, 6, 16, 70, 92, 0, 0, 0, 0, 0, 0, 0 },
{ 41, 41, 26, 56, 83, 40, 80, 70, 33, 0, 0, 0, 0, 0, 0 },
{ 41, 48, 72, 33, 47, 32, 37, 16, 94, 29, 0, 0, 0, 0, 0 },
{ 53, 71, 44, 65, 25, 43, 91, 52, 97, 51, 14, 0, 0, 0, 0 },
{ 70, 11, 33, 28, 77, 73, 17, 78, 39, 68, 17, 57, 0, 0, 0 },
{ 91, 71, 52, 38, 17, 14, 91, 43, 58, 50, 27, 29, 48, 0, 0 },
{ 63, 66, 4, 68, 89, 53, 67, 30, 73, 16, 69, 87, 40, 31, 0 },
{ 4, 62, 98, 27, 23, 9, 70, 98, 73, 93, 38, 53, 60, 4, 23 }
};


/* Get partial sums from the bottom then pile up to the top */
for (row = HEIGHT - 2; row >= 0; row--) {
for (col = 0; col <= row; col++) {
int left = triangle[row + 1][col];
int right = triangle[row + 1][col + 1];
triangle[row][col] = triangle[row][col] + left > triangle[row][col] + right ? triangle[row][col] + left : triangle[row][col] + right;
printf("%d %d : %d \n", row, col, triangle[row][col]);
}
}

printf("Maximum Sum: %d\n", triangle[0][0]);
return 0;
}

/* Answer: 1074 */


ok got it
>>
Can someone suggest me a simple game engine like XNA/Monogame but for C. I don't really like OOP...
>>
>>54905714
Roll your own.
>>
>>54905806
Not good enough...
>>
>>54905837
It's more fun though.
>>
>>54905714
something like allegro ?
http://liballeg.org/
>>
FUCK UML and FUCK visual diagrams.
Text documentation is superior in every single way.
I hate this meme shit, I want out.
>>
>>54905876
How would Pajeet write code without UML?
>>
>>54905876
Visual diagrams are useful when there are portions of your code communicating with others. Unfortunately, it doesn't work with inheritance hierarchies (which is probably what your profs are making your do with your UML) because nothing "communicates".

I use visual diagrams to model applications when I'm writing in Go, in an HDL, and when my projects communicate via shared libraries.
>>
How do I compensate for the extra 0.01% if I use this to divide by 10?

num * 205 >> 11
>>
>>54906132
num / 10
>>
What's a great book for Java?
>>
>>54906132
>using mutliplication
>ever
>>
>>54906141
Trying to solve the DPT challenge about reversing a number mathematically. The only thing I haven't gotten down was the division by 10 with right shifts method.
>>
>>54906132
Add 0.01% to the sum.
>>
When will native development on android git gud?
>>
>>54906260
They're working on it famalam. At Google IO 2016 they announced proper NDK support in Android Studio.
>>
>>54906207
Here's what I have so far. I used BigInteger to avoid overflow issues.

http://pastebin.com/8J2npjEw

Can I take my poo to the loo now?
>>
>>54906286
That's good news.

Is it announced in this presentation?
https://www.youtube.com/watch?v=70WqJxymPr8
>>
>>54906132
You don't compensate, you let the compiler do that for you. It already has the necessary multiply and shifts worked out for a lot of common numbers. If you want to do it without relying on the compiler write a script to find the multiply and shift for you. Personally, I would loop through the possible shifts and calculate the multiplicand that matches it, it sped up the time to computer each pair by 4 orders of magnitude when I did this problem.
>>
>>54906344
They've mentioned it in the keynote.
Don't know about a presentation though.
>>
>>54906352
time to compute*
>>
File: pic related.png (1MB, 982x845px) Image search: [Google]
pic related.png
1MB, 982x845px
I'm currently learning python as my first programming language.

However, I'm interested in learning processing (and hence arduino IDE) to create some parametric designs (future career related) - Problem is that these are Java based.

Will I get too confused if I do both in tandem? or shall I just suck it up and switch to java?
>>
>>54906448
Haven't barely started programming and you speak in buzzwords. I fear for the next generation.
>>
>>54906503
buzzwords?

I hope you're not referring to 'parametric design' as a buzzword.

I'm an engineer. I work for a firm that designs everything from skyscrapers to sculptures and form finding is a huge part of what we do - especially when it comes to generating geometry for finite element analysis.

Designs often change quite late on in the process, so having the ability to parametrically define geometry and modify that geometry results in a huge resource saving. I'm talking months of manual work against a week of intelligent work.

I've been studying the design workflows for parametric design for quite a while now. Now I want to actually get into the nitty gritty.
>>
>>54906574
You forgot the following:
>web scale
>cloud
>IoT
>VR
>>
>>54906574
No one else here does that. We program for hobby.

>>54906448
What the hell does industrial design have to do with Arduinos?
>>
>>54906632
Not industrial design.

The IDE for arduinos is based on Processing.

>No one else here does that. We program for hobby.

Yeah that's great, but you guys know a lot more than I do about learning languages. I'm looking for advice on if it's a really terrible idea to 'mix' languages for use in different contexts when just starting out.

>>54906611
thanks senpai.
>>
>>54906448
Just learn C and do it manually.
What are you? a woman?
>>
>>54906660
>Processing
How incredibly generic. Every field has what they call "processing". Mind elaborating?

Mix languages? Like using multiple languages in one application? That's fine. You'll have to use C++ to program Arduinos to get data, retrieve data and process it with another application which can be written in whatever and run on a desktop.
>>
>>54906692
>Every field has what they call "processing". Mind elaborating?
I took it for granted that people here knew about the programming language called 'processing'
Info:
https://processing.org/
https://en.wikipedia.org/wiki/Processing_(programming_language)

>Mix languages? Like using multiple languages in one application? That's fine. You'll have to use C++ to program Arduinos to get data, retrieve data and process it with another application which can be written in whatever and run on a desktop.
Ah ok, fair enough. Thanks.

>>54906662
>What are you? a woman?
Yes.
>>
>>54906660
Processing has nothing to do with arduino m8.

The Arduino IDE is literally just to give you nice syntax highlighting and reduces the compiling options to a single button.
There's no visual or graphical aspect to it at all, I usually edit sketches in notepad++ so I can use the plugins.

>>54906692
It's actually a language, which some fucktard decided to call "Processing" because that would never be confusing, ever.

It's pretty much made for design plebs who have no idea what they are doing, much like how COBOL was used.
>>
>>54906743
>Yes.
Then what the fuck are you doing here? fuck off.
>>
>>54906746
>It's pretty much made for design plebs who have no idea what they are doing, much like how COBOL was used.
This is exactly why I want to use it.

By creating zero substance visual shit, I can reel in people to the rest of my portfolio.

It basically makes me look like I have 'depth'.
>>
>>54906743
I'm still not sure what the Arduino is for? Why do designers need to know how to program microcontrollers?

I'm also with this anon.
>>54906746
The Arduino IDE is terrible. I'd invest in an Atmel Studio license and get the Arduino extension. That way you get debugging.
>>
>>54906793
>>54906793
>I'm still not sure what the Arduino is for?
Literally hobby shit. But the ide for arduino was based on processing, so it makes it easier for me to program microcontrollers if I learn it.

Again, starting out, so Atmel Studio is too much for the time being.
>>
>>54906823
Alright, sounds like you got a plan. Good luck my dude.
>>
New bread
>>54906842
>>54906842
>>54906842
>>
Stupid question, do values that I allocate inside a loop also exist outside it?
>>
>>54907298
Depends entirely on the language.
>>
>>54907402
ok, I'm thinking of C right now
>>
>>54907416
No, it's not visible outside the loop. And if you name a variable inside of new scope (anything inside { ... }) the same as a variable outside of the new scope the new variable shadows it.
int main(void)
{
int i = 0;
for (int j = 0; j < 10; j++) {
int i = j;
i++;
printf("%d\n", i);
}
printf("%d\n", i);
return 0;
}
>>
>>54907498
I see now, thanks.
>>
I have a vector of points, which is a struct. If I create them by writing:
points.push_back({x,y});

Will that cause a memory leak? I'm not writing "new" anywhere, do I need to do something to make sure they get deleted properly?
>>
>>54907659
No this isn't leaky at all
>>
>>54907742
Cool, thanks.
Also, what's the best way to pass a vector around? Right now I'm returning a const refrence.
>>
File: téléchargement.png (3KB, 229x220px) Image search: [Google]
téléchargement.png
3KB, 229x220px
>>54907765
>returning a const refrence
No time rn to explain sorry, just wait there without moving until an angry C++ know-it-all ninja decapitates you verbally on the spot. Then you'll be enlightened.
>>
>>54907765
For modifying pass it by a reference/pointer.
For reading-only a const reference/pointer.

And if you're returning a completely new vector from the function, return a regular std::vector without any reference qualifiers, move semantics will kick in.
>>
>>54897144
thanks pajeet
>>
>>54895080
hi so i set up tor and bootstrap at 100%
i then run torify irssi
get error

Connection to a local address are denied since it might be a TCP DNS query to a local DNS server.

so i setup edited torrc, iptable.sh
https://trac.torproject.org/projects/tor/wiki/doc/TransparentProxy

but i still get the error when i try to irssi

also what is this part about setup user name
i am running arch and already have a sudo username setup?
>>
File: torify.png (161KB, 1207x797px) Image search: [Google]
torify.png
161KB, 1207x797px
>>54908983
sry wrong file ^
Thread posts: 313
Thread images: 29


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