/dpt/ - Daily Programming Thread

Last thread: What are you working on, Jow Forums?

Attached: dpt4.jpg (600x600, 97K)

Other urls found in this thread:

github.com/friendlyanon/nojs-captcha
twitter.com/SFWRedditGifs

Haskell should be illegal

Attached: 1563447503852.jpg (1440x1080, 706K)

it shouldn't be *illegal*, but it should be controlled, and there should be severe social consequences for abusing it.
there may also be a lot of merit in a "haskell predators list" that prevents known Haskellers from participating in programmer social circles where people expect to be safe and receive good advice rather than malicious encouragement.

they probably have a GHC extension for that

data Yuno a = Shit

instance Show (Yuno a) where
showsPrec _ _ = showString "Shit"

instance Functor Yuno where
fmap _ _ = Shit

instance Applicative Yuno where
pure _ = Shit
_ _ = Shit

instance Monad Yuno where
return _ = Shit
_ >>= _ = Shit

I think we should focus on rehabilitation rather than punishment

seppleshits should be gassed

what's the name of an operation that takes a list of values, a list of keys of the same type and an equivalence relation, and creates a mapping "key : all values equivalent to key" for all keys and values?

wtf was in that md file?

zipwith or summot.

can you show me the type signature?

group?

C++ is the strongest and cutest language ever made!

The road to hell is paved with good intentions and the road to stupid is paved with anti-utilitarianism. Use the right tool for the job, fucking retards.

The road to hell is paved with utilitarianism

Can monads make me look cuter?

Kys sepplefuck

>Use the right tool for the job
is what an alchemist says, sneeringly, to a chemist. Programming technology is mostly pre-stone-age bullshit. Most of the tools that exist aren't fit for any purpose.

dilate

Even Jesus was a utilitarian.
“Even so every good tree bringeth forth good fruit, and the evil tree bringeth forth evil fruit.”
St Matthew 7:17 DRC1752

yes, if you can define higher-order operators then monads can really improve the appearance of code. It's rarely worth it, though.

>Most of the tools that exist aren't fit for any purpose.
empirically proven to be false

Wanting to be a cute boy doesn't make me a tranny

Some are more fit than others unless you're a dumb marxist.

That isn't utilitarianism you retard. He doesn't say that when you subtract the evil fruit from the good fruit, yada yada

>look at me
>I built an entire house with this house-building tool
>it took me a year
>one of the ingredients was: a preexisting house
>the tool broke 200 times and had to be repaired 200 times
>also one time some passing crows ate the tool and I had to make a new one. fuckers.
>but this tool builds houses
>empirically proven to be useful
>one day it'll be more useful than MY BARE HANDS

>she doesn't use Codensity to implement RAII

The fuck are you blabbering about?

Have sex

did you think this analogy was intelligent

Do you know what utilitarianism is?

I was taught it's doing things for the sake of results.

I accept your concession

I better not see any code in my program segments thread

Attached: 1B34718D-F887-421A-ADE2-F41E702A74D9.png (400x400, 216K)

work is done. time to kode

Attached: Kloss-2-1200x675.jpg (1200x675, 88K)

Wtf did you just say in my thread?

Attached: CE4C436D-6990-4F11-8FA0-8C1646493DEC.jpg (263x361, 16K)

is "fucks

in java this is just
static Map func(List values, List keys, BiPredicate equal) {
return keys.stream()
.collect(Collectors.toMap(
k -> k,
k -> values.stream().filter(val -> equal.test(k, val)).collect(Collectors.toList())
));
}

Yes, but the utilitarian says that "good" is that which has the best consequences - i.e. that morality is about maximising some notion of utility. An optimisation problem. While non-utilitarians might say "you've done wrong", the utilitarian would reply "it isn't wrong if it has better consequences".

What about in Haskell?

looks like farts

Attached: csi-zoom.png (325x232, 95K)

Yes, and some languages and frameworks get certain jobs done faster and better.

You should've just said you thought it was more practical

even spj says haskell is useless so theres no point in learning it

Why are you so obsessed with Haskell?
grouping :: (k -> v -> Bool) -> [k] -> [v] -> [(k, [v])]
grouping eq keys values = fmap (\k -> (k, filter (k `eq`) values)) keys

Other than being a useless fpl, what's wrong with Haskell?

No type level lambdas

oh yeah, Hsakell's extremely sincere and serious "avoid success at all costs"
reminds me of seeing interactions with reddit people in Eve Online, in Faction Warfare
reddit: haha we suck :)
FW: yeah you do :)
reddit: ...
reddit: what did you just fucking say to me?

The type level touched my lambda

Attached: 86715907-6FD4-4FF8-95A2-4580EA8E811D.jpg (415x389, 45K)

my life just got more complete

public static class Enumerator
{
public static IEnumerable Repeating(this IEnumerable enumerable)
{
while (true)
foreach (var o in enumerable)
yield return o;
}
}


since it's lazily evaluated, one can do:
int count = 30;
var fizz = new string[] { "", "", "fizz" }.Repeating().Take(count);
var buzz = new string[] { "", "", "", "", "buzz" }.Repeating().Take(count);
var numbers = Enumerable.Range(1, count);

new string[] { "0" }
.Concat(fizz.Zip(buzz, (f, b) => f + b)
.Zip(numbers, (s, i) => string.IsNullOrWhiteSpace(s) ? i.ToString() : s))
.PrintToConsole();

>decide to do a thing in node.js
>surely it can't be that bad
>no stack traces
Why is this allowed?

Based

Attached: 99pbqaq95fb31.jpg (811x573, 79K)

>/dpt/ programmer discovers haskell style programming and that one obscure haskell fizzbuzz

Attached: 1567693610212.jpg (1280x720, 113K)

ah yes, code readability

That code is very easy to read.

Figuring out how to optimize my genesis doom engine

fruits

at my uni some department is searching for someone who knows mysql and python.
Should i apply even though, i only ever did fizzbuzz-tier stuff in python ?

have you done fizzbuzz-tier stuff in mysql

it's mysql, you set it up, connect to it and query stuff.
Shouldn't be too hard, should it ?

do i REALLY have to learn regex well? how often does /dpt/ use its advanced filters?

>advanced filters
Sounds like some irregular bullshit

Attached: 1563173236243.jpg (487x449, 21K)

group is different and guarantees a whole lot of things that the other function doesn't guarantee, for instance that the equivalence classes are disjoint. you can implement the function in question using group as follows, though: calculate keys x values, filter by key ~ value, group by key equality.

yeah, that's the more general implementation.
maybe there's no neat common name, though i'd think that this is a common operation.
the only other thing i could think of that is similar is join in sql (i.e. first cartesian product and then a filter).

most of the complicated type hackery solves problems that are more easily solved with dependent types or tools like structures.

it is a left join

are there any good books on category theory?

Dependent types confirmed to be training wheels

Oh thank goodness, for a moment I was worried my monads would compile in reasonable time.
[1 of 1] Compiling Main ( helloworld.hs, helloworld.o )
Linking helloworld ...

real 0m6000000.827s
user 0m0.486s
sys 0m1.189s

doesn't this have suboptimal performance though

Is reading gcc/clang's output Assembly a good way to learn common Assembly techniques?

Hi, how do I start earning money by writing shitty code? Also where should I learn how to write said code?

Please do not use Collectors.toList, it has very very high overhead. Use Collectors.toCollection instead with the desired constructor reference.

sorta. in sql you get a type key x value, not a type key x list value. it doesn't really make a difference in sql, but would in a traditional language. the difference between those two is one invocation of group by key equality.

there's many good books, but it depends on what you're looking for.
"category theory for computing science" is decent if you're looking for a formal introduction without too much focus on examples in topology, abstract algebra and other similar stuff.
"the joy of cats" is good if you're looking for a formal introduction with examples in math.
"category theory for programmers" is good if you're looking for an informal introduction that occasionally relates ct to concepts in programming (i'd really advise that you read this together with a formal book though, otherwise you'll constantly feel like the author is hiding important things from you).
those are just a few i've read, and i'm sure there's many other great books.

i honestly never really cared about all the type hackery in haskell and i'm doing just fine working with a DTT theorem prover, so i guess that's kind of true

makes sense

Attached: 1495215380707.webm (1920x1080, 1.27M)

Learn C. Be sure to avoid indentation. Use pointers as often as possible and optimize as early as possible. Don't bother breaking up your code into functions that just wastes time. Void* is very useful and I recommend using a lot of it.

I need a basic, crash course/refresher on java that I can complete as quickly as possible, preferably in between 5 and 30 minutes.

Background: I know Lua and arduino C very well, I can do stuff in python but would not say I am experienced in it, I took a one semester course on data structures taught using java somewhere between 1.5 and 2.5 years ago, the professor was awful, had a very hard to understand accent, and did not believe programming in java was necessary to learn how to program in java. (we had a single 50 minute lab every week where we did actual programming, other than that we didn't even use computers, much less actually code or practice what we were learning)

>>TLDR: My java is rusty, and when it was fresh it still wasn't very good, I need a refresher that will give me the info I need to actually make a functional program that I can complete in as little time as possible.

working on a pure functional language that is backwards compatible with C

What does backwards compatible mean? You mean easy ffi with C?

it's called Haskell -XFFI

no, i mean it's literally going to allow you write valid C99 code (minus VLAs, of course)
trust me, it'll work

Can I just ask the interviewer to use a laptop? I'm pretty sure most of them would prefer that to the whiteboard

But C99 isn't purely functional.

i'll just call it unsafe

>void *
>optimization
ok niggerman

github.com/friendlyanon/nojs-captcha
Well, I made it, but apparently not every website supports the fallback captcha. For shame...

Lisp is the most powerful programming language.

This is going to sound completely retarded, but how do you program? I am not asking this as though I am looking for a tutorial, as I know how to do it myself. I mean, how do you specifically do it?

Allow me to elaborate. When I program, I (and I assume most people here, if they have any competence) often have a sort of intuitive sense of how to design whatever algorithm I need to implement. Sure I use my consciousness a little bit for planning and such, but the process of things is far more ready-to-hand than say mathematics (speaking of mathematics, my larger interest is on how some people can be good at learning programming but not mathematics and vice versa. Perhaps there is some 'neuro-algorithmic' explanation to this. Off topic, but see LR Vandervert's writings on neuro-algorithmic positivism if you are interested to know what I am blathering about on this tangent). Now, I never bothered to really think about it until now for a... project I am doing, but I have grown interest in what were the possible feedback mechanisms are latent in the building of computational fluency.

I think I might need to have some simple examples of what I am thinking about to properly explain what I mean here. The first example that comes to my mind rn is the fact that compilers are able to immediately give feedback if a part of your program is working or not. A simple corollary of this observation is that for one you have opportunity to repeatedly notice certain syntactical features of whatever programming language you are working on (which in turn leads to retrieval structures that make it easier to read other kinds of code). Diagnosing flaws in your understanding is also streamlined thanks to this, so you can very easily develop your problem solving capacities via shaping. A less obvious example (though admittedly still rather basic) is that this feature allows you to reverse engineer pieces of code as you abuse coding's modularity

Attached: 248121.jpg (225x350, 46K)

No. It's OCaml.

liftM9 :: Monad m => (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m a6 -> m a7 -> m a8 -> m a9 -> m r

beautiful

>Monad
>not Applicative
embarassing

lift m8

Holy animetard autism

>how do YOU program?
there, saved you the read

i keep changing the template definition until it somehow compiles

i let the parentheses guide me

This is an interesting question/idea. Unfortunately, I feel like a lot of people are going to start to read it and give up, or read it all the way through and decide they dont have the time or (in my case) the mental stamina to write a meaningful response. I want to say that at least one person is interested in this, and did not ignore it. I just cant take the time to give you much of a response.

I will say that for me programming is a lot like eating crab legs. There are times where its this tedious task where you pick stuff apart and spend a lot of effort working on something with not much to show for it, but other times you manage to crack open a leg shell and extract this single, massive strip of luscious meat from it all in one go, and its the most satisfying thing in the world. Sometimes it feels like the code writes itself, while other times I feel like Im just making a mess.

For reference, I am decently good at math, but I am not good at learning it. I also play cello, and am a good player, but I dont read music very well. I cant look at the notes and know what it sounds like before playing, and often even playing the written notes can be a challenge if I dont already know what it sounds like. Once I do know what it sounds like, I am great though. Its a similar thing with math. I look at a text book and the stuff written in anything other than very abstract, plain English terms just kind of blurs into meaningless noise, but once I understand a process or whatever, I am often pretty good at it.

you guessed right

It's not worth responding to. He's a retard throwing together words trying to make it sound fancy. Please explain what the fuck "A less obvious example (though admittedly still rather basic) is that this feature allows you to reverse engineer pieces of code as you abuse coding's modularity" is supposed to mean

You forgot to recommend using goto whenever possible.

fruits

As a neet I'm shocked you can have fucks penis out in the open at a workplace.