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. Re: Updating lists inside another list (Lee Duhem)
2. Re: decorate-sort-undecorate in haskell
(Brandon S. Allbery KF8NH)
3. Re: decorate-sort-undecorate in haskell (Henk-Jan van Tuyl)
4. Re: decorate-sort-undecorate in haskell (Daniel Fischer)
5. Re: decorate-sort-undecorate in haskell (Ivan Uemlianin)
6. HXT: Gathering text from Nodes (aditya siram)
7. [SOLVED]Re: HXT: Gathering text from Nodes (aditya siram)
8. lhs2TeX (Thomas Friedrich)
9. Re: decorate-sort-undecorate in haskell
(Brandon S. Allbery KF8NH)
----------------------------------------------------------------------
Message: 1
Date: Tue, 23 Jun 2009 15:19:50 +0800
From: Lee Duhem <[email protected]>
Subject: Re: [Haskell-beginners] Updating lists inside another list
To: Joel Neely <[email protected]>
Cc: beginners <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=UTF-8
On Tue, Jun 23, 2009 at 11:29 AM, Joel Neely<[email protected]> wrote:
> WRT the first case, I would have expected something like;
>
> addToInnerList [] a b = [(a,[b])]
>
> on the assumption that one "grows" a structure from an empty state.
> Your thoughts?
>
I think it isn't what Aaron wants, that is "to add an element to the
inner list of
the pair with the head value of my choosing".
Anyway, it is an option.
lee
------------------------------
Message: 2
Date: Tue, 23 Jun 2009 08:58:11 -0400
From: "Brandon S. Allbery KF8NH" <[email protected]>
Subject: Re: [Haskell-beginners] decorate-sort-undecorate in haskell
To: Ivan Uemlianin <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"
On Jun 22, 2009, at 06:03 , Ivan Uemlianin wrote:
> I'm learning Haskell from a background in Python, and I'm just
> looking at the sort and sortBy functions in Data.List. In Python,
> the decorate-sort-undecorate pattern is a popular alternative to
> using an explicit compare function. For example, to sort a list of
> lists by
It's fairly common, considering that decorate-sort-undecorate is a
functional programming idiom dating back to Lisp. In Haskell it's
usually expressed with the decoration in a tuple such that the default
sort can be used.
> map snd . sort . map (\x -> (x,decorate x))
Fancier versions use arrows to make the decorate part cleaner:
> map snd . sort . map (decorate &&& id)
--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [email protected]
system administrator [openafs,heimdal,too many hats] [email protected]
electrical and computer engineering, carnegie mellon university KF8NH
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url :
http://www.haskell.org/pipermail/beginners/attachments/20090623/d0874055/PGP-0001.bin
------------------------------
Message: 3
Date: Tue, 23 Jun 2009 15:42:59 +0200
From: "Henk-Jan van Tuyl" <[email protected]>
Subject: Re: [Haskell-beginners] decorate-sort-undecorate in haskell
To: "Brandon S. Allbery KF8NH" <[email protected]>, "Ivan Uemlianin"
<[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; format=flowed; delsp=yes;
charset=iso-8859-15
On Tue, 23 Jun 2009 14:58:11 +0200, Brandon S. Allbery KF8NH
<[email protected]> wrote:
> On Jun 22, 2009, at 06:03 , Ivan Uemlianin wrote:
>> I'm learning Haskell from a background in Python, and I'm just
>> looking at the sort and sortBy functions in Data.List. In Python,
>> the decorate-sort-undecorate pattern is a popular alternative to
>> using an explicit compare function. For example, to sort a list of
>> lists by
>
> It's fairly common, considering that decorate-sort-undecorate is a
> functional programming idiom dating back to Lisp. In Haskell it's
> usually expressed with the decoration in a tuple such that the default
> sort can be used.
>
> > map snd . sort . map (\x -> (x,decorate x))
>
> Fancier versions use arrows to make the decorate part cleaner:
>
> > map snd . sort . map (decorate &&& id)
>
The simplest form for e.g. sorting by length is:
> sortByLength = sortBy (comparing length)
--
Met vriendelijke groet,
Henk-Jan van Tuyl
--
http://functor.bamikanarie.com
http://Van.Tuyl.eu/
--
------------------------------
Message: 4
Date: Tue, 23 Jun 2009 16:13:04 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] decorate-sort-undecorate in haskell
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-15"
Am Dienstag 23 Juni 2009 15:42:59 schrieb Henk-Jan van Tuyl:
> On Tue, 23 Jun 2009 14:58:11 +0200, Brandon S. Allbery KF8NH
>
> <[email protected]> wrote:
> > On Jun 22, 2009, at 06:03 , Ivan Uemlianin wrote:
> >> I'm learning Haskell from a background in Python, and I'm just
> >> looking at the sort and sortBy functions in Data.List. In Python,
> >> the decorate-sort-undecorate pattern is a popular alternative to
> >> using an explicit compare function. For example, to sort a list of
> >> lists by
> >
> > It's fairly common, considering that decorate-sort-undecorate is a
> > functional programming idiom dating back to Lisp. In Haskell it's
> > usually expressed with the decoration in a tuple such that the default
> > sort can be used.
> >
> > > map snd . sort . map (\x -> (x,decorate x))
Typo:
map snd . sort . map (\x -> (decorate x,x))
> >
> > Fancier versions use arrows to make the decorate part cleaner:
> > > map snd . sort . map (decorate &&& id)
>
> The simplest form for e.g. sorting by length is:
> > sortByLength = sortBy (comparing length)
But that is an example where the decoration really shines, except all lists are
very
short:
Prelude> :set +s
Prelude> let lens :: [Int]; lens = [(k^2+3*k-2) `mod` 5431 | k <- [1 .. 500]]
(0.04 secs, 6184112 bytes)
Prelude> let lists = map (flip replicate ()) lens
(0.00 secs, 609084 bytes)
Prelude> :m +Data.List
Prelude Data.List> :m +Data.Ord
Prelude Data.List Data.Ord> let srtl1 = sortBy (comparing length) lists
(0.00 secs, 0 bytes)
Prelude Data.List Data.Ord> let srtl2 = map snd . sortBy (comparing fst) $ map
(\l ->
(length l, l)) lists
(0.02 secs, 5975640 bytes)
Prelude Data.List Data.Ord> length (srtl2 !! 420)
4471
(0.19 secs, 37089168 bytes)
Prelude Data.List Data.Ord> length (srtl1 !! 420)
4471
(1.09 secs, 542788 bytes)
simpler is not always better.
------------------------------
Message: 5
Date: Tue, 23 Jun 2009 15:20:34 +0100
From: Ivan Uemlianin <[email protected]>
Subject: Re: [Haskell-beginners] decorate-sort-undecorate in haskell
To: Daniel Fischer <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Daniel Fischer wrote:
> Prelude> :set +s
> Prelude> let lens :: [Int]; lens = [(k^2+3*k-2) `mod` 5431 | k <- [1 .. 500]]
> (0.04 secs, 6184112 bytes)
> Prelude> let lists = map (flip replicate ()) lens
> (0.00 secs, 609084 bytes)
> Prelude> :m +Data.List
> Prelude Data.List> :m +Data.Ord
> Prelude Data.List Data.Ord> let srtl1 = sortBy (comparing length) lists
> (0.00 secs, 0 bytes)
> Prelude Data.List Data.Ord> let srtl2 = map snd . sortBy (comparing fst) $
> map (\l ->
> (length l, l)) lists
> (0.02 secs, 5975640 bytes)
> Prelude Data.List Data.Ord> length (srtl2 !! 420)
> 4471
> (0.19 secs, 37089168 bytes)
> Prelude Data.List Data.Ord> length (srtl1 !! 420)
> 4471
> (1.09 secs, 542788 bytes)
>
Profiling too! Excellent. So this shows that with these long lists of
lists, the dsu version was about ten times faster.
I'll report back once I've written up.
Thanks to everyone for your comments.
Ivan
--
============================================================
Ivan A. Uemlianin
Speech Technology Research and Development
[email protected]
www.llaisdy.com
llaisdy.wordpress.com
www.linkedin.com/in/ivanuemlianin
"Froh, froh! Wie seine Sonnen, seine Sonnen fliegen"
(Schiller, Beethoven)
============================================================
------------------------------
Message: 6
Date: Tue, 23 Jun 2009 14:20:11 -0500
From: aditya siram <[email protected]>
Subject: [Haskell-beginners] HXT: Gathering text from Nodes
To: beginners <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Hi all,
I'm having trouble using HXT to gather up text from all nodes with a certain
name, and return it in a tuple with another node.
So given 3 child nodes called "kid" containing "a", "b" and "c", and 1 child
node called "name" containing "A", I want to return ("A", ["a","b","c"]). My
current code at
http://hpaste.org/fastcgi/hpaste.fcgi/view?id=6187#a6187returns
[("A","a")("B","b")("C","c")].
Any help is appreciated.
-deech
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20090623/e0e25e14/attachment-0001.html
------------------------------
Message: 7
Date: Tue, 23 Jun 2009 14:51:30 -0500
From: aditya siram <[email protected]>
Subject: [Haskell-beginners] [SOLVED]Re: HXT: Gathering text from
Nodes
To: beginners <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
The trick was using listA to gather up the results of the computation.
Working code is at http://hpaste.org/fastcgi/hpaste.fcgi/view?id=6187#a6188.
-deech
On Tue, Jun 23, 2009 at 2:20 PM, aditya siram <[email protected]>wrote:
> Hi all,
> I'm having trouble using HXT to gather up text from all nodes with a
> certain name, and return it in a tuple with another node.
>
> So given 3 child nodes called "kid" containing "a", "b" and "c", and 1
> child node called "name" containing "A", I want to return ("A",
> ["a","b","c"]). My current code at
> http://hpaste.org/fastcgi/hpaste.fcgi/view?id=6187#a6187 returns
> [("A","a")("B","b")("C","c")].
>
> Any help is appreciated.
> -deech
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20090623/ac29bbf8/attachment-0001.html
------------------------------
Message: 8
Date: Tue, 23 Jun 2009 18:52:00 -0400
From: Thomas Friedrich <[email protected]>
Subject: [Haskell-beginners] lhs2TeX
To: beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Hi everyone,
A Google-search wasn't successful, that's why I am asking here. I want
to use the program lhs2TeX. In the manual it says there are different
styles that you can use, and some examples how they look like. But they
never say how to call them. If I like to see the verbatim-style or the
tt-style. What do I include in my document?
Cheers,
Thomas
------------------------------
Message: 9
Date: Tue, 23 Jun 2009 22:03:31 -0400
From: "Brandon S. Allbery KF8NH" <[email protected]>
Subject: Re: [Haskell-beginners] decorate-sort-undecorate in haskell
To: Daniel Fischer <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"
On Jun 23, 2009, at 10:13 , Daniel Fischer wrote:
> Typo:
> map snd . sort . map (\x -> (decorate x,x))
Yeh, as usual I realized that about 5 minutes after I sent the
message. :/
--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [email protected]
system administrator [openafs,heimdal,too many hats] [email protected]
electrical and computer engineering, carnegie mellon university KF8NH
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url :
http://www.haskell.org/pipermail/beginners/attachments/20090623/b263ff83/PGP.bin
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 12, Issue 11
*****************************************