On Tue, Jul 28, 2009 at 6:47 AM, Sebastian
Fischer wrote:
>>> perms = sortByM (const [True,False])
> Hence, perm as defined above can yield a list that contains all permutations
> of the input (at least once) regardless of the sorting algorithm.
>
> Where is the hitch?
The algorithm might diverge
Sebastian Fischer wrote:
> On Jul 28, 2009, at 11:06 AM, Sittampalam, Ganesh wrote:
>
>>> perms = sortByM (const [True,False])
>>
>> and moreover the results will depend on the sorting algorithm chosen.
>
> Is it only that different sorting algorithms enumerate all
> permutations in different or
On Jul 28, 2009, at 11:06 AM, Sittampalam, Ganesh wrote:
perms = sortByM (const [True,False])
This doesn't seem right, since the comparison function is inconsistent
I was also wary about this point, e.g. QuickSort depends on
transitivity.
and moreover the results will depend on the sor
On Tue, Jul 28, 2009 at 10:58:53AM +0200, Sebastian Fischer wrote:
> tails = dropWhileM (const [True,False])
Actually this should be
tails = dropWhileM (const [False, True])
--
Felipe.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://w
> perms = sortByM (const [True,False])
This doesn't seem right, since the comparison function is inconsistent
and moreover the results will depend on the sorting algorithm chosen.
Ganesh
===
Please access the attached
The M is the list, i.e. nondeterminism monad. For each element in
the list, there is one return value where it appears (True), and one
where it does not (False).
This discussion made Curry [1] programmers realise the beauty of non-
determinism and lead to interesting reformulations of comm
Thomas Hartman wrote:
> on haskell reddit today
> powerSet = filterM (const [True, False])
>
> is said to be beautiful / mind blowing.
> Is this a uniquely haskell obfu, or is there a way of reading this
> definition that makes sense?
To me, these are more obvious:
powerSet = map catMaybes . mapM
For each item, we ignore what the item actually is (hence `const`),
and say that we both want it (True) and don't want it (False) in the
output. Since we are using the list monad we are allowed to say this,
and the filter function gives us a list of lists. I think there's
probably a more intuitive
On Fri, Jul 17, 2009 at 1:35 AM, Thomas Hartman wrote:
> on haskell reddit today
>
> powerSet = filterM (const [True, False])
The M is the list, i.e. *nondeterminism* monad. For each element in the
list, there is one return value where it appears (True), and one where it
does not (False).
Ba
on haskell reddit today
powerSet = filterM (const [True, False])
is said to be beautiful / mind blowing. I just don't get it. I can
play with transformations until I get
powerSet [] = [[]]
powerSet (x:xs) =
let pxs = powerSet xs
in map (x:) pxs ++ pxs
which is understandable to me, b
10 matches
Mail list logo