Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: How to get each list in a list of lists for filter
(Harald B?geholz)
----------------------------------------------------------------------
Message: 1
Date: Tue, 31 Dec 2013 21:34:44 +0100
From: Harald B?geholz <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] How to get each list in a list of
lists for filter
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Am 31.12.13 19:48, schrieb Angus Comber:
> I am getting a list of lists from chop9. I want to somehow filter each
> element in the list. How do I do that.
>
> I have encoded binary data eg [1,1,0,0,1,0] etc
>
> Each 9th bit is a parity bit which is checked using this function:
>
> type Bit = Int
>
> paritychecker :: [Bit] -> Bool
> paritychecker xs | length xs == 9 && ((sum (init xs)) `mod` 2) == (last xs)
> = True
> | otherwise = False
>
>
> In the stream (the list) I use chop to retrieve each block of 9 bits as in:
>
> chop9 :: [Bit] -> [[Bit]]
> chop9 [] = []
> chop9 bits = take 8 bits : chop9 (drop 8 bits)
>
> I have been playing with this sort of thing:
> filter paritychecker ??? chop9 [1,0,0,0,1,1,1,0,0,...]
>
> But doesn't work.
Could a simple typo be the problem?
Shouldn't chop9 .. take 9 bits ... and ... drop 9 bits ... instead of 8?
Harald
--
Harald B?geholz <[email protected]> (PGP key available from servers)
Redaktion c't Tel.: +49 511 5352-300 Fax: +49 511 5352-417
http://www.ct.de/
int f[9814],b,c=9814,g,i;long a=1e4,d,e,h;
main(){for(;b=c,c-=14;i=printf("%04d",e+d/a),e=d%a)
while(g=--b*2)d=h*b+a*(i?f[b]:a/5),h=d/--g,f[b]=d%g;}
(Arndt/Haenel)
Affe Apfel Vergaser
/* Heise Zeitschriften Verlag GmbH & Co. KG * Karl-Wiechert-Allee 10 *
30625 Hannover * Registergericht: Amtsgericht Hannover HRA 26709 *
Pers?nlich haftende Gesellschafterin: Heise Zeitschriften Verlag *
Gesch?ftsf?hrung GmbH * Registergericht: Amtsgericht Hannover, HRB
60405 * Gesch?ftsf?hrer: Ansgar Heise, Dr. Alfons Schr?der */
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 67, Issue 1
****************************************