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

/sci/btfo

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: 34
Thread images: 6

File: 300k starting.png (11KB, 340x456px) Image search: [Google]
300k starting.png
11KB, 340x456px
Find a flaw
> protip: you can't
>>
>>8458644
This is a science and math board. For languages you might enjoy >>>/g/ a bit more.
>>
>not using Haskell
Wow, it's like you don't even program.
>>
>>8458644
I fucking hate you coder zombies with your codes n shit
>>>/g/
>>
That's fucked up but would actually work if it returned the length of the vector instead of the vector itself
>>
Arithmetic in the category of sets is also basically this. Any two sets of cardinality 4 resp. 7 are isomorphic (in bijection to), e.g. {0,1,5,6} and {3,5,6,2}, and addition (coproduct, i.e. the direct sum) of a set with 4 element and one with 7 gives you one with 11 elements, and this is again isomorphic (in bijection) to any other set of cardinality 11.

You restrict yourself to FinSet, the finite sets, and require that your set argument come with a total order - i.e. you work with finite lists.

PS instead of unpacking list elements, you can just do "++" and "+="
a = [1,7]
b = [2,3]
r = a++b
Then r points at [1,7,2,3].
r += b
Then r points at [1,7,2,3,2,3].
>>
>>8458671
This. But obviously OP was baiting in layers of retardation.
>>
>>8458688
B8'd hard
>>
>>8458655
This.
>>
>>8458655
Lisp is legit too, though.
>>
File: 1473219212966.jpg (303KB, 816x744px)
1473219212966.jpg
303KB, 816x744px
i did this in lua a while ago just for keks

http://pastebin.com/MUajNsaE

now try to construct the real numbers :^)
>>
File: Charles_Babbage_-_1860.jpg (148KB, 960x1257px) Image search: [Google]
Charles_Babbage_-_1860.jpg
148KB, 960x1257px
>>8458644
Congratulations, you've just discovered the basic arithmetic Charles Babbage used to design the Analytical Engine. You're only about 180 years too late.

>/sci/ completely btfo
>how will it ever recover?
>>
>>8458644

> exponent function isn't even recursive

what is this trash?
>>
>nonrecursive slow as shit exponentials
Kys
>>
>>8458644
wew, babby's first peano encoding

meanwhile in Haskell

[code]
add = (++)
multiply = (>>)
power = foldr (>>) (pure ()) .: (<$)
[/code]
>>
>>8459092
I did this in the haskell type system and wrote fizzbuzz in it for the lulz

https://0x0.st/2Q-.hs
>>
>>8459176
It's funny how this is fucking short, and still, beyond that, the MonadPlus class even abstracts from it exactly like that

https://en.wikibooks.org/wiki/Haskell/MonadPlus

In your code: What's the backwards fish <$ again?
And is ":" the only List things in the power-line?
>>
Wait do academics unironically do things that can be done iteratively recursively in haskell
>>
File: Catamorphisms.png (107KB, 1001x406px) Image search: [Google]
Catamorphisms.png
107KB, 1001x406px
>>8459208
There is not "for" construction in haskell, but stuff like folds are another method
>>
>>8459207
>In your code: What's the backwards fish <$ again?
x <$ y = pure x <* y
or
x <$ y = const x <$> y
>>
>>8459208
>>8459213
there's `for` in haskell (but it's an example of a catamorphism)

for :: (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b)

for [1..10] doSomething

this would run `doSomething` on each number from 1 to 10 and collect all of the results
>>
>>8459268
>>8459213

sounds like mental masturbation to me

I don't know why anybody would want that when C or c++ exists
>>
>>8459304
It's okay brainlet, nobody's forcing you to move on
>>
>>8459304
Why have different languages at all?
Haskell in particular has laziness and (much) stronger type system, traded off for more abstraction (and different abstractions) and thus slower code
https://en.wikipedia.org/wiki/Hindley%E2%80%93Milner_type_system
https://en.wikipedia.org/wiki/Lazy_evaluation

But it was an academic project and there's also nothing wrong with that.
Why do we have different music bands?
>>
>>8459304

Different tools for different jobs.
>>
>>8458655
This.
>>
>>8458644
god damn, what language is this and why is addition not part of its core instructions
>>
>>8458644
>Not multiplying with fast fourier transform.
>>
>>8460180

Looks like Python.

The functions aren't adding/multiplying/raising to the power though. First concats two arrays, second outputs the second array a number of times equal to the length of the first, and the third seems to repeatedly output the first array the sum of the second array's elements times.

My Python's a bit shaky though, so that may well be wrong.
>>
File: haskell.png (3KB, 219x106px) Image search: [Google]
haskell.png
3KB, 219x106px
>>8458655
this, is python even trying?
>>
>>8460247
both of those implement the `min` operation
>>
>>8459006
+1
>>
>>8459006
>lot's of
>infuriating
>small
>parenthesis

if you are gonna write functional code, at least use OCaml
>>
>>8458644
>def power
and this is why imperative programming is cancer.
Thread posts: 34
Thread images: 6


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