Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/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 check the format of a string ?
(Sumit Sahrawat, Maths & Computing, IIT (BHU))
2. Re: how to check the format of a string ? (Frerich Raabe)
3. Re: how to check the format of a string ? (Roelof Wobben)
----------------------------------------------------------------------
Message: 1
Date: Mon, 23 Feb 2015 00:57:19 +0530
From: "Sumit Sahrawat, Maths & Computing, IIT (BHU)"
<[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 check the format of a string ?
Message-ID:
<CAJbEW8M43e4Te2guWVxCkEsUtnRJf=w2h9zwc77fy9taopt...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Also, as far as I remember, cis194 made you build parser combinators like
parsec and attoparsec when teaching applicative functors and other fancy
stuff.
You can opt to wait till then.
On 23 February 2015 at 00:55, Sumit Sahrawat, Maths & Computing, IIT (BHU) <
[email protected]> wrote:
> The exercise was meant to be done without using any library. Try it out,
> it will work.
> A parser combinator library, such as parsec or attoparsec is better learnt
> after you have some idea of monads, which is the last topic cis194 deals
> with.
> But, if it interests you, keep going. Parsec might be a better option as
> it has been there for a longer amount of time, and thus has more learning
> resources.
>
> Hope this helps.
>
> On 23 February 2015 at 00:52, Roelof Wobben <[email protected]> wrote:
>
>> Thanks,
>>
>> Found this tutorial which works with log files like I have to do :
>> https://www.fpcomplete.com/school/starting-with-haskell/libraries-and-frameworks/text-manipulation/attoparsec
>>
>> Roelof
>>
>>
>>
>> Benjamin Edwards schreef op 22-2-2015 om 20:14:
>>
>> If the format is sufficiently simple a regex can be a very neat way to
>> express the idea. Mostly people use parser combinators. Have a look at
>> parsec / attoparsec on hackage.
>>
>> Ben
>>
>> On Sun Feb 22 2015 at 18:50:18 Roelof Wobben <[email protected]> wrote:
>>
>>> Hello,
>>>
>>> Im still busy with CIS 194
>>>
>>> Now im facing this problem.
>>>
>>> There is a log file of strings.
>>>
>>> Most of them are of this format char Number [chars]
>>>
>>> What is the best way to check if the string has this format ?
>>>
>>> Regex or another way ?
>>>
>>> Roelof
>>>
>>> _______________________________________________
>>> Beginners mailing list
>>> [email protected]
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>>
>>
>>
>> _______________________________________________
>> Beginners mailing
>> [email protected]http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>>
>
>
> --
> Regards
>
> Sumit Sahrawat
>
--
Regards
Sumit Sahrawat
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150223/6f186d91/attachment-0001.html>
------------------------------
Message: 2
Date: Sun, 22 Feb 2015 20:38:38 +0100
From: Frerich Raabe <[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 check the format of a string
?
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII; format=flowed
On 2015-02-22 19:50, Roelof Wobben wrote:
> Now im facing this problem.
>
> There is a log file of strings.
>
> Most of them are of this format char Number [chars]
>
> What is the best way to check if the string has this format ?
For this particular format I'd go for plain pattern matching and guards.
Something like
import Data.Char (isLetter, isDigit)
isValid :: String -> Bool
isValid s = go (words s)
where
go ([a]:b:_) = isLetter a && all isDigit b
go _ = False
This will accept lines starting with a letter followed by some number and
then (optionally!) some more text.
--
Frerich Raabe - [email protected]
www.froglogic.com - Multi-Platform GUI Testing
------------------------------
Message: 3
Date: Sun, 22 Feb 2015 21:23:01 +0100
From: Roelof Wobben <[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 check the format of a string
?
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252; format=flowed
Frerich Raabe schreef op 22-2-2015 om 20:38:
> On 2015-02-22 19:50, Roelof Wobben wrote:
>> Now im facing this problem.
>>
>> There is a log file of strings.
>>
>> Most of them are of this format char Number [chars]
>>
>> What is the best way to check if the string has this format ?
>
> For this particular format I'd go for plain pattern matching and
> guards. Something like
>
> import Data.Char (isLetter, isDigit)
>
> isValid :: String -> Bool
> isValid s = go (words s)
> where
> go ([a]:b:_) = isLetter a && all isDigit b
> go _ = False
>
> This will accept lines starting with a letter followed by some number
> and then (optionally!) some more text.
>
Thanks,
I can also check if a is equal to I , W or E.
And in the main function check if A = I/W/E
Roelof
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 80, Issue 63
*****************************************