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


Groups > comp.lang.haskell > #363

Re: List

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.haskell
Subject Re: List
Date 2016-04-15 17:21 +0100
Organization A noiseless patient Spider
Message-ID <8737qmvo4b.fsf@bsb.me.uk> (permalink)
References <8a0b955e-17d4-42f1-bde0-c1ca5623ffe3@googlegroups.com>

Show all headers | View raw


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.

Back to comp.lang.haskell | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web