Search Haskell Channel Logs

Saturday, February 25, 2017

#haskell channel featuring flxw, bollu, razieliyo, juhp, lambdabot, MarcelineVQ,

adarqui 2017-02-24 21:59:31
cool thanks sternmull! i ended up just piping stdout: (_, Just h_out, _, _) <- (Process.createProcess $ (proc "proc" args) { std_out = CreatePipe }) >>= hGetContents
juhp 2017-02-24 22:01:25
is there a good name for `not . null` ?
sternmull 2017-02-24 22:02:57
adarqui: right, if you don't actually need a file then it is of course better to just stream the output to the consumer
MarcelineVQ 2017-02-24 22:04:16
that's readProcess yeah?
juhp 2017-02-24 22:05:17
I guess I'll go with notNull ;)
MarcelineVQ 2017-02-24 22:06:37
juhp: I can't think of anything shorter :>
juhp 2017-02-24 22:06:48
:)
juhp 2017-02-24 22:06:52
me neither
razieliyo 2017-02-24 22:39:26
hi
razieliyo 2017-02-24 22:39:26
I'm starting project euler to learn some haskell and I have a question for my naive solution for the second problem
razieliyo 2017-02-24 22:39:26
http://pastebin.com/hgV30ivj
razieliyo 2017-02-24 22:39:50
it's taking forever, is it because the naive fibonacci function approach? also I'm computing it a lot of times
bollu 2017-02-24 22:39:52
razieliyo: what is the question?
razieliyo 2017-02-24 22:40:03
bollu, that's the question
bollu 2017-02-24 22:40:15
ah, OK
bollu 2017-02-24 22:40:24
razieliyo: yes, you're computing the recurrence "fully" each time
razieliyo 2017-02-24 22:40:32
so that's what is slowing it down, right?
bollu 2017-02-24 22:40:36
yep
bollu 2017-02-24 22:40:38
razieliyo: the "slick" way of writing fibonacci in haskell is this:
razieliyo 2017-02-24 22:40:39
nice, thank you bollu
bollu 2017-02-24 22:40:45
(where we make use of laziness)
bollu 2017-02-24 22:41:04
>fib = 1:1:(zipWith (+) fib (tail fib))
razieliyo 2017-02-24 22:41:06
I read an implementation using zipWith and a infinite list, it's awesome
bollu 2017-02-24 22:41:08
> >fib = 1:1:(zipWith (+) fib (tail fib))
razieliyo 2017-02-24 22:41:11
cool
lambdabot 2017-02-24 22:41:11
:1:1: error: parse error on input '>'
bollu 2017-02-24 22:41:14
yeah :D
bollu 2017-02-24 22:41:23
well, since you've seen it
razieliyo 2017-02-24 22:42:00
thanks for the help bollu :)
bollu 2017-02-24 22:42:03
razieliyo: np :)
bollu 2017-02-24 22:42:41
razieliyo: this is somewhat unrelated to the problem at hand
bollu 2017-02-24 22:42:41
razieliyo: but have you seen how to compute fib using matrix multiplication?
razieliyo 2017-02-24 22:42:41
bollu, no, how is that?
bollu 2017-02-24 22:42:41
razieliyo: this is useful if you want the nth term in the fib sequence
razieliyo 2017-02-24 22:42:50
well, I'll take a peek at google
bollu 2017-02-24 22:43:01
razieliyo: yes. I think this is decent: https://kukuruku.co/post/the-nth-fibonacci-number-in-olog-n/
razieliyo 2017-02-24 22:43:34
nice, thanks bollu
octarin 2017-02-24 22:44:51
Yes, you just need to implement a 2x2 matrix data type and make it an instance of Num in order to use (^)
flxw 2017-02-24 22:44:54
a third way to compute the n-th fibonacci number would be to use the golden ratio formula. Have you seen this, too?
octarin 2017-02-24 22:44:55
that's quite elegant