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

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

Thread replies: 255
Thread images: 29
File: casting_spels.jpg (75 KB, 500x527) Image search: [Google]
casting_spels.jpg
75 KB, 500x527
((lisp) edition)


Old:
>>54877214
>>
File: 200205132-001.jpg (126 KB, 357x479) Image search: [Google]
200205132-001.jpg
126 KB, 357x479
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 (909 KB, 1982x1724) Image search: [Google]
finland.jpg
909 KB, 1982x1724
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 (99 KB, 630x655) Image search: [Google]
code bloat.jpg
99 KB, 630x655
>>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 (140 KB, 909x810) Image search: [Google]
1464997529.png
140 KB, 909x810
>>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 (2 MB, 265x192) Image search: [Google]
1377082502339.gif
2 MB, 265x192
>>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 (2 KB, 191x91) Image search: [Google]
6s75vtH.png
2 KB, 191x91
>>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 (2 MB, 384x216) Image search: [Google]
190wz.gif
2 MB, 384x216
>>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 (1007 KB, 1092x698) Image search: [Google]
1462369642505.png
1007 KB, 1092x698
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 (5 KB, 110x126) Image search: [Google]
laugh batman.jpg
5 KB, 110x126
>>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 (48 KB, 604x453) Image search: [Google]
1464033727551.jpg
48 KB, 604x453
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 (48 KB, 455x455) Image search: [Google]
trash_look_at_the_time.png
48 KB, 455x455
>>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 (203 KB, 2132x666) Image search: [Google]
categorised monad.png
203 KB, 2132x666
>>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 (3 MB, 960x540) Image search: [Google]
launchpack.webm
3 MB, 960x540
/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 (60 KB, 912x566) Image search: [Google]
help.jpg
60 KB, 912x566
i heard this software could help me make programs, but i only see the option for apps

help
>>
File: mons.webm (3 MB, 900x506) Image search: [Google]
mons.webm
3 MB, 900x506
>>54902099
there an epub
http://golibgen.io/view.php?id=864155
>>
File: 659945641.png (107 KB, 792x1023) Image search: [Google]
659945641.png
107 KB, 792x1023
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 (94 KB, 396x395) Image search: [Google]
fragezeichen yui.png
94 KB, 396x395
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 (729 KB, 1920x1018) Image search: [Google]
svvsvsv.jpg
729 KB, 1920x1018
>>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 (1 MB, 1000x1412) Image search: [Google]
1464616114468.jpg
1 MB, 1000x1412
What are some great programming related movies?
>>
>>54903706
Erlang and Erlang 2
>>
File: lay_the_foundation_pupper.jpg (133 KB, 500x553) Image search: [Google]
lay_the_foundation_pupper.jpg
133 KB, 500x553
>>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.
Thread replies: 255
Thread images: 29

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

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.