Article View: pl.comp.lang.funkcyjne
Article #717[Haskell] head xs a x:xs
From: Zbyszek Malec
Date: Wed, 07 Sep 2005 21:47
Date: Wed, 07 Sep 2005 21:47
26 lines
1483 bytes
1483 bytes
Hej
Mam w haskellu taką prostą funkjcę:
ta się kompiluje
delete :: Char -> String -> String
delete c [] = []
delete c xs | c == (head xs) = delete c (tail xs)
| otherwise = (head xs):delete c xs
a ta już nie
delete :: Char -> String -> String
delete c [] = []
delete c x:xs | c == x = delete c xs --linia 131
| otherwise = x:delete c xs
Różnią sie tylko zastąpieniem x przez wywołanie funkcji head oraz xs
poprzez tail. Dlaczego tak jest? Nie jestem biegły w Haskellu, więc może to
jest kwestia doczytania czegoś, ale nie wiem nawet dlaczego miało by to być
źle.
Błąd jaki dostaję to:
Main.hs:131:0: Parse error in pattern
--
Zbigniew Malec Ustronie 104 gg:2756100
Technical Details
Message-ID:
<fs4x8h2sta59.kdobpdw4xagk.dlg@40tude.net>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail From: Zbyszek Malec <zbyszekto@tlen.pl> Newsgroups: pl.comp.lang.funkcyjne Subject: [Haskell] head xs a x:xs Date: Wed, 7 Sep 2005 23:47:58 +0200 Organization: "Portal Gazeta.pl -> http://www.gazeta.pl" Lines: 26 Message-ID: <fs4x8h2sta59.kdobpdw4xagk.dlg@40tude.net> NNTP-Posting-Host: ckj191.neoplus.adsl.tpnet.pl Mime-Version: 1.0 X-Trace: inews.gazeta.pl 1126129683 22256 83.31.85.191 (7 Sep 2005 21:48:03 GMT) X-Complaints-To: usenet@agora.pl NNTP-Posting-Date: Wed, 7 Sep 2005 21:48:03 +0000 (UTC) X-User: zbyszanna User-Agent: 40tude_Dialog/2.0.15.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit