[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: 311
Thread images: 25

File: 1472108959005.jpg (22KB, 542x480px) Image search: [Google]
1472108959005.jpg
22KB, 542x480px
Previous thread: >>56380391

What are you working on, /g/?
>>
>>56391453
First for D
>>
File: Calculus of Maki Constructions.png (312KB, 452x355px) Image search: [Google]
Calculus of Maki Constructions.png
312KB, 452x355px
>>56391453
Shitty normalfag image anon
>>
Where's the CoC? How can we feel safe and welcome discussing here with no code of conduct? Please address this issue.
>>
>>56391453
Fourth for Rust
>>
>>56391461
I bet you get plenty of D
>>
>>56391477
If you want Corruption of Champions so badly go to /f/
>>
>>56391477
Right here, anon. >>56391475
>>
File: 1443247652355.png (29KB, 800x473px) Image search: [Google]
1443247652355.png
29KB, 800x473px
Are there any good tutorial series to learn how to program? I mean, I have a big list of relevant books, but it would be nice to have a comprehensive set of video tutorials so I could listen and follow along instead of having to switch back and forth between a book and my computer.

I'm mostly interested in learning one of the C languages.
>>
>>56391521
But that's just a mentally ill person.
>>
File: 1472007964659.png (230KB, 640x360px) Image search: [Google]
1472007964659.png
230KB, 640x360px
>>56391528
>video tutorials
>>
>>56391528
>I'm mostly interested in learning one of the C languages.
K&R + some guide on how to setup the environment and related stuff
>>
File: 1453068998593.png (507KB, 595x639px) Image search: [Google]
1453068998593.png
507KB, 595x639px
>>56391528
>one of the C languages
>>
File: still no hkts.png (463KB, 538x534px) Image search: [Google]
still no hkts.png
463KB, 538x534px
>>56391561
C isn't a language
It's a way of life
>>
File: anal beads.png (16KB, 741x228px) Image search: [Google]
anal beads.png
16KB, 741x228px
>>56391377
>>56391396
Repost, because I'm trying to figure out why people are sperging out about "goroutines".

See image. Example taken from Go website.
>>
MLTT > CoC
>>
>sit down to read book
>get bored

fucking adhd
>>
>>56391528
>one of the C languages.
???

Do you mean any language with a C in the name, or do you only mean C and C++?
>>
File: 1439929145075.png (719KB, 524x956px) Image search: [Google]
1439929145075.png
719KB, 524x956px
>>56391528
>switch back and forth between a book and my computer.
Honestly, it's way more distracting to have to pause a video, seek back find the relevant part you didn't understand or didn't listen to because you had something going on on your screen that took your attention away for a few seconds.
>>
>>56391578
>language feature
>Run()
>>
>>56391593
i think he means one of the c-based languages, don't quote me though
>>
>>56391593
can't spell Scheme without C

>>56391590
>blame adhd

>>56391583
Keep overflowing the stack, Hime!
>>
>>56391609
>I like that something that could be a library feature is actually a baked-in language feature
>>
>>56391528
>>56391553
Don't use K&R, it's discouraging for beginners.
>>
>>56391612
like javascript?
>>
>>56391609
Yes, it is built into the .NET framework.

You must be confused.
>>
>>56391645
The .NET framework is not a language.

You must be retarded.
>>
Why would you use a language that is designed not to help you as much as possible?
>>
>>56391637
>addition of integers should be a library feature
>>
.NET
dotnet
botnet
>>
>>56391691
Why shouldn't it be, if you have inlining?
>>
>>56391698
>it should tho
>>
>>56391691
it is in some languages
>>
>>56391689
""""help""""
>>
>>56391698
>inlining should be a library feature
>>
>>56391578

I was memeing about Goroutines, but please stop employing static using statements.
>>
>>56391714
Just like some have programmable semicolons.

How's your language going, Sisyphus?
>>
>>56391729
Inlining can't really be a library feature.
>>
File: anal beads.png (6KB, 314x122px) Image search: [Google]
anal beads.png
6KB, 314x122px
>>56391732
>please stop employing static using statements
No, fuck off.

I'll abuse them however I damn well please.
>>
>>56391732
Mummy, should I bother learning F#, or is it just a meme?
>>
>>56391741
monads

>>56391754
meme
>>
>>56391754
it's trash
>>
File: img1.jpg (681KB, 2208x1242px) Image search: [Google]
img1.jpg
681KB, 2208x1242px
I'm working on my day job currently, but will be working on reducing the size of my game by loading music post-install when device on wifi.

Check out my mobile game I released yesterday:
duckeh.com/djpenguin

Day job consists of nodejs and swift, doing some websocket fun at the moment.
>>
>>56391765
How fucking big is your loading music file?

Just compress that shit.

Doesn't matter if it sounds like trash; it'll at least match your game's visuals.
>>
>tfw roleplay as a programmer
>>
>>56391787
oshiete sensei

if you can roleplay as a programmer then maybe i can roleplay as a good programmer
>>
>>56391737
last thing i did was last night, added some pattern expansions for let-bindings so
let (a, (b, c), d) = (1, (2, 3), 4) in
a + b + c + d

becomes
let %%tuple0 = (1, (2, 3), 4) in
let a = %%tuple0 #0 in
let %%tuple1 = %%tuple0 #1 in
let b = %%tuple1 #0 in
let c = %%tuple1 #1 in
let d = %%tuple0 #2 in
a + b + c + d

This also works on variant patterns, but it doesn't currently compare the tag
>>56391741
it can in Lisp
>>
>>56391765
>72M
unity engine?
>>
>>56391762
>>56391761
Why?
>>
>>56391689
the super productive elites of /dpt/ would never touch a language that helps you produce quality, stable, secure software
they would obviously add quality, stabilty and security to the software themselves, of course
>>
>>56391741
>I was just pretending tho
>>
>>56391809
>would obviously add
with library features
>>
File: latest.jpg (31KB, 456x320px) Image search: [Google]
latest.jpg
31KB, 456x320px
Is programming something innate or something you can get better at? Im afraid Im shit at it and have already peaked
>>
>>56391750

o i am barfin
>>
>>56391801
Do you know any good guides for creating my own programming language?

I know LLVM exists but idk what it does.
>>
>>56391801
I see.

Why don't you use Java or C#, like a normal person?
>>
>>56391761

>monads
Do you actually think people understand what you're talking about when you use this word?
>>
>>56391833
depends on how retarded you are
>>
>>56391835
Don't look, mummy! Just think of happy ponies!
>>
>>56391855
That anon doesn't, either.
>>
>>56391855
Nope :^)
>>
>>56391855
>I'm too retarded
>>
>>56391855
You use monads all the time without even realizing it, lil' clopper.
>>
>>56391803
yep, but half the size is music. 72MB didn't seem like a big deal to me.
>>
I've already mastered Scala, Haskell and Coq. What should I study next?
>>
>>56391888
try a real programming language
>>
>>56391855
They're monoids in the category of endofunctors ya dip
>>
>>56391888
Your mom's coq
>>
>>56391841
If you're familiar with Scheme, Essentials of Programming Languages and SICP are both great (though they're books). Haven't really looked at the LLVM guide desu but it seems nice enough at a quick glance.
>>56391855
even OSGTP understands monads, what's your excuse Ruby?
>>56391847
cause im not a normie REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
>>
>>56391888
I bet you mastered Coq you slut
>>
Moving out of home and dumping my dad's narcissistic unloving ass
>>
>>56391888
Something with HoTT.
>>
>>56391900
>even OSGTP understands monads, what's your excuse Ruby?
he's retarded
i mean think about it, he spent $200 on a fucking pony plushie
>>
>>56391892
What a dunce, eh?

>>56391900
Yes you are nv

You are a NORMIE REEEEEEEEEE FUCKING OCAML IS FOR NORMIES
>>
>>56391909
Who the fuck loads up 4chan and decides that /dpt/ is the single best place to post this sort of information?
>>
>>56391930
Who the fuck boots up their 4chan machine and believes every bait they see?
>>
>>56391884
for a meh game like that (no offense) it's kind of a big deal. not everyone has fast mobile internet with loads of bandwidth. iOS doesn't even allow downloads over 100MB on a mobile connection
>>
>>56391930
Who autistically checks people's posts on a mongolian throat singing board to make sure they're relevant to the topic?
>>
>>56391597
That's a cute half-anime shark, I want to hug it.
>>
What is wrong with this code?
double factorial(int number){
double result;
if(number > 0){
result = number * factorial(number - 1);
}else{
return result;
}
}


the result is always
0.000000
>>
>>56391946
kek, these newfags are so naive man
>>
>>56391973
>else return result
else return 1
>>
>>56391979
? i've only been here for a month m8
>>
>>56391665
What's the difference between that and
package main
?
>>
>>56391973
You're lucky it's 0 and not garbage. You return result if number <= 0 without initializing it.
>>
>>56391973
Shouldn't compile, IMO
>>
>>56391841

>I know LLVM exists but idk what it does.
Well...

Compilers are typically composed of two parts: a front end, which handles scanning, parsing, and AST generation, and a back end, which converts the AST into executable code and does all of the optimization. In general, the back end is considered the really hard part. LLVM is an easy to package compiler backend. Rather than letting your compiler generate native code, you can instead generate LLVM Intermediate Representation, and LLVM will turn that into native code for you, and do all of the hard tasks like register allocation and various optimizations.
>>
>>56391946
>>56391979
You're assuming that I believed the content, rather than just being confused as to the subject matter, given the location.
>>
>>56392018
P O N Y

O

N

Y
>>
>>56392018
>llvm will never replace jvm
>>
>>56391950
Will reduce size + reupload. Someone also suggested lazy loading the levels to reduce original app download size.
>>
>>56391991
NORMIE NORMIE
LEAVE, YOU BORE ME
>>
>>56392018
although if you're using LLVM you still need a middle end to convert your AST -> LLVM IR
>>56392046
they have completely different goals and use cases
>>56392034
A
U
T
I
S
M
>>
>>56391991
Does nv stand for normie virgin?
>>
>>56391973
>double factorial(int number){
> double result;
wtf?
>>
>>56392066
them large numbers tho
>>
File: smileypngfile.png (310KB, 2000x2000px) Image search: [Google]
smileypngfile.png
310KB, 2000x2000px
Hey, I have been learning Python and Javascript for the last year. I would like to become better! Got any tips?
I would like to do some interactive programming; interact with others on something!

What are some good entries for this?
>>
>>56392063
Why have you posted from 3 different IP addresses in this single thread?
>>
>>56391973
You need to think functionally
fact :: Int -> Int
fact n = foldr (*) 1 [1..n]
>>
>>56392079
Unlearn Python and JavaScript.
>>
>>56392085
>not foldl'
>>
>>56392085
>Int
>not Integral
>>
>>56392085
>your code
>not this other code
>>
>>56392120
whoops, num
>>
>>56392081
why do you care?
>>56392064
nope, guess again
>>
>>56392034
>he thinks that things have places and things should always be in a pattern
go back to putting your action figures in height order over and over senpai
>>
>Rust is getting guaranteed TCO
Nice.
>>
>>56392197
What, source?
>>
>>56392018
>>56392063
LLVM is a meme and anything made with it is a meme

GCC >>>>>>>>>>>>>>>> LLVM
>>
I was thinking about coding something like a SimCity 2000 ripoff
>>
>>56392210
you're comparing two completely different things dumbass
>>
>>56392155
Needs Viagra
Never valid
Nasal veins
Nasty vaper
Nigel's vase
Notices vans
Normally violent
Naturally violet
>>
File: 1465784584317.jpg (156KB, 1000x887px) Image search: [Google]
1465784584317.jpg
156KB, 1000x887px
Rec me some beginner projects to do with C.
>>
>>56392231
Monads
>>
>>56391973
why are u calling the same function u are defining inside of it ??? ugly ass code desu
>>
>>56392207
https://github.com/rust-lang/rfcs/issues/271

>>56392210
>yfw LLVM isn't clang
>yfw people often use GCC's linker along with the LLVM compiler
>>
>>56391900

>even OSGTP understands monads
Can he actually explain them as something other than "a monoid in the category of endofunctors"?

>>56391912

And spending $200 on a pony plushie makes me less intelligent... how? Please, do explain this to me in great detail.

>>56392063

>middle end
Haven't heard that term used before... although yes, you would have to do a lot more than just scanning, parsing, and AST generation. Still, generating LLVM IR isn't particularly hard by comparison to generating raw assembly.

>>56391998

He's lucky it even compiles at all. He's computing the value of result and then throwing it on the floor. Execution does of the function does not continue beyond computing the value of result, and he does not return the value of result when number > 0. So the compiler's giving it a default return of 0.
>>
>>56392231
make a simcity 2000 ripoff
>>
>>56392256
>Can he actually explain them as something other than "a monoid in the category of endofunctors"?
That's all they are, though.
>>
>>56392079
up
>>
>>56392212
do it. make it free and/or open-source
>>
Try to convince me that Rust ISN'T the best, I dare you.
>>
>>56392256
Mummy knows what monads are. They're in LINQ, you know.

>And spending $200 on a pony plushie makes me less intelligent... how?
Is it not self-evident? You have spent hard cash on something useless.
>>
>>56392280
It's pretty good, but it could also be a lot better. I don't think the developers are ambitious enough.
>>
>>56392256
monads are really easy once you get started

>>56392256
>And spending $200 on a pony plushie makes me less intelligent... how? Please, do explain this to me in great detail.
saved
>>
>>56392280
No higher-rank polymorphism
No higher-kinded types
Unsafe
>>
>>56392212

Add more natural disasters.
>>
>>56392251
>labels: postponed
>Last comment in february

Anon, it's a wanted feature but it's still ways off from getting into the language
>>
File: full-monad-id-law.png (26KB, 334x358px) Image search: [Google]
full-monad-id-law.png
26KB, 334x358px
>>56392256
>Haven't heard that term used before
you usually hear about it in compilers with tons of passes. in GCC all the optimization passes are considered part of the middle-end
also see pic related for best monad explanation
>>
>>56392305
You should use protection so that you don't get the clop.
>>
>>56392303
Unsafe Rust doesn't poison safe Rust that uses it. Safe Rust code will never be a source of memory errors. It's either unsafe code itself, or the boundary between safe and unsafe code that is marked by the "unsafe" keyword.
>>
>>56392335
And when every library in the ecosystem is marked unsafe, as will inevitably happen?
>>
I mean, what's not to understand about monads?
>>
>>56392349
Why do you think it will?
>>
>>56392325
I prefer the explanation in terms of >>= and return, and prefer >=> to >>=
>>
>>56392349
I don't think you understand how unsafe works in Rust.
>>
>>56391453
I wan't to start learning javascript so I can finally make cool web apps with node.
How do I do this, I mean, with other languages you have a compiler and shit, what do I need to test my js?
Don't tell me I need a fucking local web server.
>>
Why is javascript the best language?
>>
>>56391973
I know what I've done wrong. It should be
double result = 1;

Thanks /g/
>>
>>56392378
is there an image version of that in the same format though?
>>
>>56392361
I'm a pessimist.

The hordes of idiots will write mountains of shitty code in Rust and mark it unsafe because they can't or won't make it pass the borrow checker, or Rust will die because not enough people use it.
>>
>>56392405
Unsafe Rust has absolutely nothing to do with the borrow checker.
>>
>>56392401
I haven't seen one.
>>
>>56392405
paraphrasing Jonathan Blow: don't limit a language because bad programmers will use it poorly, give it good features that good programmers can use effectively
>>
>>56392424
You're obscuring the issues.

The idiots will ruin Rust, just as they ruin evey other promising language. There is no future.
>>
>>56392405
>can't pass the borrow checker

https://doc.rust-lang.org/book/unsafe.html#unsafe-superpowers

The important part:
>It’s important that unsafe does not, for example, ‘turn off the borrow checker’.

What >>56392424 said.
>>
>>56392445
blow also said that languages like rust or haskell aren't a good choice because they are "100%" languages
>>
>>56392276

The problem is that now we are left to question what "monoid" and "endofunctor" are. The number of undefined words has doubled.

>>56392287

>You have spent hard cash on something useless.
And Donald Trump has a gold plated plane. Clearly, this is more expensive than a regular plane, and it serves no other purpose than to look nice. I bought a plushie that would be soft and cuddly. What should it matter if I spend my tax return on something nice for myself?

>>56392329

>so that you don't get the clop
*closes 27 Derpibooru tabs*

You were saying, Anon?
>>
>>56392445
j blow is overrated as fuck
>>
>>56392469
He's got a point when it comes to Haskell, but not Rust. Rust is very pragmatic despite having an "agenda".
>>
>>56392445
Great way to trigger a hate campaign against yourself by triggering tumblrina programmers.
>>
>>56392469
A good choice for what?
>>
link for late reply from the thread before to the goroutine thing because i was away for a while:
>>56392427
>>
>>56392473
A monoid is an associative magma equipped with an identity element

An endofunctor is a morphism from a category to itself
>>
>>56392478
>>56392469
he's basically an FP fag at this point
watch his latest video, he's going full type theory
>>
>>56392473
>The problem is that now we are left to question what "monoid" and "endofunctor" are. The number of undefined words has doubled.
It doesn't matter, because you don't need to know what a monad ~is~ to recognize something as being one and then using it as one. Smart people just realized that this concept in category theory could be used to describe a lot of things in programming.
>>
>>56392473
I was making a joke about ponies and the clap.

I have no idea what Derpibooru is.
>>
>>56392473
>The problem is that now we are left to question what "monoid" and "endofunctor" are. The number of undefined words has doubled.
yes, haskellers are even prematurely abstracting their terminology
>>
>>56392473
>>56392526
Well, you need to know the type signature, the operations, and the laws. These combined are the same thing as saying "monoid in the category of endofunctors".
>>
>>56392518
>an FP
>an functional programming
What?
>>
>>56392510

>associative magma
How is molten rock, associative?

>morphism
Again, we find ourselves into more undefined words.
>>
>>56392256
>Can he actually explain them as something other than "a monoid in the category of endofunctors"?

Monads wrap values and are used for the chaining of computations. They define bind, and return, which pass along the results of computation (obviously with some additional purpose) and inject the value into the container, respectively.
>>
>>56392554
A morphism is a mapping between categories
A magma is a set equipped with a closed binary operation
>>
>>56392473
Monads are programmable semicolons, jesus drunk fuck christ.
>>
>>56392562
>A morphism is a mapping between categories
BZZZT
>>
>>56392547
eff pee
enn vee
>>
>>56392554
Are you sure you know what a category is, in this context?

Kan þa eksplæn te mi?
>>
Does anyone else always have this feeling in the pit of your stomach that your code is "doin' it wrong" and there's always a much more intelligent solution out there than whatever cludge you came up with?

Also, ops pic is very relatable for me.
>>
>>56392603
Yes. It's a sign you're gonna make it, if you act on it in the end.
>>
>>56392622
I have no idea how to act on that feeling.

Except keep cludging code out of duct tape and pine needles.
>>
>>56391578
Most likely because if you want to go async in C# you have to explicitly yield and stuff whereas Goroutines handle that automatically. I don't use either language though, they're both shit.
>>
>>56392528
Use protection with those vinyl records, or you'll get The Clash.
>>
If anyone gives a shit, my life is basically ruined. Should I just become NEET and eventually hope I program something that will make me a little bit of money?
>>
>>56392686
The C# that anon posted is async and doesn't have "explicit yields and stuff".
>>
>>56392697
>my life is basically ruined
You can't stuff like that without telling a story.
>>
>>56392697
Make super ultra lewd porn games on an episodic business model (with the first episode free and then you charge for the rest).
>>
>>56392697
you and >>56391909 should fuck
>>
OKAY MONAD SEEKERS HERE GOES

Suppose you have a generic type, say List

If you have a function that, for any A and B, given a List<A> and a function from A to List<B>, will give you a List<B>

AND FURTHERMORE

You have a function that, for any A, given an A, will give you a List<A>

THEN IF THESE FUNCTIONS FOLLOW SOME BEHAVIORAL REQUIREMENTS

Then they form a monad for List.

The monad for a generic type M is two functions with those signatures (with M instead of List) that follow the behavioral requirements.

THIS IS USEFUL

Because you can then write functions that will work with ANY MONAD and you will get a large amount of reuse out of them.

SOÞLICE
>>
>>56392752
And???
>>
>>56392752
Cool, thanks.
>>
>>56392731

Like I've dropped out of College twice because of my intense social anxiety. I just dislike people. Nobody has ever done me right in real life. People just take advantage of other people. I was looking at doing online courses but I don't even know if it's possible to get a job that way.

My dad, who I haven't spoken to for 6 years came up about 3 months ago saying he'd found me a job and everything, today I found out he was literally just trying to get closer to me because he knew I was written in my grandmothers will, so yeah I don't have a job, I'm basically fucked.
>>
>>56392724
the shit that anon posted is concurrent but doesn't actually use CSP
yield is a lot less powerful than csp
>>
Network automation for a small ISP network.
Delegating prefixes to distribution routers, configuring P2P links, automatic DNS, routed subnets for customers with DNS management.
>>
>>56392836
>today I found out he was literally just trying to get closer to me because he knew I was written in my grandmothers will,

If this is something that seriously crossed your mind, you're no better than he is.
Secondly, how do you know it's purely because he wants your money and not because he cares about his SON??

You're fucked in the head.
>>
>>56392826
Wow

Did I really help?
>>
I'm making a tiny static C library for a functionality that I'm using in another project because it makes sense to keep it separate.

Should I just put testing functionality in main.c and just copy the headers and other sources into the other project? How do people usually build libraries?
>>
>>56392602

>Are you sure you know what a category is, in this context?
Gonna be honest, my university never covered category theory, and looking at the curriculums of various top CS schools, I'm not finding any that do. CMU doesn't, MIT doesn't, UW doesn't...
>>
>>56392912

Mostly because it's a meme that was invented by functional weenies.

Also, did you notice that I explained Monads as something other than monoids in the category of endofunctors?
>>
>>56392912
It's definitely postgraduate material at most if not all colleges.
>>
>>56392905
just copy the library.h and library.c to your new project, it should work fine so long as the library.c has the required headers.
>>
>>56392912
Are you coming to the Ponies of New York (PoNY) meetup?
>>
>>56392935
>functional weenies
foxandgrapes.jpg
>>
>>56392559

>used for the chaining of computations
So... shit we normally do in imperative languages all the goddamn time but didn't make a term for because none was ever required?

>bind, and return
I understand return. What is bind, in this context?

>>56392935

Missed that post until now.

>>56392943

My master's degree program barely went over type theory, and did not go over monads at all, in a class on programming language theory.
>>
>>56392935
>category theory was invented by functional weenies
It was invented by smart mathematicians. Computer scientists applied it to programming, and functional weenies use it to masturbate about lenses and arrows.
>>
File: 1439815589957.jpg (414KB, 1060x1600px) Image search: [Google]
1439815589957.jpg
414KB, 1060x1600px
>>56391966
I-It's not like I want to be cute or anything! BAKA!
>>
>>56392998
Apols, should have been clearer. I meant postgraduate as in 'not undergraduate', not necessarily masters level.
>>
>>56392998
Chaining in much more nuanced ways than "hurr do this and then do that" of imperative programming. C#, for example, is a bit more nuanced with yield/async/await, but that's all built-in to the language.
>>
>>56392884
Yeah, a little bit, in combination with >>56392559
I still don't really grok it but it gives me a general idea of what a monad is and why people call things like Rust's Option<> a monad.

So, from what I'm reading, it's a container which can do computation on taking a value or on returning a value. I have a feeling this is wrong, but, is it at least correct as an oversimplification?

What really gets me is that I'm not sure what code that acts on any monad would look like:
>Because you can then write functions that will work with ANY MONAD and you will get a large amount of reuse out of them.
>>
>>56392998
Monads let you do much more generic chaining.
>>
>>56392998
>I understand return. What is bind, in this context?
it depends on the monad
>>
>>56393022
>Chaining in much more nuanced ways
What I gather is, with monads you can take a chain of operations and pass it to a function, and add another operation to it, and then call this however many times you want wherever you want from elsewhere, yeah?
>>
>>56393034
An example is the function forM. For any A, B, and M, it lets you the elements in a List<A> with a function from A to M<B>, and it will automatically combine the M<B> values in the necessary way (with the basic monad functions bind and return) to give you back an M<List<B>>.

This function is very generic: it works for any A, B, and M, as long as there is a monad for M. M could be Option, it could be Either, it could be IO, ..., and this one function will work with all of them. You don't need to rewrite it for each one.
>>
>>56392998
>What is bind, in this context?

Assume you have a monad m, given an m a and a function a -> m b, bind will allow you to get that m b from an m a instance.
>>
>>56393034
>So, from what I'm reading, it's a container which can do computation on taking a value or on returning a value. I have a feeling this is wrong, but, is it at least correct as an oversimplification?
It's not really an oversimplification, but an overspecification. Monads are any type constructor with return, bind (or join, they are equivalent in power), and the laws.

>What really gets me is that I'm not sure what code that acts on any monad would look like:
Tree traversal would be an example.

>>56393108
Well, it's the result of a chain of operations. Whether this is an actual reified "imperative program" like IO or a free monad, or whether it's just data depends on the monad.
>>
>>56393138
it lets you map the elements*
>>
File: meme fizzbuzz.png (24KB, 437x388px) Image search: [Google]
meme fizzbuzz.png
24KB, 437x388px
rate my memenadic fizzbuzz
>>
>>56393147
If you define it in terms of return and join you also need fmap, don't you?
>>
>>56393034
>>56393147
Also, fun fact, when people complain about Rust not having higher-kinded types, it's because those would enable you to write generic functions over any monad (for instance).

>>56393193
Good point.
>>
>>56392979

I'm on the other side of the country, Anon. If I were to go to any pony conventions, it would be Everfree Northwest, which I have yet to ever go to.

>>56392905

Making library:
gcc -c foo.c
gcc -c bar.c
ar rcs libfoo.a foo.o bar.o


Using library:
#include <foo.h>

// ...

int main(void)
{
some_libfoo_function(2);
// ...
}


Compiling:
gcc main.c -lfoo


The program ar is used to take object files and cram them together into an archive that can be statically linked to your program. The header file is included by whatever program is using your library, and tells that program what types and functions exist.

http://tldp.org/HOWTO/Program-Library-HOWTO/static-libraries.html

>>56393141

So it is a function that allows one monad to turn into another?
>>
>>56393229
The monad stays the same. It's the type parameter that changes.
>>
>>56393229
>So it is a function that allows one monad to turn into another?
No: you have to stay in the same monad. It allows you to chain multiple functions that return something in the same monad together to form a single function that returns something in that monad.
>>
>>56393229
>So it is a function that allows one monad to turn into another?

What sort of response are you probing for with this question?
>>
>>56393229
http://mightybyte.github.io/monad-challenges/
>>
>>56393138
>>56393141
Can A == B or would that violate the definition?
>>
>>56393319
A and B can be any type, including the same type.
>>
>>56393210
>Also, fun fact, when people complain about Rust not having higher-kinded types, it's because those would enable you to write generic functions over any monad (for instance).
psst
hey
https://gist.github.com/14427/af90a21b917d2892eace
>>
>>56393247

Okay then...

>>56393271

A confirmation or a correction.
>>
>>56393229
Why be a brony when you can embrace FULL DEGENERACY and be a furry?
>>
>>56393368

I do not need to go to New York to have degenerate fun with furries. Seattle is a two hour bus ride away.
>>
>>56393359
>A confirmation or a correction.

I mean, the result is that it's going to be an m.
>>
>>56393229
>So it is a function that allows one monad to turn into another?
Nope.

The "same" Monad containing a different type. Or, possibly, the same type, but with a different value. Or, in some cases, nothing changes.
>>
>>56393406

You suggested as turning an m a into an m b. I assume that would refer to changing the monad.
>>
>>56393456
m is the monad
think of it this way

if you turn a list of integers into a list of floats, the fact it's a list hasn't changed

that's the monad part
>>
>>56393456

You know what they say about assumptions.
>>
Rate my FizzBuzz

#include <iostream>

int main(int argc, char* argv[])
{
std::cout << "FizzBuzz!\n" << std::endl;

for (int i = 1; i <= 100; i++)
{
if (!(i % 3))
{
std::cout << "Fizz";
if (!(i % 5)) std::cout << "Buzz";

}
else if (!(i % 5))
{
std::cout << "Buzz";
}
else
{
std::cout << i;
}
std::cout << std::endl;
}

return 0;
}


I can has job nao?
>>
>>56393482
no
>>
>>56393467
>>56393474

Was not aware at the time that they had a type parameter. So monads themselves... are they like types?
>>
My take on programmable semicolons:
Whenever a function takes a continuation as its last parameter, you use a semicolon (and optionally binding syntax) to pass the rest of the scope as a lambda. It works with monads (with an explicit "bind" combinator), but is more general and can be used or abused in a lot of different scenarios.

>>56393352
>it's because those would enable you to write generic functions over any monad (for instance)
You didn't do this. You don't need HKTs just to make a Monad trait and implement it.
>>
>>56393554
>programmable semicolons
the mental illness is strong with this one
>>
>>56393530
A monad is a type constructor (m) with two operations (return & bind), which follow the monad laws. These laws are derived from the fact that a monad is a monoid in a category of endofunctors.
>>
>>56393573
Why? They're far closer to "programmable semicolons" than just monads are, and yet they don't have anything to do with category theory or whatever else you find fedora-tier about Haskell.
>>
>>56392231
https://www.google.com/#q=the%20c%20programming%20language%20pdf

If you couldn't even do this, you might be hopeless.
>>
>>56393577

This makes somewhat more sense.
>>
File: bf1beta2.png (953KB, 1615x939px) Image search: [Google]
bf1beta2.png
953KB, 1615x939px
I bet monads could fix this fucking garbage heap.
>>
caps lock can be useful when writing all caps variable names because when touch typing you're supposed to use the shift key of the opposite side of the key so it's a pain in the ass to write all caps by holding down the shift key when touch typing properly
>>
>>56393627
Monads can't fix terriburu taste in games, you have dishonored your senpai
>>
>>56393649
>terrible taste

but.. we wuz British soldiers and shiit
>>
>>56393625
That's all a monad is. Trying to assign more meaning is an exercise in futility.
>>
>>56393530
Monads are functions from a type (any type) to another type, along with the relevant operations
>>
I can't believe I'm learning more about monads for meme purposes.
>>
>>56393667
No

NO

NO THEY ARE NOT

GET OUT
>>
>>56393676
it's their only purpose
>>
>>56393658
Yup. They're not astronauts, or burritos, or anything like that.
>>
File: 1466544326223.jpg (32KB, 557x612px) Image search: [Google]
1466544326223.jpg
32KB, 557x612px
https://wiki.haskell.org/Monad_tutorials_timeline
>>
Can someone explain what a monad is?
>>
>>56393711
>>56393577
>>
>>56393711
sent ;3
>>
Can we rename them memenads?
>>
>>56393749
gonads
>>
Total noob here, easiest way to scrape a html value in c#? I want to save the value to a document or something similar
>>
>>56393749
>>56393163
>>
>>56393711
No, it's impossible.
>>
>>56393767

Nice. The revolution started here.
>>
>>56393711
some kind of magic concept hasklel programmers can say to make their language seem relevant.
>>
>>56393779
>a memenad is a memeoid in a category of endofuckers
>>
Sometimes I wonder if the "kys hasklel *tips lambda*" guy has just been pretending all along, or if he really is that retarded.
>>
File: ocaml2.jpg (9KB, 132x195px) Image search: [Google]
ocaml2.jpg
9KB, 132x195px
>>56393797
In one month I will start an OCaml job.
>>
>>56393757

WebClient
>>
>>56393808
a memenad is a memoid in the memetegory of endomemes
>>
File: gnostic-cosmology.jpg (74KB, 400x606px) Image search: [Google]
gnostic-cosmology.jpg
74KB, 400x606px
>>56393711
The One Above All
>>
ded thred
ded lyfe
>>
File: anal beads.png (20KB, 952x358px) Image search: [Google]
anal beads.png
20KB, 952x358px
>>56393757
You could use HtmlAgilityPack

Pic related. Obviously, if you're working with 4chan, you'd use the APIs, but you get the idea.

Just use NuGet to add HtmlAgilityPack.
>>
>>56393947
resurrect :: Void -> a
>>
>>56393964
>You could use HtmlAgilityPack

I mean, you can always scrape values using WebClient and [spoiler][spoiler][spoiler]regex[/spoiler][/spoiler][/spoiler] if you know what you're looking for & don't expect the page to change format any time soon.
>>
>>56393966
AAAAAAAAAAAAAAAAAAAAAJ
>>
https://www.youtube.com/watch?v=U1mcD-IfAas
>>
>>56393947

Thread.current.wakeup
>>
>>56394037
throw new CantWakeUpException();
>>
>>56394037
It's too late, you can't bring something back from the dead. See >>56393966
>>
I want to recreate this effect
http://www.patrickmatte.com/stuff/physicsLiquid/

40 balls, all interacting in 2D.

Should I write the code myself for the physics, or is there an easy way to c+p existing code?

I'm using java and Libgdx.
>>
>>56391453
>building a thing, it launches rly soon
>was gonna launch yesterday, but choked on last think-thru
>had facebook registration mandatory for user permissions
>had persistent account mandatory for user permissions
>target demo is literally half-/pol/tard
>thought i needed normie-check measure for anti-spam
>realized 50 stormfags on my platform is far more preferable to 50 stormfags behind an ion cannon

tl;dr you think it's possible to facilitate the coexistence of /pol/tards and normiebookers on one platform, with clever enough design/user permission tiers?
>>
>>56394078
box2d plugin
>>
Im working on my MIT Freecourse ware lesson for vara varabs the instructions are

Assume that two variables, varA and varB, are assigned values, either numbers or strings.

Write a piece of Python code that prints out one of the following messages:

"string involved" if either varA or varB are strings

"bigger" if varA is larger than varB

"equal" if varA is equal to varB

"smaller" if varA is smaller than varB


so i throw down
varA = 18
varB = -6
if type(varA) == str or type(varB) == str:
print("string involved")
elif:
varA > varB
print("bigger")
elif:
varA == varB
print("equal")
else:
varA < varB
print("smaller")


And im stumped, ive tried altering it a ton aswell as using the acutal ANSWER to the question and its still showing me inncorrect.

also im still obvioussly learning. so no bully plz
>>
>>56394078
i played with that and the balls started falling out of the side of the bottle
>>
>>56392554
>undefined words.
Not really
>>
>>56394115
Can't you use something like
input.isdigit()
?
>>
File: a monad.png (52KB, 896x602px) Image search: [Google]
a monad.png
52KB, 896x602px
>>
>>56394180
So ;any copy/paste
>>
>>56392085
u're shit
fact = foldl1' (*) [2..n]
>>
>>56394180
What editor is this?
>>
>>56394148
desu id tell ya but even in the code i posted i have a syntax error that makes it unable to execute at the first elif
>>
>>56394180
>>56394222
Also, the font.
>>
>>56391453
Writing a program that writes a skeleton C program and sets up my special shitty offline version control built in, as a showcase for some C libraries I wrote
>>
>>56394110
I've been using the plug in, but only for collision detection.

Can you link me something that could help?

>>56394126
I threw my mouse up and down hard and broke it as well
>>
>>56394222
>>56394239

atom
font is firacode
theme is "one dark"
>>
>>56394229
That's because your syntax is fucked.

Please go read your textbook.

elif:
varA > varB
print("bigger")

should be
elif varA > varB:
print("bigger")


Fucking hell, I don't even program in Python.
>>
>>56392518
>implying thats bad
kys
>>
>>56394277
>kys
you're banned from the dpt fp cj
>>
>>56394249
i don't remember exactly how box2d works but it should be pretty easy each entity has a velocity and can collide with other entities etc
>>
File: maxresdefault.jpg (46KB, 1280x720px) Image search: [Google]
maxresdefault.jpg
46KB, 1280x720px
>random people download your shit project on GitHub
>>
>>56394319
>maxresdefault.jpg
>>
>>56394319
>people unironically use shithub
>>
>>56394319
It's not so shitty then.
>>
>>56394126
I played to and this happened, plus the liquid box disappeared, leaving only the balls.
>>
>>56394340
almost everything on github is shit
>>
File: 1472612920721.jpg (19KB, 262x274px) Image search: [Google]
1472612920721.jpg
19KB, 262x274px
>>56394355
Sure thing nerd.
>>
>>56394388
he's right though animefam
>>
how do I make my c program work with cli args
>>
>>56394381
new
I mean
unique_ptr
>>
>>56394401
Are you retarded
>>
>>56394399
int main(int argc, char **argv)

argc is the number of arguments

argv is an "array" of pointers to chars that are the strings containing your arguments

argv[0]
is the program name (e.g. cp or mv)

argv[1]
is the first argument (e.g. -l or -v)

Please check out getopt to handle options in an intelligent way
>>
>>56394115
why the fuck did this work? did i not have to define the fucking varibles?

if type(varA) == str or type(varB) == str:
print('string involved')
elif varA > varB:
print('bigger')
elif varA == varB:
print('equal')
else:
# If none of the above conditions are true,
# it must be the case that varA < varB
print('smaller')




I was instructed on this lesson but the lecture had nothing about this shit.
>>
>>56394525
and how the fuck did this work if varA and varB never fuckign existed? wtf man? Did python just decide to make up its own fucking varibles or someshit.
>>
>>56393808
a gonad is just a gonoid in the category of endofucktors
>>56393822
oooh where??
>>
>>56394277
it's not, did you even bother reading into the context?
>>
NEW THREAD!!

>>56394621
>>
>>56394649
Are you retarded
>>
>>56394682
He's false flagging people who post anime ops
>>
>>56394579
>oooh where??
Near Paris.
>>
File: 1456177263968.jpg (321KB, 1280x853px) Image search: [Google]
1456177263968.jpg
321KB, 1280x853px
>>56394314
I've decided to read through LiquidFun. It's related to box2D, but I can't tell if it's included when you add the box2D plugin. Any ideas?
>>
This thread didn't even hit the bump limit
Wow
Thread posts: 311
Thread images: 25


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