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: a problem with maps (Dennis Raddle)
2. Re: a problem with maps (Ertugrul Soeylemez)
3. Repeat function application x times? (Christopher Howard)
4. Re: Repeat function application x times? (Magnus Therning)
5. Re: Repeat function application x times? (Ertugrul Soeylemez)
6. Re: Repeat function application x times? (Felipe Almeida Lessa)
----------------------------------------------------------------------
Message: 1
Date: Fri, 22 Jul 2011 20:38:25 -0700
From: Dennis Raddle <[email protected]>
Subject: Re: [Haskell-beginners] a problem with maps
To: [email protected]
Message-ID:
<CAKxLvop7=l5euy4dd-jfa7vvr45vmy7nsa8vyzytre79hvy...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Another problem is have is to filter entries in a map. If I have a map
Ord k => Map k [a]
(essentially, which combines data with the same key into a list)
and I have a predicte (k,a) -> Bool
(which takes the key and one element in its list and checks it)
and I need to regenerate the map, what would be a good way to do that?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110722/5e074878/attachment-0001.htm>
------------------------------
Message: 2
Date: Sat, 23 Jul 2011 05:51:56 +0200
From: Ertugrul Soeylemez <[email protected]>
Subject: Re: [Haskell-beginners] a problem with maps
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII
Dennis Raddle <[email protected]> wrote:
> Another problem is have is to filter entries in a map. If I have a map
>
> Ord k => Map k [a]
>
> (essentially, which combines data with the same key into a list)
>
> and I have a predicte (k,a) -> Bool
>
> (which takes the key and one element in its list and checks it)
>
> and I need to regenerate the map, what would be a good way to do that?
See the foldWithKey function in Data.Map.
Greets,
Ertugrul
--
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/
------------------------------
Message: 3
Date: Fri, 22 Jul 2011 22:11:39 -0800
From: Christopher Howard <[email protected]>
Subject: [Haskell-beginners] Repeat function application x times?
To: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Is there a convenient stock function in prelude/base that applies a
function to a single value x number of times and returns the result?
(I.e., does not return a list, but the final value.) Something like
applyN :: Integral b => (a -> a) -> b -> a -> a
Honestly I looked through the base hierarchy and at hoogle but I am
missing it.
--
frigidcode.com
theologia.indicium.us
------------------------------
Message: 4
Date: Sat, 23 Jul 2011 08:26:05 +0200
From: Magnus Therning <[email protected]>
Subject: Re: [Haskell-beginners] Repeat function application x times?
To: [email protected]
Message-ID: <20110723062605.GA4386@ohann>
Content-Type: text/plain; charset="us-ascii"
On Fri, Jul 22, 2011 at 10:11:39PM -0800, Christopher Howard wrote:
> Is there a convenient stock function in prelude/base that applies a
> function to a single value x number of times and returns the result?
> (I.e., does not return a list, but the final value.) Something like
>
> applyN :: Integral b => (a -> a) -> b -> a -> a
>
> Honestly I looked through the base hierarchy and at hoogle but I am
> missing it.
I'm not sure there is one, but it's rather simple to build one out of
`iterate` and `!!`.
/M
--
Magnus Therning OpenPGP: 0xAB4DFBA4
email: [email protected] jabber: [email protected]
twitter: magthe http://therning.org/magnus
Most software today is very much like an Egyptian pyramid with
millions of bricks piled on top of each other, with no structural
integrity, but just done by brute force and thousands of slaves.
-- Alan Kay
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110723/c5dec657/attachment-0001.pgp>
------------------------------
Message: 5
Date: Sat, 23 Jul 2011 08:26:33 +0200
From: Ertugrul Soeylemez <[email protected]>
Subject: Re: [Haskell-beginners] Repeat function application x times?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII
Christopher Howard <[email protected]> wrote:
> Is there a convenient stock function in prelude/base that applies a
> function to a single value x number of times and returns the result?
> (I.e., does not return a list, but the final value.) Something like
>
> applyN :: Integral b => (a -> a) -> b -> a -> a
>
> Honestly I looked through the base hierarchy and at hoogle but I am
> missing it.
No, but it's easy to define:
applyN :: Int -> (a -> a) -> a -> a
applyN n = foldl (.) id . replicate n
Greets,
Ertugrul
--
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/
------------------------------
Message: 6
Date: Sat, 23 Jul 2011 03:28:42 -0300
From: Felipe Almeida Lessa <[email protected]>
Subject: Re: [Haskell-beginners] Repeat function application x times?
To: Christopher Howard <[email protected]>
Cc: Haskell Beginners <[email protected]>
Message-ID:
<CANd=OGGxRveasjEoQSf=7d1f+iflgz1sh_wva0vzkqd9kcp...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
It's straightforward to define it using iterate:
applyN :: (a -> a) -> Int -> a -> a
applyN f n x = iterate f x !! n
Cheers,
--
Felipe.
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 37, Issue 50
*****************************************