https://wiki.haskell.org/index.php?title=Haskell_Quiz/Text_Munger/Solution_Dolio&feed=atom&action=history
Haskell Quiz/Text Munger/Solution Dolio - Revision history
2024-03-29T09:56:41Z
Revision history for this page on the wiki
MediaWiki 1.35.5
https://wiki.haskell.org/index.php?title=Haskell_Quiz/Text_Munger/Solution_Dolio&diff=10232&oldid=prev
Quale: sharpen cat
2007-01-13T10:57:38Z
<p>sharpen cat</p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 10:57, 13 January 2007</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td>
</tr>
<tr>
<td class="diff-marker">−</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>[[Category:<del class="diffchange diffchange-inline">Code</del>]]</div></td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>[[Category:<ins class="diffchange diffchange-inline">Haskell Quiz solutions|Text Munger</ins>]]</div></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>This solution makes use of the [[New monads/MonadRandom|random monad]] elsewhere on the wiki.</div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>This solution makes use of the [[New monads/MonadRandom|random monad]] elsewhere on the wiki.</div></td>
</tr>
</table>
Quale
https://wiki.haskell.org/index.php?title=Haskell_Quiz/Text_Munger/Solution_Dolio&diff=7422&oldid=prev
Dolio: New page
2006-10-27T08:23:17Z
<p>New page</p>
<p><b>New page</b></p><div>[[Category:Code]]<br />
<br />
This solution makes use of the [[New monads/MonadRandom|random monad]] elsewhere on the wiki.<br />
<br />
<haskell><br />
module Main where<br />
import Control.Monad<br />
import Data.Char<br />
import Data.List<br />
import System.Random<br />
import MonadRandom<br />
<br />
permute [] = return []<br />
permute l = do r <- getRandomR (0, n)<br />
let (a, e:b) = splitAt r l<br />
l' <- permute (a ++ b)<br />
return $ e : l'<br />
where n = length l - 1<br />
<br />
munge l<br />
| isAlpha h && length l > 2 = ((h:) . (++[f])) `liftM` permute m<br />
| otherwise = return l<br />
where h = head l<br />
f = last l<br />
m = tail (init l)<br />
<br />
main = do g <- getStdGen<br />
interact $ flip evalRand g . liftM join . mapM munge . groupBy f<br />
where f a b = isAlpha a == isAlpha b<br />
</haskell></div>
Dolio