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.  error with cabal install readline (Ashish Agarwal)
   2.  Re: error with cabal install readline (Heinrich Apfelmus)
   3.  homogeneous value list (Luca Ciciriello)
   4. Re:  homogeneous value list (Daniel Fischer)
   5. Re:  homogeneous value list (Roger Whittaker)
   6. Re:  homogeneous value list (allan)
   7. Re:  homogeneous value list (Daniel Fischer)
   8. Re:  homogeneous value list (Ozgur Akgun)
   9. Re:  homogeneous value list (Salil Wadnerkar)


----------------------------------------------------------------------

Message: 1
Date: Wed, 10 Mar 2010 15:02:40 -0500
From: Ashish Agarwal <[email protected]>
Subject: [Haskell-beginners] error with cabal install readline
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

I'm on a Mac, and trying to install readline through cabal. I installed the
readline library through macports and thus tried the command below. However,
readline is still not found. Are there other options I can try? Thank you.

$ cabal install readline --extra-include-dirs=/opt/local/include/
--extra-lib-dirs=/opt/local/lib/
Resolving dependencies...
Configuring readline-1.0.1.0...
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for GNUreadline.framework... checking for readline... no
checking for tputs in -lncurses... yes
checking for readline in -lreadline... yes
checking for rl_readline_version... yes
checking for rl_begin_undo_group... no
configure: error: readline not found, so this package cannot be built
See `config.log' for more details.
cabal: Error: some packages failed to install:
readline-1.0.1.0 failed during the configure step. The exception was:
exit: ExitFailure 1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20100310/4343bb9d/attachment-0001.html

------------------------------

Message: 2
Date: Thu, 11 Mar 2010 10:49:49 +0100
From: Heinrich Apfelmus <[email protected]>
Subject: [Haskell-beginners] Re: error with cabal install readline
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8

Ashish Agarwal wrote:
> I'm on a Mac, and trying to install readline through cabal. I installed the
> readline library through macports and thus tried the command below. However,
> readline is still not found. Are there other options I can try? Thank you.
> 
> $ cabal install readline --extra-include-dirs=/opt/local/include/
> --extra-lib-dirs=/opt/local/lib/
> Resolving dependencies...
> Configuring readline-1.0.1.0...
> checking for gcc... gcc
> checking for C compiler default output file name... a.out
> checking whether the C compiler works... yes
> checking whether we are cross compiling... no
> checking for suffix of executables...
> checking for suffix of object files... o
> checking whether we are using the GNU C compiler... yes
> checking whether gcc accepts -g... yes
> checking for gcc option to accept ISO C89... none needed
> checking for GNUreadline.framework... checking for readline... no
> checking for tputs in -lncurses... yes
> checking for readline in -lreadline... yes
> checking for rl_readline_version... yes
> checking for rl_begin_undo_group... no
> configure: error: readline not found, so this package cannot be built
> See `config.log' for more details.
> cabal: Error: some packages failed to install:
> readline-1.0.1.0 failed during the configure step. The exception was:
> exit: ExitFailure 1

It's the  configure  shell script that doesn't see the extra
directories. Setting the CPPFLAGS and LDFLAGS environment variables
should do the trick. Personally, I'm using the following shell script

    > cat cabal-macports
    #!/bin/bash
    # Run commands with /opt/local/ directories
    export CPPFLAGS=-I/opt/local/include
    export LDFLAGS=-L/opt/local/lib
    cabal $@ --extra-include-dirs=/opt/local/include \
             --extra-lib-dirs=/opt/local/lib

    > cabal-macports install readline

(Make sure you installed the MacPorts readline with  +universal .)


Regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com



------------------------------

Message: 3
Date: Fri, 12 Mar 2010 13:27:21 +0000
From: Luca Ciciriello <[email protected]>
Subject: [Haskell-beginners] homogeneous value list
To: <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"


Hi.

I know, this is a very basic question but I've had some trouble with it.

 

I've a list and I want to write a function 

 

isHomogeneous :: [String] -> Bool

 

returning True is all the elements of the list are equals and False otherwise. 
In my first ugly test I've used a list-comprehension method, but I'm sure that 
exists a more elegant/short way to obtain the same result.

 

Thanks in advance for any answer.

 

Luca
                                          
_________________________________________________________________
Tell us your greatest, weirdest and funniest Hotmail stories
http://clk.atdmt.com/UKM/go/195013117/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20100312/3585f770/attachment-0001.html

------------------------------

Message: 4
Date: Fri, 12 Mar 2010 14:41:11 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] homogeneous value list
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain;  charset="utf-8"

Am Freitag 12 März 2010 14:27:21 schrieb Luca Ciciriello:
> Hi.
>
> I know, this is a very basic question but I've had some trouble with it.
>
>
>
> I've a list and I want to write a function
>
>
>
> isHomogeneous :: [String] -> Bool
>
>
>
> returning True is all the elements of the list are equals and False
> otherwise. In my first ugly test I've used a list-comprehension method,
> but I'm sure that exists a more elegant/short way to obtain the same
> result.
>
>
>
> Thanks in advance for any answer.

isHomogeneous :: Eq a => [a] -> Bool
isHomogeneous [] = True
isHomogeneous (x:xs) = all (== x) xs

>
>
>
> Luca



------------------------------

Message: 5
Date: Fri, 12 Mar 2010 13:44:21 +0000
From: Roger Whittaker <[email protected]>
Subject: Re: [Haskell-beginners] homogeneous value list
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

On Fri, Mar 12, 2010 at 01:27:21PM +0000, Luca Ciciriello wrote:

> I've a list and I want to write a function
>
> isHomogeneous :: [String] -> Bool
>
> returning True is all the elements of the list are equals and
> False otherwise. In my first ugly test I've used a
> list-comprehension method, but I'm sure that exists a more
> elegant/short way to obtain the same result.

I'm a total beginner, so I don't know if this is the best way, but
I tried:

isHomogeneous :: [String] -> Bool

isHomogeneous [] = True
isHomogeneous [x] = True
isHomogeneous (x:xs) = if x == head xs && isHomogeneous xs 
                       then True
                       else False



-- 
========================
Roger Whittaker
[email protected]
http://disruptive.org.uk
========================


------------------------------

Message: 6
Date: Fri, 12 Mar 2010 13:53:39 +0000
From: allan <[email protected]>
Subject: Re: [Haskell-beginners] homogeneous value list
To: Roger Whittaker <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

This is not bad, I think Daniel's version is a bit more elegant.
One point though, whenever you see "then True else False" you can just 
remove the conditional.
if cexp then True else False is the same as just 'cexp'
Your last line becomes simply:

isHomogeneous (x:xs) = x == head xs && isHomogeneous xs



> I'm a total beginner, so I don't know if this is the best way, but
> I tried:
>
> isHomogeneous :: [String] -> Bool
>
> isHomogeneous [] = True
> isHomogeneous [x] = True
> isHomogeneous (x:xs) = if x == head xs && isHomogeneous xs 
>                        then True
>                        else False
>
>
>
>   


-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.



------------------------------

Message: 7
Date: Fri, 12 Mar 2010 15:08:18 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] homogeneous value list
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain;  charset="utf-8"

Am Freitag 12 März 2010 14:41:11 schrieb Daniel Fischer:
>
> isHomogeneous :: Eq a => [a] -> Bool
> isHomogeneous [] = True
> isHomogeneous (x:xs) = all (== x) xs
>

Variant, getting rid of the special case for an empty list:

isHomogeneous :: Eq a => [a] -> Bool
isHomogeneous xs = and (zipWith (==) xs (drop 1 xs))


------------------------------

Message: 8
Date: Fri, 12 Mar 2010 14:21:17 +0000
From: Ozgur Akgun <[email protected]>
Subject: Re: [Haskell-beginners] homogeneous value list
To: Daniel Fischer <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="utf-8"

Another boring variant from me then.

isHomogeneous xs = all (first==) xs
    where first = head xs

Guess what? You do not need the special case for [], because "all _ [] =
True" allways. So if the list is empty, it won't even try evaluating
"first".

Cheers,

On 12 March 2010 14:08, Daniel Fischer <[email protected]> wrote:

> Am Freitag 12 März 2010 14:41:11 schrieb Daniel Fischer:
> >
> > isHomogeneous :: Eq a => [a] -> Bool
> > isHomogeneous [] = True
> > isHomogeneous (x:xs) = all (== x) xs
> >
>
> Variant, getting rid of the special case for an empty list:
>
> isHomogeneous :: Eq a => [a] -> Bool
> isHomogeneous xs = and (zipWith (==) xs (drop 1 xs))
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>



-- 
Ozgur Akgun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20100312/262cbeda/attachment-0001.html

------------------------------

Message: 9
Date: Fri, 12 Mar 2010 22:25:48 +0800
From: Salil Wadnerkar <[email protected]>
Subject: Re: [Haskell-beginners] homogeneous value list
To: Ozgur Akgun <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

On Fri, Mar 12, 2010 at 10:21 PM, Ozgur Akgun <[email protected]> wrote:
> Another boring variant from me then.
>
> isHomogeneous xs = all (first==) xs
>     where first = head xs


Shouldn't
head xs
give an exception on an empty list?



>
> Guess what? You do not need the special case for [], because "all _ [] =
> True" allways. So if the list is empty, it won't even try evaluating
> "first".
>
> Cheers,
>
> On 12 March 2010 14:08, Daniel Fischer <[email protected]> wrote:
>>
>> Am Freitag 12 März 2010 14:41:11 schrieb Daniel Fischer:
>> >
>> > isHomogeneous :: Eq a => [a] -> Bool
>> > isHomogeneous [] = True
>> > isHomogeneous (x:xs) = all (== x) xs
>> >
>>
>> Variant, getting rid of the special case for an empty list:
>>
>> isHomogeneous :: Eq a => [a] -> Bool
>> isHomogeneous xs = and (zipWith (==) xs (drop 1 xs))
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>
>
>
> --
> Ozgur Akgun
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>


------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 21, Issue 10
*****************************************

Reply via email to