/dpt/ - Daily Programming Thread

old thread: What are you working on, Sup Forums?

Other urls found in this thread:

a.pomf.cat/dcklso.html
coq.inria.fr/
twitter.com/NSFWRedditImage

First for D

I just wrote my first interactive website!
Pls rate.

a.pomf.cat/dcklso.html

regular expressions are so fucking complicated

does anyone understand this stuff?

re.sub(']+>', '\n',string)
re.sub(r'(.)\1{2,}', r'\1\1', u'жжж')
?????

Include in your response an algorithm written in Haskell that iterates through N*N*N space, in the following order:
>(0,0,0)
>(1,0,0)
>...
>(MAX,0,0)
>(0,1,0)
>...
>(MAX,1,0)
>(0,2,0)
and so on.

It's totally possible but the structure of the pure version of the code is much longer, much more susceptible to bugs, and much harder to write successfully.

You should check out the Lua string manipulation functions.

The entire Lua language is implemented in less code than Cs regex.

virus

>re.sub(']+>', '\n',string)
replacing any xml tag with new line
>re.sub(r'(.)\1{2,}', r'\1\1', u'жжж')
dunno

consider that Haskell is based partially on the ML family of languages (SML, OCaml, F#, etc.), which have always been known for being the best choices for writing compilers (Facebook used OCaml for their Flow type checker as well as for Hack, the many-backend compiler for Haxe is OCaml, even LLVM provides official documentation for OCaml as the only language other than C++, etc.) for various reasons (algebraic data types, pattern matching, better optimized for recursion or mapping data over trees/lists)
Haskell expands on much of that with a rock-solid set of parsing libraries that make writing parsers with good error reporting ridiculously simple (Parsec or Attoparsec, for example). because of the default laziness it makes it simple to express certain types of recursive behavior. pure functions also means that it's much simpler to debug (*most of the time). finally, having lots of powerful data abstractions (functors, monads, applicatives, alternatives) defined makes it easy to write very generic operations on the code without specifically inspecting the AST or IR.
there are tons of other smaller advantages, but a lot of it ends up coming down to the fact that experts in PLT tend to go for more declarative/functional languages like Haskell (because it's closer to type theory and category theory)
I think Elixir (or Erlang) would be somewhere in there if we keep moving towards large distributed systems or "cloud computing". other than that probably still JS, C# or Java, C, C++

>learning tkinter

Oh boy I sure hope I get to type "self" some more

The same in Caml, just translate. It's fucking easy to maintain.

let max = 2;;

let doit f a =
let rec loop a x y z =
if x > max then
a
else if y > max then
loop a (succ x) 0 0
else if z > max then
loop a x (succ y) 0
else
loop (f a x y z) x y (succ z) in
loop a 0 0 0
;;

let main () =
let f () x y z =
Printf.printf "(%d, %d, %d)" x y z;
print_newline () in
doit f ()
;;

let () = main ();;

By the way, shut up, you're ignorant.

you shouldnt have to if that is the only reference in reach

>Pure languages discourage prototyping and iterative design just as static languages do. Haskell is not only pure but highly static.

This is an interesting argument. I'll wait on commenting about the pure aspect until your next point, but I absolutely contend that static languages (especially static typing) make iterative design easier. With dynamic typing you it's difficult to make aggressive refactors since you no longer have the promises a static language's compiler makes about correctness of code which it guarantees before the program is run. And not only that, but because the correctness is checked at runtime, static analysis of what are trivial things in a language like C++ becomes undecideable problems for a language like JavaScript.

>In order to solve a problem in Haskell you have to already know the structure of the problem in specific detail, and as such Haskell is suffocating. Iterative design in Haskell requires a lot of refactoring of type declarations.

This is kind of a more abstract issue to argue about. My opinion on the subject is that if you're a skilled Haskell developer, you will write code in a way that better provides flexibility in the event of necessary future changes (usually by guessing where the future changes are going to be). In most circumstances you don't *need* to offer type declarations in Haskell, either, though they would have to be changed quite a bit if you wrote them out between each revision. It's true that you can get better error messages when you explicitly provide type declarations.

10/10

kys

#include
#include

int main(void)
{
uint64_t i, j, k;
i = j = k = 0;
for(;;)
{
++i;
if (i == ~0) {j++;i=0;}
if (j == ~0) {k++;j=0;}
if (k == ~0) break;
}
return 0;
}

>hasklel
>not shit
choose one

>My opinion on the subject is that if you're a skilled Haskell developer, you will write code in a way that better provides flexibility in the event of necessary future changes
fucking delusional, you're not smart or skilled for using haskell, in fact you're most likely the opposite

You have to repeat your code each time you need to iterate over your set, not with functional version.

Of course, another trapfag, this explains everything.

maybe i would agree if i was one of the 30 autists that could read hasklel and lisp shit

>t. pajeet

Oh, and by the way, I just saw

Here you go:
[(i,j,k) | j

Sorry if you suck at programming user. FP is beauty, Coq is the future.

cock?

No. Coq.
coq.inria.fr/

I accidentally swapped two characters. Before you say this proves your point, C has the same kinds of nested loops, except the code is like 3 times larger. I just fucked up since the keys are next to each other.
[(i,j,k) | k

that will be as popular as lisp and haskell
;;^/J

It's the future. Just be patient. OCaml and Haskell grow in popularity, everyday. After that it will be Coq.

dunno mang
scipy or some shitty (((((((((((((((((((((lisp(((((((clone)))))))))))))))

Why does learning how to code turn so many people gay?

That's fun when you're talking about languages that remove parenthesis for function calls.

You're embarrassing yourself.

(haha (ok (whatever) (you (say)
, (friend(!)))))

OK, you're retarded.

If you're still using a language that doesn't support higher-kinded types then you should just give up and go home.

It doesn't. it's just one retard

make a hasklel program that says that

They were already gay, but working in an office with 95% males just made them realise faster.

Tbh I'd rather come out in my 20s than get married, have 2 kids then realise I like cock aged 40, and end up paying child support for kids who'll never like me.
It's usually the most outwardly discriminatory who turn out to be total faggots, too.

>If you're still using a language that doesn't support higher-kinded types then you should just give up and go home.
If you're still using a language that doesn't support dependent types then you should just give up and go home.

I think that's just you user

main = putStrLn "OK, you're retarded."

He might be the same guy who challenged me to write a Haskell program that's supposed to be next to impossible. I don't think he expected a one-liner 16 times smaller than his golfed C++ code.

that's the question
>>tmag3ire

Is it possible to generate polygons procedurally and draw vertexes in GLSL?

No objections from me. I was trying to be nice, hence the low bar I set.

I like you user.

Of course it is.

Have you considered maybe he just wanted a one-liner and couldn't be bothered to do it himself?

Thank you. I like me too.

Why would he need a Haskell expression for something so trivial? He probably doesn't even know how to give n a value in what I wrote.

>Never attribute to malice that which is adequately explained by stupidity

That's backwards. The correct expression is:

>Never attribute to incompetence, that which can be explained by malice.

>just git gud
Not a valid defense.
>static typing leads to better error messages
Prelude> min 2

:4:1:
No instance for (Ord a0) arising from a use of `min'
The type variable `a0' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Note: there are several potential instances:
instance Integral a => Ord (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
instance Ord () -- Defined in `GHC.Classes'
instance (Ord a, Ord b) => Ord (a, b) -- Defined in `GHC.Classes'
...plus 23 others
In the expression: min 2
In an equation for `it': it = min 2

:4:1:
No instance for (Show (a0 -> a0)) arising from a use of `print'
Possible fix: add an instance declaration for (Show (a0 -> a0))
In a stmt of an interactive GHCi command: print it

:4:5:
No instance for (Num a0) arising from the literal `2'
The type variable `a0' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus three others
In the first argument of `min', namely `2'
In the expression: min 2
In an equation for `it': it = min 2

Holy fucking shitballs that's a lot of text for accidentally forgetting a parameter.
let n = 2

Smug haskell weenie.

For the person who asked about automatic dipose in C#, take a look at destructors.

You probably think the illuminati is real too.

No that's just an explicit error message.

That's because you can't print a function, user.

Prelude> min 2

:8:1:
No instance for (Show (a0 -> a0)) arising from a use of ‘print’
In a stmt of an interactive GHCi command: print it


At least you know that much. Now can you address your statement,
>It's totally possible but the structure of the pure version of the code is much longer, much more susceptible to bugs, and much harder to write successfully.

No, I just don't suffer fools gladly.

The problem with relying on destructors for cleanup in GC languages is that there are no guarantees about when they will be called. A connection could get left open for hours.

>Functional programming doesn't divinely bestow some arcane knowledge.

I never implied causation.

That's a problem with relying on GC for anything.
If unpredictable cleanup isn't acceptable, you shouldn't be using GC at all.

Disposable objects is a good compromise.

>it's justified
Fucking incredible. Yes it's because you can't print a curried min but holy fucking shit that's a lot of shit to parse through for a simple error message. Essentially none of that error text is fucking useful.
You still have to read the first block of error throwup to understand what the problem with "print it" is.

You want me to address your 1-liner? Cool you remembered Haskell's set-builder tools.

>Everyone is out to get me

Stay tinfoil. D I R T Y B O M B

>He actually believes this symbol was taken from some random pyramid in America.

>Cool you remembered Haskell's set-builder tools.
Apparently you didn't.

Sorry, I did a lot of Haskell, and that kind of problem is because you're not capable of high order code.

So instead of "bearing the weight" of manual memory management, you just need to remember exactly what needs cleaning up from what doesn't, and then manage it anyway?

Sounds fucking gr8 m8, where do I sign up?

>The problem with relying on destructors for cleanup in GC languages is that there are no guarantees about when they will be called.

Alright then, use "using", which is guaranteed to dispose the enclosed resource at the end of its scope.

No, because objects that need to be managed are disposable, so you don't need to remember anything. You just have to check if the object implements the IDisposable interface.

>smug smug smug smug
>ur inability to remember haskell's set build tools is b/c ur not a l33t haskell mathematician

template

:^)

is programming mainstream now?

That's not what that user was talking about.

Good-o.

I was once bitten by some code that an intern wrote that didn't do the Java equivalent, and ended up crashing because it had so many file handles left open that it couldn't open any more files.

Coq isn't very suited to actual programming, though.

Yes, it is. F has a higher kind that's similar to * -> * in Haskell.

>Yes, it is. F has a higher kind that's similar to * -> * in Haskell.
Still not what we're talking about.

We're talking about quantification over functor.

I was under the impression that you were talking about higher kinded types.

>I was once bitten by some code that an intern wrote that didn't do the Java equivalent

try-with-resources is, as the kids say, "lit."

Yes, that's why all the people who want to be special snowflakes fled to functional programming.

Gotta love how angry Haskell makes a particular poster ITT.

>"lit."
I'm not down with the kids. What does that mean?

I fled to FP because I find it a lot more fun than OO.

>Can't argue against the more simple points
>Literally can't even understand the more complicated ones
Therefore, ad hominem

First one should point to

Don't take it personally, I'm just shitposting. I'm /RacketRocket/ now.

What are you getting at?

Coursework which i have to do in C# but write it like C, because my uni doesn't want me to teach me C. It's the fucking worst.

>he has haskell on his computer
>he hates haskell
nah not mad

Write it like BCPL. Stick it to the man.

I'm saying you're calling Haskell devs man babies because you don't have e a better point to make.

That's okay, C# turns you gay anyway

woah. your parents must be proud

Write it like algol
#define STRING char *
#define IF if(
#define THEN ){
#define ELSE } else {
#define FI ;}
#define WHILE while (
#define DO ){
#define OD ;}
#define INT int
#define BEGIN {
#define END }

It does, it's already sinking in.

oops didn't realize that thread was dead
pls help?

Try crossdressing while programming. It'll make you better at it.

Lol haskellers btfo

>Haskell is a puzzle-oriented programming language that attracts attention of autistic-but-not-bright users that happen to like solving puzzles while programming.

Yup:
1) Use tesselation
2) Implement a renderer in fragment shader

Read about signed distance function while you are at it, they are cool

I now identify as a winblowsexual

>when u up late working on lame stored procedures in SQL

>programming isn't problem solving
Okay script kiddo.

Try programming while [spoiler]cumming[/spoiler] [spoiler]hands-free[/spoiler]