Send Beginners mailing list submissions to
        beginners@haskell.org

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
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Re: Beginners Digest, Vol 27, Issue 57 (Martin Tomko)
   2.  removing duplicate tuples (including symmetrical ones)
      (Martin Tomko)
   3. Re:  removing duplicate tuples (including symmetrical ones)
      (edgar klerks)
   4. Re:  removing duplicate tuples (including symmetrical ones)
      (edgar klerks)
   5. Re:  removing duplicate tuples (including symmetrical ones)
      (Martin Tomko)


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

Message: 1
Date: Tue, 28 Sep 2010 10:07:13 +0200
From: Martin Tomko <martin.to...@geo.uzh.ch>
Subject: [Haskell-beginners] Re: Beginners Digest, Vol 27, Issue 57
To: beginners@haskell.org
Message-ID: <4ca1a231.3000...@geo.uzh.ch>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Ahaaa, the heureka moment. Stupid me, I should have tried :t null
Thanks Brent!


On 9/27/2010 6:00 PM, beginners-requ...@haskell.org wrote:
> Send Beginners mailing list submissions to
>       beginners@haskell.org
>
> 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
>       beginners-requ...@haskell.org
>
> You can reach the person managing the list at
>       beginners-ow...@haskell.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Beginners digest..."
>
>
> Today's Topics:
>
>     1. Re:  matching the output of a standard function        to my
>        function definition (non-exhaustive pattern problem) (Brent Yorgey)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 27 Sep 2010 12:21:08 -0400
> From: Brent Yorgey<byor...@seas.upenn.edu>
> Subject: Re: [Haskell-beginners] matching the output of a standard
>       function        to my function definition (non-exhaustive pattern 
> problem)
> To: beginners@haskell.org
> Message-ID:<20100927162108.ga5...@seas.upenn.edu>
> Content-Type: text/plain; charset=us-ascii
>
> On Mon, Sep 27, 2010 at 06:15:22PM +0200, Martin Tomko wrote:
>    
>> Dear Daniel
>> that worked perfectly, thanks for the suggestion!
>>
>> One more question: how do you use null to check for empty lists?
>> something like [] == null did not work ... just chekcing, I got my
>> orignal code to work, thanks again!
>> Martin
>>      
> When in doubt, consult the types!
>
>    null :: [a] ->  Bool
>
> That is, null is a function for testing lists to see whether they are
> empty.  So rather than 'list == null' you write 'null list'.
>
> -Brent
>
>
> ------------------------------
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
> End of Beginners Digest, Vol 27, Issue 57
> *****************************************
>
>    


-- 
Martin Tomko
Postdoctoral Research Assistant

Geographic Information Systems Division
Department of Geography
University of Zurich - Irchel
Winterthurerstr. 190
CH-8057 Zurich, Switzerland

email:  martin.to...@geo.uzh.ch
site:   http://www.geo.uzh.ch/~mtomko
mob:    +41-788 629 558
tel:    +41-44-6355256
fax:    +41-44-6356848



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

Message: 2
Date: Tue, 28 Sep 2010 11:33:54 +0200
From: Martin Tomko <martin.to...@geo.uzh.ch>
Subject: [Haskell-beginners] removing duplicate tuples (including
        symmetrical     ones)
To: beginners@haskell.org
Message-ID: <4ca1b682.9020...@geo.uzh.ch>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi all,
I apologize for spamming this forum so frequently, but there is noone I 
can turn to around here...
I have a list of (a,a) tuples, and am trying something like nub, but 
also matching for symmetrical tuples. I implemented it using the 
template from delete from Prelude. Seems like my typse signature has 
some troubles (Paarse error in pattern) but I am not sure where the 
problem is.

removeDuplTuples :: [(a,a)] -> [(a,a)]
removeDuplTuples [] = []
removeDuplTuples [b] = [b]                                             
                                                                         
                 -- using the syntactic sugar for single element in list
removeDuplTuples x:xs = nub (if elem (snd x,fst x) xs then 
removeDuplTuples xs else [x] ++ removeDuplTuples xs)

I assume the problem lies in elem (snd x,fst x) xs but I am not sure how 
to rewrite it.

Thanks for all help,
Martin


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

Message: 3
Date: Tue, 28 Sep 2010 11:44:41 +0200
From: edgar klerks <edgar.kle...@gmail.com>
Subject: Re: [Haskell-beginners] removing duplicate tuples (including
        symmetrical ones)
To: martin.to...@geo.uzh.ch
Cc: beginners@haskell.org
Message-ID:
        <aanlkti=hu6jzyyzn=f4emth_dfvt8baed6p2w1hvi...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi Martin,

You have some typos:

import Data.List
removeDuplTuples :: (Eq a) => [(a,a)] -> [(a,a)]
removeDuplTuples [] = []
removeDuplTuples [b] =
[b]
-- using the syntactic sugar for single element in list
removeDuplTuples (x:xs) = nub (if elem (snd x,fst x) xs then
removeDuplTuples xs else [x] ++ removeDuplTuples xs)
                             --------
You forgot the parenthesis. Parse error in pattern usually means a type in
the input of one of your functions. Nub needs elements that can be equal.

Nub is quitte inefficient, if your elements can be ordered, there is a more
efficient version. It is something like:

fmap head.group.sort $ [1,1,1,1,4,4,5,6,6,7,8,9]
[1,4,5,6,7,8,9]

But I haven't test it thoroughly.

Greets,

Edgar

On Tue, Sep 28, 2010 at 11:33 AM, Martin Tomko <martin.to...@geo.uzh.ch>wrote:

> Hi all,
> I apologize for spamming this forum so frequently, but there is noone I can
> turn to around here...
> I have a list of (a,a) tuples, and am trying something like nub, but also
> matching for symmetrical tuples. I implemented it using the template from
> delete from Prelude. Seems like my typse signature has some troubles (Paarse
> error in pattern) but I am not sure where the problem is.
>
> removeDuplTuples :: [(a,a)] -> [(a,a)]
> removeDuplTuples [] = []
> removeDuplTuples [b] = [b]
>
>         -- using the syntactic sugar for single element in list
> removeDuplTuples x:xs = nub (if elem (snd x,fst x) xs then removeDuplTuples
> xs else [x] ++ removeDuplTuples xs)
>
> I assume the problem lies in elem (snd x,fst x) xs but I am not sure how to
> rewrite it.
>
> Thanks for all help,
> Martin
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20100928/f922db1b/attachment-0001.html

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

Message: 4
Date: Tue, 28 Sep 2010 11:45:24 +0200
From: edgar klerks <edgar.kle...@gmail.com>
Subject: Re: [Haskell-beginners] removing duplicate tuples (including
        symmetrical ones)
To: martin.to...@geo.uzh.ch
Cc: beginners@haskell.org
Message-ID:
        <aanlktimainxt94ac67rgb6coj=_lmqcf2ffyza4ep...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

>You forgot the parenthesis. Parse error in pattern usually means a type in
the input of one of your functions. Nub needs >elements that can be equal.

type has to be typo.
On Tue, Sep 28, 2010 at 11:44 AM, edgar klerks <edgar.kle...@gmail.com>wrote:

> Hi Martin,
>
> You have some typos:
>
> import Data.List
> removeDuplTuples :: (Eq a) => [(a,a)] -> [(a,a)]
>
> removeDuplTuples [] = []
> removeDuplTuples [b] =
> [b]
> -- using the syntactic sugar for single element in list
> removeDuplTuples (x:xs) = nub (if elem (snd x,fst x) xs then
> removeDuplTuples xs else [x] ++ removeDuplTuples xs)
>                              --------
> You forgot the parenthesis. Parse error in pattern usually means a type in
> the input of one of your functions. Nub needs elements that can be equal.
>
> Nub is quitte inefficient, if your elements can be ordered, there is a more
> efficient version. It is something like:
>
> fmap head.group.sort $ [1,1,1,1,4,4,5,6,6,7,8,9]
> [1,4,5,6,7,8,9]
>
> But I haven't test it thoroughly.
>
> Greets,
>
> Edgar
>
> On Tue, Sep 28, 2010 at 11:33 AM, Martin Tomko <martin.to...@geo.uzh.ch>wrote:
>
>> Hi all,
>> I apologize for spamming this forum so frequently, but there is noone I
>> can turn to around here...
>> I have a list of (a,a) tuples, and am trying something like nub, but also
>> matching for symmetrical tuples. I implemented it using the template from
>> delete from Prelude. Seems like my typse signature has some troubles (Paarse
>> error in pattern) but I am not sure where the problem is.
>>
>> removeDuplTuples :: [(a,a)] -> [(a,a)]
>> removeDuplTuples [] = []
>> removeDuplTuples [b] = [b]
>>
>>         -- using the syntactic sugar for single element in list
>> removeDuplTuples x:xs = nub (if elem (snd x,fst x) xs then
>> removeDuplTuples xs else [x] ++ removeDuplTuples xs)
>>
>> I assume the problem lies in elem (snd x,fst x) xs but I am not sure how
>> to rewrite it.
>>
>> Thanks for all help,
>> Martin
>> _______________________________________________
>> Beginners mailing list
>> Beginners@haskell.org
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20100928/d05576de/attachment-0001.html

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

Message: 5
Date: Tue, 28 Sep 2010 11:57:28 +0200
From: Martin Tomko <martin.to...@geo.uzh.ch>
Subject: Re: [Haskell-beginners] removing duplicate tuples (including
        symmetrical ones)
To: edgar klerks <edgar.kle...@gmail.com>
Cc: beginners@haskell.org
Message-ID: <4ca1bc08.2060...@geo.uzh.ch>
Content-Type: text/plain; charset="iso-8859-1"

Hi Edgar,
thanks for the help. I wanted to first test with nub, but I still cannot 
get it to work. I cannot see any missing parenthesis, but I retyped it 
this way to check:

removeDuplTuples :: (Eq a) =>[(a,a)] -> [(a,a)]
removeDuplTuples [] = []
removeDuplTuples [b] = [b]
removeDuplTuples x:xs = nub(if ((snd x,fst x) `elem` xs) then 
(removeDuplTuples xs) else ([x] ++ removeDuplTuples xs))

still the same error

What am I missing?
Martin

On 9/28/2010 11:45 AM, edgar klerks wrote:
> >You forgot the parenthesis. Parse error in pattern usually means a 
> type in the input of one of your functions. Nub needs >elements that 
> can be equal.
>
> type has to be typo.
> On Tue, Sep 28, 2010 at 11:44 AM, edgar klerks <edgar.kle...@gmail.com 
> <mailto:edgar.kle...@gmail.com>> wrote:
>
>     Hi Martin,
>
>     You have some typos:
>
>     import Data.List
>     removeDuplTuples :: (Eq a) => [(a,a)] -> [(a,a)]
>
>     removeDuplTuples [] = []
>     removeDuplTuples [b] =
>     [b]                                                                       
>                                                              
>     -- using the syntactic sugar for single element in list
>     removeDuplTuples (x:xs) = nub (if elem (snd x,fst x) xs then
>     removeDuplTuples xs else [x] ++ removeDuplTuples xs)
>                                  --------
>     You forgot the parenthesis. Parse error in pattern usually means a
>     type in the input of one of your functions. Nub needs elements
>     that can be equal.
>
>     Nub is quitte inefficient, if your elements can be ordered, there
>     is a more efficient version. It is something like:
>
>     fmap head.group.sort $ [1,1,1,1,4,4,5,6,6,7,8,9]
>     [1,4,5,6,7,8,9]
>
>     But I haven't test it thoroughly.
>
>     Greets,
>
>     Edgar
>
>     On Tue, Sep 28, 2010 at 11:33 AM, Martin Tomko
>     <martin.to...@geo.uzh.ch <mailto:martin.to...@geo.uzh.ch>> wrote:
>
>         Hi all,
>         I apologize for spamming this forum so frequently, but there
>         is noone I can turn to around here...
>         I have a list of (a,a) tuples, and am trying something like
>         nub, but also matching for symmetrical tuples. I implemented
>         it using the template from delete from Prelude. Seems like my
>         typse signature has some troubles (Paarse error in pattern)
>         but I am not sure where the problem is.
>
>         removeDuplTuples :: [(a,a)] -> [(a,a)]
>         removeDuplTuples [] = []
>         removeDuplTuples [b] = [b]                                    
>                                                                      
>                                           -- using the syntactic sugar
>         for single element in list
>         removeDuplTuples x:xs = nub (if elem (snd x,fst x) xs then
>         removeDuplTuples xs else [x] ++ removeDuplTuples xs)
>
>         I assume the problem lies in elem (snd x,fst x) xs but I am
>         not sure how to rewrite it.
>
>         Thanks for all help,
>         Martin
>         _______________________________________________
>         Beginners mailing list
>         Beginners@haskell.org <mailto:Beginners@haskell.org>
>         http://www.haskell.org/mailman/listinfo/beginners
>
>
>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20100928/8ad5640c/attachment.html

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

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 27, Issue 58
*****************************************

Reply via email to