/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

en.wikibooks.org/wiki/Haskell
twitter.com/AnonBabble

IIRC you can cast away the const in Rust though.

It's not like anyone's ever gonna do important things with it.

Thanks for using a thanks for using a thanks for using a

Yeah, via unsafe, but you aren't supposed to use usafe in your everyday code.

With what?

Why are C toddlers dumb?

If you're so good why aren't you making yourself useful and doing anything other than posting here? There are dozens of things we could be doing right now that would be massively more beneficial than Eternal Bikeshedding on /dpt/

Why do you compare programming to math? Math notation is declarative, which means that you could say let 420 = x, and it still would be correct. The actual math notation for assigment is :=, which, I hope we can both agree, is gay.

LOOOOL CTARDS BTFO!!!!!

>tfw finally getting haskell

ama

Daily reminder that OCaml, F# and Scala are the only usable functional programming languages and the Haskell cult only shows how little Sup Forums knows about the industry and programming in general.

AHAHAH C Babies are dumb, dumb!

>C Babies
C toddlers*

Is Boost++ cancer?

>If I keep posting that it'll make it true!

No C is

what weren't you getting earlier?

I hope you're learning Haskell only to switch to Idris latter, otherwise it's a waste of time.

Hello, expert C programmer here.

How can I average two integers? Using C if that matters.

PS: I'm using C btw

But it is user. Name any other fp language with more industry adoption.

how do you like your monads?

>OCaml
Trash.
>F#
Trash.
>Scala
Fucking trash.

>Name any other fp language with more industry adoption.
I don't know why you think this is relevant. I bet you also believe in democracy.

>I don't like getting things done
Typical /dpt/.

I was reading Read You A Haskell for Great Good, which is a TERRIBLE FUCKING BOOK

Started reading Functional Programming using Haskell by Richard Bird, and it cleared shit up.

not there yet, desu, the book is kinda dense and explains everythign in detail.

why? elaborate.

Change Int to float, average them, change back to int. easy.

Using unsafe is fine if it's a final resort. It doesn't really endanger the safety of the rest of the program because it lifts very few rules off, and it's meant as an annotation to the consumer.

JavaScript.

What's not trash?

Can somebody tell me what the FUCK is going on here

It is because that's what the post was about.

>change back to int.
>change a float back to int

Why are C toddlers so dumb?

(a+b)/2

If you want to have a float result do
(a+b)/2.0

It's called "arithmetic mean" btw

Who are you quoting?
I don't know of such a language yet. Haskell is garbage too, but not as as bad as those three.

Javascript confirmed for best language, C toddlers btfo!!!

...

You add (+) the integers together and divide (/) them by two (2).

Oh?
And what happens when any of a or b equals to INT_MAX or INT_MIN?

?
???
?

Disgusting trash

learn about IEEE 754, nigger, you can't directly compare floats

so

4 + 5 = 9 has an average of (9/2=) 4?
?
??
?

Pure functional languages are not as widely useful and easy to use as traditional languages that let you pick the right paradigm for the job, whether it be declarative, imperative, object-oriented or functional, such as Python, Ruby to a lesser extent, Rust, Jabosgript, Kotlin, Lua

I'm not directly comparing them nigger

(defn approx=
"Tests two values for approximity within 1e10^-10."
[x y]
(> 0.0000000001 (abs (- x y))))

(defn coll-approx=
"Tests two collections of values for approximity within 1e10^-10."
[xcoll ycoll]
(= (count (filterv #(= % true) (map approx= xcoll ycoll)))
(count xcoll)
(count ycoll)))

How will we ever recover?
>>Sup Forumseddit

In C yes.

> why? elaborate.
I was merely memeing. Still though, Idris has real dependent types while SPJ have spent the last 10 years trying to make GHC to emulate them with 50 different extensions. You should really check it out one you are confident with your Haskell.

You can't do pure FP in any of those languages.
Most of those languages are shit at FP.

So much for multi-paradigm/.

Is there a language which uses sets as its core data structure? Preferably without IO.

I agree but imperative and functional are the only sane paradigms, unless you use OOP for a very restricted entity-component-system design.

I thought you expert C kernel hacker masters could produce that"bug free" code unlike Rust noobs :D

>Who are you quoting?
Back to >>/jp/

dependent types aren't yet necessary
idris has a lot of flaws, particularly syntactically and in terms of patterns, e.g. (->)

there's a wikibook too

>right paradigm for the job
>object-oriented
Only if the job is to somehow make the project more shittier.

>I was merely memeing.
Fuck off back to your subreddit. Never mention anything related to Idris in your posts ever again if you want to use "meme" in such a reddit manner.

Did someone shit in your coffee?

You have clearly never used a functional language in production.

idris >> your trash

Yes. That, dare I say "person", I replied to in my previous post.

You can't disagree that map/filter/reduce and list comprehensions are useful while programming in those languages.
Maybe not classical object-oriented programming, but Rust shows how it is useful to group data with methods and also use typeclasses for polymorphism.
Not an argument. Have you?

[x] Tiling WM
[x] Programming socks
[x] Hate IDEs
[x] Hate Ubuntu
What else do I need to become a master programmer?

The you're retard for not using bigger integer type. Also a/2.0+b/2.0. Safer for mah unchecked input, but slower

Program in C and hasklel

I can't say anything about precision, because it shows only 7 numbers after dot

>Idris >> Idris
What were you trying to say here exactly?

seriously what the shit

>You can't disagree that map/filter/reduce and list comprehensions are useful while programming in those languages.
map/filter/reduce are not the entirety of functional programming

>there's a wikibook too
What, something like Real World Haskell?

>I was merely memeing.
wew lad

Can someone help me with this?

data Nat = Zero | succ Nat
deriving (Eq, Ord, Show)
(xx) :: Nat -> Nat -> Nat
m xx Zero = Zero
m xx succ m = (m xx n) + m

(^^) :: Nat -> Nat -> Nat
m ^^ Zero = succ Zero
m ^^ succ m = (m ^^ n) xx m

factsu :: Nat -> Nat
factsu Zero = succ Zero
factsu (succ n) = succ n xx fact n


[1 of 1] Compiling Main ( dat.hs, interpreted )

dat.hs:6:8: error: Parse error in pattern: succ
Failed, modules loaded: none.

>typeclasses
>polymorphism
>somehow the same as POO
Fucking jump off a bridge already.

That was an amazing demonstration of backpedaling, weaboo jones. Keep if up and make Sup Forums proud.

en.wikibooks.org/wiki/Haskell


Data constructors have to begin with uppercase letters

Succ

Um, that returns me a float for two integers, kernel hacker master

pls show me a correct way

What are you even on about? Where exactly did I "backpedal" in any of my posts?

The solution is to check the & of the lowest bit for carry and add it if it exists to the sum of the shifted results of both numbers.

Or you could promote to double before division.

Also, you can round up by adding denominator minus one the numerator, e.g. (9+2-1)/2 == 5

small mechanical keyboard

>in any of my posts?
take your reddit culture to your subreddit

>promote to double before division
Most unexpectedly expensive operation though.

Stop comparing floating point numbers for equality. Alternatively, you can go full retard and do
(= (to-string result) (to-string [0.9148))

, because this is what you're trying to do here.

...

Oh, and xx is a combination of characters, not symbols, so it will not be interpreted as an infix operator.
If you want to infix something made of characters, put it in backticks.

xx :: Nat -> Nat -> Nat
m `xx` Zero
m `xx` Succ m

(^^) is fine though, that's interpreted as an operator


...
factsu (Succ n) = Succ n `xx` fact n

>reddit """"""culture""""""
I want to see the reasoning why you're not from reddit, which you obviously are.

And why do you think 0.0000000001 is big enough to make a difference?

Because you thought I am seeing your trip/name when I have anonymized every poster, reddit trash

>back to le reddit xD
>lmao he programs in a GC'd language noob noob idiot noob
>le C(ancer) toddlers Cx
>fuck u retard i dont have any arugment moron idiot retarded
>etc etc
Seriously are these threads so shit? Can't we just talk about actual programming?

...

I was stuck on this for an hour.

I'm fixing this right now.
[1 of 1] Compiling Main ( dat.hs, interpreted )

dat.hs:3:1: error:
Invalid type signature: (xx) :: ...
Should be of form ::

What are your favorite striped socks?

I see, it was too much of me to assume that someone from plebbit could keep track of a short reply chain. I guess it's just too hard for your kind to adapt.

i heard they have that on ribbit, you might wanna give it a try (i'll assume that isn't your home site (which it obviously is))

>keep track of a short reply chain
Sorry, ribbit, we don't have names in Sup Forums and we don't follow your "reply (((chain)))"

Now head back to ribbit

Learn to format your posts correctly, you illiterate redditor fuck.

...

data Nat = Zero | Succ Nat
deriving (Eq, Ord, Show)
xx :: Nat -> Nat -> Nat
m `xx` Zero = Zero
m `xx` Succ n = (m `xx` n) + m

(^^) :: Nat -> Nat -> Nat
m ^^ Zero = Succ Zero
m ^^ Succ n = (m ^^ n) xx m

factsu :: Nat -> Nat
factsu Zero = Succ Zero
factsu (Succ n) = Succ n `xx` fact n


[1 of 1] Compiling Main ( dat.hs, interpreted )

dat.hs:9:18: error:
Ambiguous occurrence ‘^^’
It could refer to either ‘Prelude.^^’,
imported from ‘Prelude’ at dat.hs:1:1
(and originally defined in ‘GHC.Real’)
or ‘Main.^^’, defined at dat.hs:8:3
Failed, modules loaded: none.

Or you could do what I did, but without castingn to float a/2+b/2

Then why the fuck does it work here?

(defn sigmoid
"The sigmoid function: S(t) = 1 / (1 + e^-t)"
[t]
(/ 1 (+ 1 (math/expt Math/E (- t)))))

Goddamn, Haskell looks ugly..

holy fug

Another backpedaling. Are we being raided by redditors like you today?

Yeah that's the point but this will be wrong if both numbers are odd, so you still have to check for carry on the first digit.