18h
comment Why can you reverse list with foldl, but not with foldr in Haskell
you could also go from ((`g` 1) >>> (`g` 2) >>> (`g` 3) >>> id) t to ((t `g` 1) `g` 2) `g` 3.
19h
revised Understanding Type of `flip ($)`
c/e
19h
comment Understanding Type of `flip ($)`
cf. stackoverflow.com/a/14558244/849891 :)
1d
comment Why is super-compilation not more prevalent?
maybe a supercompiler could be part of the run time, observe execution times, and choose a better executable for future runs.
1d
comment How foldr works
alive again. :)
1d
comment Generating prime numbers in poly-time
"If primes were vanishingly rare" as is, indeed, the case with the 5-smooth numbers (a.k.a. "ugly numbers"), for example.
2d
comment GHC Partial Evaluation and Separate Compilation
one straightforward and costly way to deal with this is to run multiple instances of compiler with progressively increasing timeouts, producing a sequence of executables, from least to most pre-calculated. The tasks to perform the more pre-calculating compiles would be given smaller and smaller priorities, if computing resources become scarce, while the user could run, and thus explore the efficiency of the executables, as they become available.
2d
comment Accumulator in foldr
what you describe is foldr1 and it indeed errors on empty lists.
2d
comment Haskell Novice Trouble with Splitting a List in Half
halve a = go a [] a; go [] b c = (reverse b, c); go a b (c:d) = go (drop 2 a) (c:b) d is a well-known trick in Lisp folklore.
2d
revised Haskell Novice Trouble with Splitting a List in Half
clarify
Nov
21
comment Codechef - Alien chefs - time limit exceeded
stackoverflow.com/search?q=%5Bhaskell%5D+fenwick+AND+tree
Nov
21
awarded Fanatic
Nov
18
revised Infinite list not being terminated after appropriate value is found.
formatting, c/e
Nov
17
comment Writing partition for quicksort in scheme
as the error says: else can't be used on its own, it must start the last clause of a cond expression.
Nov
17
comment Proving foldr f st (xs++ys) = f (foldr f st xs) (foldr f st ys)
this only holds if f is associative, (a `f` b) `f` c == a `f` (b `f` c) (but foldr in general allows for asymmetric type of f :: a -> b -> b), and st is its right zero: f a st == a (counterexample: foldr (+) 1 (a++b) = foldr (+) 1 a + foldr (+) 1 b - 1).
Nov
16
revised Is applyTwice a well-known Haskell idiom?
small fix
Nov
16
comment Is applyTwice a well-known Haskell idiom?
a related Haskell combinator is Data.Function.on: (g `on` f) x y = g (f x) (f y) but that goes the other way around, with "one function, two arguments".
Nov
16
comment Is applyTwice a well-known Haskell idiom?
applyTwice g f1 f2 = (g.f1) <*> f2. So, yes, and no; it's an **S** combinator from combinatory logic and lambda-calculus.
Nov
16
comment Is Haskell's laziness an elegant alternative to Python's generators?
also, if you compile the file with -O2, the individual numbers won't be stored, because the only top-level entity that matters is main. They are stored in the interpreter, because you're using the interpreter. :)
Nov
16
comment What caused this "delayed read on closed handle" error?
why CW? you've made a valuable Q&A entry, get the rep you deserve! :)
1 2 3 4 5