3h
comment Haskell: How to get element from a Maybe tuple
try maybe undefined fst, or (fst <$>).
13h
comment In need of explanation of how my Tower of Hanoi Recursion code works
@Chap glad to be of help. :)
1d
revised What Is Tail Call Optimization?
add name of blog entry, its author, and copied tail-call stuff in.
1d
revised In need of explanation of how my Tower of Hanoi Recursion code works
added 227 characters in body
1d
answered In need of explanation of how my Tower of Hanoi Recursion code works
1d
comment Making a list of divisors without dividing sequentially in Haskell
I think it's better to always have explicit type signature for every module-level definition, especially in the finished code. Here in the answers we're sometimes a bit careless and hasty. :) (not the best of us) :)
2d
comment Force String to given length in Haskell
destroyallsoftware.com/talks/wat :)
2d
comment Functional Language Family of LISP and one Code Fragment?
ideone.com . ____
2d
comment Functional Language Family of LISP and one Code Fragment?
No user4249446, you should follow the advice of @Barmar. Try reading Touretzky's book "A Gentle Introduction to Symbolic Computation". -- and you forgot to mention the rplacd. That's the culprit. :)
2d
revised Functional Language Family of LISP and one Code Fragment?
added 1 character in body
2d
revised Haskell: Join on State Monad
added 49 characters in body
2d
revised Haskell: Join on State Monad
added 319 characters in body
2d
answered Haskell: Join on State Monad
2d
revised Making a list of divisors without dividing sequentially in Haskell
edited tags
2d
revised Can functions with non-pure arguments of type functions be pure?
edited tags
2d
revised Can functions with non-pure arguments of type functions be pure?
added 271 characters in body
2d
revised Making a list of divisors without dividing sequentially in Haskell
added 257 characters in body
2d
comment Making a list of divisors without dividing sequentially in Haskell
@HironobuNagaya Haskell takes guidance from the explicitly specified type signature. So you need to know what you're doing. If you write it wrong, you can cause type errors. Without it, it guesses, and then you have something to start from, if everything fits. OTOH there's type-directed development, where you start from types, they aid your thinking... -- In this case, you already gave the signature to factors, so the type for divisors in my answer gets deduced correspondingly, so I didn't bother. Type signatures are good, esp. in the finished product.
Feb
10
comment Iterative factorial procedure in SICP
the reason is the separation of concerns, in the book's version: one is to maintain data needed for the next step calculation, the other is testing for when to stop. Your version conflates the two -- uses n for both (you make this possible by counting down instead of counting up, but is it always possible to morph a code in such a way?). It is also more fragile, prone to errors because of that. So methodologically, theirs is "cleaner", one might argue. --- I believe you have a typo and the 1st line of code in your 3rd snippet needs to be moved 5 lines down? -- yes, both are iterative.
Feb
10
comment Making a list of divisors without dividing sequentially in Haskell
behzad.nouri's code uses all numbers as candidates; yours just primes. Should be faster, right? Except it takes time to generate them first. Your code is still slow -- it uses trial division, not the sieve of Eratosthenes which can be much faster (check out the package arithmoi). But at least for the 2nd run, the same list of primes can be used, that was already calculated before, right? Not unless you give it a monomorphic type signature, like [Int], or [Integer]. But you gave it polymorphic type, Integral a => [a]. So it is recalculated each time! :)
1 2 3 4 5