/dpt/ daily programming thread

What are you working on Jow Forums?

Old thread:

Attached: typeclass.jpg (960x720, 67K)

Other urls found in this thread:

github.com/NightDiveStudios/shockmac/issues/6
lifehacker.com/productivity-101-how-to-use-personal-kanban-to-visuali-1687948640
twitter.com/SFWRedditImages

Why do people hate on Haskell?

Attached: 1505049636455.jpg (600x800, 95K)

Daily reminder to not touch OOP if you don't adhere to the Liskov substitution principle.

If in doubt, only inherit from interfaces and you'll be guarenteed to satisfy it.

New thread when?

python is good for almost anything and specially useful for everyone that does not have a not a CS or a SE degree.

Checking reddit.

>why do people hate on Lisp
>what is smug lisp weenie

Memory inefficient due to static variables only

New thread

>specially[sic] useful for everyone that does not have a not a CS or a SE degree.
>does not have a not a
Python might be the answer for you!

New thread:

Not practical enough for real-life programming, not bleeding edge enough to be cool anymore.

Because the "monad tutorial problem" isn't solved.

>non-linear slope meme pyramid
shiggy

Linear + ordered types will save systems programming

There's already ST for that but it's ugly. In the future Haskell will have linear types.

Am i doing something wrong, or is a Python class filled with "self." You don't use class variables, and every also method calls self, right?

This looks pretty fucking ugly.

Attached: self.png (733x472, 68K)

OOP in python is ugly, that's all there is to say

Line Order Double Fry types will save sanders programming

It's object oriented and thus a shitlang.
Types belong to data. In any strongly statically typed language, especially one with limited or no type variance e.g Haskell, functions are restricted in what types they accept as parameters.
This is essentially the same thing as said parameters being receivers and accepting the functions in question as messages, since in both cases the function is "owned" by, or confined to, the type of the data receiving it.
The only true pure functional languages are pure functional dynamic languages, e.g Scheme, because their functions are not "owned by" the data on which they operate.

why do pajeets love python so much?

Euler 21
def d(n: Int) = (1 until n) .filter {n%_ == 0} .sum

@ (1 to 10000) .filter {a => val b = d(a); a != b && d(b) == a} .sum
res1: Int = 31626

/Br/ainlet here, can any /ha/sklet explain the difference between a /mo/nad and a /go/nad?

Attached: 1513724089731.gif (640x360, 354K)

Attached: 1520987687923.jpg (211x239, 6K)

hasklets _have_ moan ads

>meme book is backwards

Japanese version, you dummy.

>jap

A monad is a monoid in the category of endofunctors, whereas a gonad is a male organ whose point is to improve gender equality by allowing women in labour to kick their men's gonads and share the pain.

nice save

Is there anything more autistic than fighting over text editors? They all do the same thing in the end

>a gonad is a male organ
the state of American education, everyone

is there anything more retarded than learning haskell?

Which style do you prefer? I'm autistically trying to standardize my code and I'm not sure which one is more maintainable

foo = GetFoo()
bar = GetBar()
DoSomething(foo, bar)


DoSomething(GetFoo(), GetBar())

?> a moan ad is a mongoloid in the category of end fuckers

A gonad is just a mongloid in the gategory of endobunctors :D

fighting over languages

why not fill self.ops dynamically?

it doesn't matter in most contexts

I would say the 1st one, for debugging

Good to know, second version it is then thanks

You only use self when you want to store a variable in the object's dictionary or use a variable in the object's dictionary.

Yes, asking idiotic questions on Jow Forums comes to mind.

First is easier to inspect in a debugger because you won't need to run the functions again. If those are pure getters, it's fine, but if the functions would be better named CalculateFoo() and CalculateBar(), stick to #1.

explain

See

any modern compiler optimizes both choices as the same, so not really

Right. I prefer the second one because it's more concise but I can see the need for debugging too

how do you fags keep yourself disciplined when doing your own projects? also, have you ever started commercials projects on your own?

someone said he used to work in public shared working spaces for this reason. is this a good idea?

-> answered better than I ever could have done it

>any modern compiler optimizes
yes, but then you can tell the compiler to add debugging info to your binaries, can't you? and if you ever have an odd, specific problem relative to those functions, you will find you those lines were the problem

have you guys ever used an interactive debugger? just breakpoint or eval the expression at cursor.

I prefer either the first variant, or something like:

DoSomething(
GetFoo(),
GetBar())

I'd rather read downwards than left-to-right. As for debugging, the above looks like C# to me, whose debugger is good enough to not need separate statements. The story may be different in other langs.

>eval expression
>run function again
>possibly change state
Today, on Jow Forums is bad at development...

>how do you fags keep yourself disciplined when doing your own projects?
Easy, I never do. Next question please!

> have you ever started commercials projects on your own?
No.

>someone said he used to work in public shared working spaces for this reason. is this a good idea?

Highly depends on your style. Works for some, others find it distracting.

do you trust them at 100%? have you ever had someone try to debug your shit, only to tell you that they couldn't, because your code sucks?

Euler 22
val in = scala.io.Source.fromURL("projecteuler.net/project/resources/p022_names.txt").getLines.next

val names = in.split(',').map{_.tail.init}

@ names.sorted.zipWithIndex.map{case(n,i) => n.map{_-'A'+1}.sum*i}.sum
res1: Int = 870873746

are you retarded? when you enter the call frame for DoSomething(), the results of the evaluation of GetFoo() and getbar() are already here. replaying the call frame doesn't call GetFoo() and getbar() again. fucking amateurs.

>Easy, I never do. Next question please!
yeah, well, I was looking for people who have had some experience with this...

>Highly depends on your style. Works for some, others find it distracting.
my experience has been: I have difficulty programming in a noisy environment, but, OTOH, I have difficulty doing shit if I'm not being pressured by someone else. I do shit slowly, and of bad quality.

>Freetard attempts to spread his dirty, commie ways
github.com/NightDiveStudios/shockmac/issues/6

Seems like what you need is someone who silently stares at you and silently judges you whenever you slack off. Post on craigslist, someone's sure to want to do it for the right price, like that guy who hired someone to slap him when he'd slack.

>Seems like what you need is someone who silently stares at you and silently judges you whenever you slack off
not in that sense, no. I need someone to manage my times, because I'm very disorganized, and not knowing how to manage shit makes me anxious and unproductive. also, knowing that I don't know, and simply thinking about the problems I will have in the future, makes me feel like shit.
being side to side with other people (I live alone...) helps me put things in perspective, and realize I'm not too stupid as they are, and that, indeed, I have a sort-of natural ability to solve technical problems.

>giving Haskell-chan an infinite list
UwU DADDY. This list is longgggggg. I don't know if I can take the whole thing. C-can I please just be a naughty little baby girl and just work on whatever you need to CUM to CUMPLETION >_< *nuzzles*

Have you tried a pull-based system, like Kanban?

nope, but I guess I should. does it work for a 1-person project, though?

Depends on the person but yes, some use it for themselves: lifehacker.com/productivity-101-how-to-use-personal-kanban-to-visuali-1687948640

Second is more effective since nothing needs to be declared, so the second one obviously

>I'm autistically trying to standardize my code and I'm not sure which one is more maintainable
Retarded fucking idea. Instead of trying to "standardize" your code, just use the first whenever the second is too long/complicated.

It's also less work, less debate over naming things (the local variables) and thus fewer billable hours. Why do you want to put everyone's job security at risk, do you hate your coworkers or something?

thanks, guess I really need to manage the basic stuff and organize myself before doing anything, because I'm just wasting my time by not doing that already...

(define (identity x) x)
(define (compose . fs)
(if (null? fs) identity
(lambda (x)
((car fs) ((apply compose (cdr fs)) x)))))
(define (curry f . as)
(if (null? as) f
(lambda bs
(apply f (append as bs)))))
(define (curryr f . as)
(if (null? as) f
(lambda bs
(apply f (append bs as)))))

What are the advantages of laziness ?
I only see people shitting on it, but surely, there should be some advantages to it, otherwise some languages wouldn't adopt it as default, right ?

It all heavily sits on just one thread from several directions, that takes an hour of review before one . or / Welcome to the painted jungle /

not initializing if it's not used, that's pretty much the entire point

Euler 23 with two tweaks to drop runtime by about 10x. Still shitty code, obviously
val abundants = {
def propDivisors(n: Int) = {
val small = (2 to math.sqrt(n).toInt) .filter {n%_ == 0}
val big = small map {n/_}
(small ++ big :+ 1).distinct
}
def isAbundant(n: Int) = propDivisors(n).sum > n
(1 to 28123) .filter(isAbundant) .toArray
}

val isAbundant = abundants.toSet

def sumOf2abundants(n: Int) = abundants.takeWhile{_ isAbundant(n-i)}

@ (1 to 28123) .filterNot(sumOf2abundants) .sum
res1: Int = 4179871

it makes somethings easier, like custom control flow constructs and infinite data structures

advantages:
>doesn't need to compute what isn't needed
>infinite data structures (codata)
>some data structures are more efficient (e.g. llists) than otherwise
>true product types (TM), at the expense of true coproduct types
>can do recursive computations that eventually bottom out (think excel spreadsheets with reference cycles)

>slide with no context.
What the fuck are you talking about? Don't assume terminology that's language specific makes any sense elsewhere.

Haskell's the most mainstream language that adopted it as default and it only did so as a side effect of its philosophy to avoid success at any cost, so your premise is false.
Regardless of its advantages, the disadvantages are that laziness complicates your runtime, and that, if you want laziness, implementing it in a non-lazy language is fairly easy, so there's no reason to encumber an entire language with it.

You need glasses or will need glasses

also if you think about it, if-then-else essentially takes its two arguments lazily
same for logical operators like || and && - (true || b), (false && b) don't need to compute b

>What are the advantages of laziness ?
Literally nothing that's actually useful and can't be accomplished without the downsides of lazy-by-default.

>doesn't need to compute what isn't needed
Don't write useless code.

>infinite data structures
Doesn't require laziness by default.

>some data structures are more efficient (e.g. llists) than otherwise
Doesn't require laziness by default.

>true product types (TM)
wat

>can do recursive computations that eventually bottom out
Doesn't require laziness by default.

>i don't understand: the post

>most of my points got refuted and i can't respond

who said anything about lazy by default?

>Doesn't require laziness by default.
Yes it does because if laziness is not default most functions are strict in their arguments and evaluate your lazy values fucking up everything.

You talk of shifts

I need a job and can program Jow Forums

kill me, every interview so far has been IQ tests and fizzbuzz with lmao no call back

>who said anything about lazy by default?
Nobody said it explicitly, but it's kinda implied in the user's question.

user, watch this:

>>something you said
>some bullshit
>>something else you said
>some more bullshit
>>the rest of what you said
>even more bullshit
Wow all of your points were refuted amazing

>Don't write useless code.
Yeah, fuck those if statements, write only the branch that will execute, the rest is just noise! /s

I can't tell whether you're just a troll or seriously retarded, so I won't bother with the other nonsense you wrote.

>Yes it does because if laziness is not default most functions are strict in their arguments and evaluate your lazy values fucking up everything.
But that's wrong, you nigger... do you want me to show you how you can make lazy lists and pass them around without making everything lazy? The same can be applied to any other data structure.

Other than the things people already mentioned, having the ability to refer to values that still don't exist is very useful for writing algorithms in an elegant and concise way.

>both branches of the if statement get executed unless muh laziness
Maybe in lambda calculus brain damage land.

>>doesn't need to compute what isn't needed
>Don't write useless code.
I'm the first to shit on haskek, but lazy-by-default actually allows you to write less, and more readable code.

Way too much spontaneous retardation, OP confirmed for samefag.

>lazy-by-default actually allows you to write less, and more readable code.
Rarely, and usually the resulting code is fucking useless.

public class Test
{
public string ToString()
{
return "I posted formatted code on Jow Forums!";
}
}

Attached: 1521993364399.gif (512x481, 631K)

Euler 25, would be shorter in Python or similar
def fibWdigits(n: Int) = {
var f2 = BigInt(1)
var f1 = f2

var f = f1 + f2 // ignored
var i = 1
while(f.toString.size < n) {
i += 1
f = f1 + f2

f2 = f1
f1 = f
}
i
}

@ fibWdigits(1000)
res1: Int = 4781

>t. seething hasklette

who the fuck writes code like this
constant H_START_PULSE_cste : INTEGER := H_DISPLAY_cste + H_FP_cste;
constant H_END_PULSE_cste : INTEGER := H_START_PULSE_cste + H_PULSE_cste;
constant V_START_PULSE_cste : INTEGER := V_DISPLAY_cste + V_FP_cste;
constant V_END_PULSE_cste : INTEGER := V_START_PULSE_cste + V_PULSE_cste;
constant H_PERIOD_cste : INTEGER := H_DISPLAY_cste + H_FP_cste + H_PULSE_cste + H_BP_cste;

jesus fucking christ

That's a very well supported objective fact you got there, pal.