Mar
23
revised Understanding Structure Sharing in Haskell
typos
Mar
23
comment What if we split the array in merge sort into 4 parts?? or eight parts?
we should solve T(n)=2*T(n/2)+n vs. e.g. T(n)=8*T(n/8)+3*n directly, to see this for sure. the first seems to be n*logBase(2,n), the second 3*n*logBase(8,n) (right?) which is the same, so, yes.
Mar
23
comment What if we split the array in merge sort into 4 parts?? or eight parts?
I'd expect the merge step to be 2N in case of 4-split, and 3N for 8-split (not that it changes the complexity, it doesn't).
Mar
20
answered Haskell custom datatype with parameter
Mar
18
awarded haskell
Mar
16
comment How to achieve tail recursion in functional programs
see also stackoverflow.com/search?tab=newest&q=defunctionalization, esp. stackoverflow.com/questions/9323036/….
Mar
15
comment How to achieve tail recursion in functional programs
sometimes you can do en.wikipedia.org/wiki/Tail_call#Tail_recursion_modulo_cons. sometimes kons can be turned into associative append and so an accumulating version can be written. when all else fails, there's CPS, and the continuations can be reified - built as some data structure, not as actual lambdas - and then processed when all data is gathered (whole list is scanned through) (I vaguely remember Reynolds' en.wikipedia.org/wiki/Defunctionalization having something to do with that). Sometimes these data on heap can be simplified while being built.
Mar
11
comment Is this a correctly implemented mergesort in Haskell?
stable bottom-up mergesort: en.wikipedia.org/w/…
Mar
11
comment Is this a correctly implemented mergesort in Haskell?
with this twisting top-down split, the sort is not stable. It's better to split in half without measuring the length at all, by advancing two pointers, one at twice the speed of the other. bottom-up is best, esp. as you can separate out the "runs" in the initial pass, like is done in data-ordlist's nubSort.
Mar
8
comment Vector addition of elements behaving weird
two={1}, three={0,1}, mult(two,three) will cause out-of-bounds access to two[1]. always fully parenthesize your expressions while you're learning (i.e. i <f1.size() && f2.size()).
Mar
3
answered Sieve of Atkin explanation
Mar
2
comment Bindings inside lazy prime number generator function in Clojure
it should have been (cons x (allprimes (nextprime x))) anyway, no need for the let.
Mar
2
comment Generate a vector of 30 first primes in matlab
for n > 6, x < n(log n + log log n), according to Wikipedia.
Mar
2
revised Quick Prolog Issue
deleted 2 characters in body; edited tags
Mar
2
comment Generate a vector of 30 first primes in matlab
pseudocode: {2,3,...,120} \ {4,6,...,120} \ {9,12,...,120} \ {25,30,...,120} \ {49,56,...,120}. ("\" for "set-difference"; associates to the left).
Feb
27
comment Did we really have to delete this 80-vote community wiki answer after three years?
@GeorgeStocker what's your take on this (another) case? is the answer good enough to be preserved even though it is incomplete, and the question indeed off-topic? ( the question has almost 1500 views... and two of the deleters are the same as on this here question. )
Feb
26
revised Why does this Haskell code compile?
c/e
Feb
25
comment Sieve of Eratosthenes - Finding Primes Python
n for n in ilist if n%p != 0 tests each number n in a range for divisibility by p; but range(p*p, N, p) generates the multiples directly, all by itself, without testing all these numbers.
Feb
25
comment Interview question : What is the fastest way to generate prime number recursively?
@Charles thanks for the confirmation.
Feb
10
revised Haskell Arrow delay function
add missing code; formatting; c/e; retag
1 2 3 4 5