Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.haskell > #362 > unrolled thread

List

Started bypip7kids@gmail.com
First post2016-04-15 08:23 -0700
Last post2016-04-16 04:07 -0700
Articles 6 — 5 participants

Back to article view | Back to comp.lang.haskell


Contents

  List pip7kids@gmail.com - 2016-04-15 08:23 -0700
    Re: List Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-04-15 17:21 +0100
      Re: List pip7k <philsivyer@googlemail.com> - 2016-04-16 03:28 -0700
        Re: List pip7k <philsivyer@googlemail.com> - 2016-04-16 03:57 -0700
          Re: List Mark Carroll <mtbc@bcs.org> - 2016-04-16 12:46 +0100
    Re: List philsivyer@googlemail.com - 2016-04-16 04:07 -0700

#362 — List

Frompip7kids@gmail.com
Date2016-04-15 08:23 -0700
SubjectList
Message-ID<8a0b955e-17d4-42f1-bde0-c1ca5623ffe3@googlegroups.com>
Hi
I'm trying to return True or False (based on a condition) on first character in a list.

eg
myList  ["Apple","Fruit","Pears","Misc"]
so - my first characters are
A
F
P
M

if first characters <= 'M' then Tue Else False

True
True
False
True
So far I have ...

isTrueFalse :: String -> Bool
isTrueFalse (x:_) = x <= 'M'
isTrueFalse _ = False

if I use ... print(isTrueFalse 'A'   .. Then I get true.
How can I use this logic against myList so as to return [True,TrueFalse,True]

Regards

[toc] | [next] | [standalone]


#363

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2016-04-15 17:21 +0100
Message-ID<8737qmvo4b.fsf@bsb.me.uk>
In reply to#362
pip7kids@gmail.com writes:

> I'm trying to return True or False (based on a condition) on first
> character in a list.
>
> eg
> myList  ["Apple","Fruit","Pears","Misc"]
> so - my first characters are
> A
> F
> P
> M
>
> if first characters <= 'M' then Tue Else False

Do you need to worry about case?  I.e. what about 'a' and 'z'?

> True
> True
> False
> True
> So far I have ...
>
> isTrueFalse :: String -> Bool
> isTrueFalse (x:_) = x <= 'M'
> isTrueFalse _ = False

That's a terrible name!  Every Bool-returning function could be called
that.  The name should say what a True return means -- specifically.

> if I use ... print(isTrueFalse 'A'   .. Then I get true.
> How can I use this logic against myList so as to return
> [True,TrueFalse,True]

Look at map in the standard prelude.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#364

Frompip7k <philsivyer@googlemail.com>
Date2016-04-16 03:28 -0700
Message-ID<279ae91d-7b5e-47ae-b6ea-70811450239c@googlegroups.com>
In reply to#363
Hi
Sorry about the name - not case sensitive

Thanks

On Friday, April 15, 2016 at 5:21:57 PM UTC+1, Ben Bacarisse wrote:
> .com writes:
> 
> > I'm trying to return True or False (based on a condition) on first
> > character in a list.
> >
> > eg
> > myList  ["Apple","Fruit","Pears","Misc"]
> > so - my first characters are
> > A
> > F
> > P
> > M
> >
> > if first characters <= 'M' then Tue Else False
> 
> Do you need to worry about case?  I.e. what about 'a' and 'z'?
> 
> > True
> > True
> > False
> > True
> > So far I have ...
> >
> > isTrueFalse :: String -> Bool
> > isTrueFalse (x:_) = x <= 'M'
> > isTrueFalse _ = False
> 
> That's a terrible name!  Every Bool-returning function could be called
> that.  The name should say what a True return means -- specifically.
> 
> > if I use ... print(isTrueFalse 'A'   .. Then I get true.
> > How can I use this logic against myList so as to return
> > [True,TrueFalse,True]
> 
> Look at map in the standard prelude.
> 
> -- 
> Ben.

[toc] | [prev] | [next] | [standalone]


#365

Frompip7k <philsivyer@googlemail.com>
Date2016-04-16 03:57 -0700
Message-ID<76f6faf7-842d-4786-8a5b-545aed84a2d9@googlegroups.com>
In reply to#364
On Saturday, April 16, 2016 at 11:28:20 AM UTC+1, pip7k wrote:
> Hi
> Sorry about the name - not case sensitive
> 
> Thanks
> 
> On Friday, April 15, 2016 at 5:21:57 PM UTC+1, Ben Bacarisse wrote:
> > .com writes:
> > 
> > > I'm trying to return True or False (based on a condition) on first
> > > character in a list.
> > >
> > > eg
> > > myList  ["Apple","Fruit","Pears","Misc"]
> > > so - my first characters are
> > > A
> > > F
> > > P
> > > M
> > >
> > > if first characters <= 'M' then Tue Else False
> > 
> > Do you need to worry about case?  I.e. what about 'a' and 'z'?
> > 
> > > True
> > > True
> > > False
> > > True
> > > So far I have ...
> > >
> > > isTrueFalse :: String -> Bool
> > > isTrueFalse (x:_) = x <= 'M'
> > > isTrueFalse _ = False
> > 
> > That's a terrible name!  Every Bool-returning function could be called
> > that.  The name should say what a True return means -- specifically.
> > 
> > > if I use ... print(isTrueFalse 'A'   .. Then I get true.
> > > How can I use this logic against myList so as to return
> > > [True,TrueFalse,True]
> > 
> > Look at map in the standard prelude.
> > 
> > -- 
> > Ben.

Hi
I tried the following without success..

isGood :: String -> Bool
isGood (x:_) = x <= 'M'
isGood _ = False

myList = ["Apple","Fruit","Pears","Misc"] 
aa = map (isGood) $ map (head) myList

Regards

[toc] | [prev] | [next] | [standalone]


#367

FromMark Carroll <mtbc@bcs.org>
Date2016-04-16 12:46 +0100
Message-ID<87mvotkc7j.fsf@ixod.org>
In reply to#365
On 16 Apr 2016, pip7k wrote:

> I tried the following without success..
>
> isGood :: String -> Bool
> isGood (x:_) = x <= 'M'
> isGood _ = False
>
> myList = ["Apple","Fruit","Pears","Misc"] 
> aa = map (isGood) $ map (head) myList

Did you simply want,

	aa = map isGood myList

...?

-- Mark

[toc] | [prev] | [next] | [standalone]


#366

Fromphilsivyer@googlemail.com
Date2016-04-16 04:07 -0700
Message-ID<47a5a10e-d9bf-46ec-85d1-33347ee35c40@googlegroups.com>
In reply to#362
On Friday, April 15, 2016 at 4:23:57 PM UTC+1, pip7...@gmail.com wrote:
> Hi
> I'm trying to return True or False (based on a condition) on first character in a list.
> 
> eg
> myList  ["Apple","Fruit","Pears","Misc"]
> so - my first characters are
> A
> F
> P
> M
> 
> if first characters <= 'M' then Tue Else False
> 
> True
> True
> False
> True
> So far I have ...
> 
> isTrueFalse :: String -> Bool
> isTrueFalse (x:_) = x <= 'M'
> isTrueFalse _ = False
> 
> if I use ... print(isTrueFalse 'A'   .. Then I get true.
> How can I use this logic against myList so as to return [True,TrueFalse,True]
> 
> Regards

Hi
OK - got it it's...
isGood :: String -> Bool
isGood (x:_) = x <= 'M'
isGood _ = False

myList = ["Apple","Fruit","Pears","Misc"] 
aa = map isGood myList

Regards

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.haskell


csiph-web