Article View: pl.comp.lang.funkcyjne
Article #364Re: [Haskell] Lista bez powtórzeń.
From: Tomasz Zielonka
Date: Mon, 16 Jun 2003 12:33
Date: Mon, 16 Jun 2003 12:33
30 lines
1450 bytes
1450 bytes
Marcin Gajda napisał:
> Witam,
Nie mam teraz za dużo czasu, więc tylko rzucę dwie propozycje:
module A where
import Control.Monad.Cont
import Control.Monad
import Data.Set
import List
powt1 :: Ord a => [a] -> Bool
powt1 l =
runCont (callCC (\exit -> foldM (step exit) emptySet l >> return False)) id
where
step exit set x = do
when (x `elementOf` set) (exit True)
return (addToSet set x)
powt2 :: Ord a => [a] -> Bool
powt2 l = any (> 1) (map length (group (sort l)))
> Pozdrawiam,
pozdrawiam,
tomek
--
.signature: Too many levels of symbolic links
Technical Details
Message-ID:
<slrnbere7s.5ic.t.zielonka@zodiac.mimuw.edu.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!mimuw.edu.pl!news.mimuw.edu.pl!not-for-mailReferences:
<bcijpt$1s1$1@kenny.mimuw.edu.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!mimuw.edu.pl!news.mimuw.edu.pl!not-for-mail From: Tomasz Zielonka <t.zielonka@students.mimuw.edu.pl> Newsgroups: pl.comp.lang.funkcyjne Subject: Re: [Haskell] Lista bez powtórzeń. Date: Mon, 16 Jun 2003 12:33:02 +0000 (UTC) Organization: MIMUW Lines: 30 Message-ID: <slrnbere7s.5ic.t.zielonka@zodiac.mimuw.edu.pl> References: <bcijpt$1s1$1@kenny.mimuw.edu.pl> Reply-To: t.zielonka@students.mimuw.edu.pl NNTP-Posting-Host: zodiac.mimuw.edu.pl Mime-Version: 1.0 X-Trace: kenny.mimuw.edu.pl 1055766782 4766 10.1.1.1 (16 Jun 2003 12:33:02 GMT) X-Complaints-To: abuse@news.mimuw.edu.pl NNTP-Posting-Date: Mon, 16 Jun 2003 12:33:02 +0000 (UTC) User-Agent: slrn/0.9.7.3 (Linux) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit