Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/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. latest Haskell Platform build fails (F?bio Roberto Teodoro)
2. Re: Haskell equivalent to Clojure's partition fn
(Timothy Washington)
----------------------------------------------------------------------
Message: 1
Date: Tue, 4 Aug 2015 11:07:31 -0300
From: F?bio Roberto Teodoro <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] latest Haskell Platform build fails
Message-ID:
<canp42kpcsdzpsaek8sgyouw9egl66j4wc9xchbwve56lltg...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
---------- Mensagem encaminhada ----------
De: "F?bio Roberto Teodoro" <[email protected]>
Data: 04/08/2015 11:04
Assunto: latest Haskell Platform build fails
Para: <[email protected]>
One way I found to get rid of the "package(s) with this id already exist"
problem was by doing a "ghc-pkg --force unregister <package>"
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150804/2904af9c/attachment-0001.html>
------------------------------
Message: 2
Date: Tue, 4 Aug 2015 20:13:25 -0700
From: Timothy Washington <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Haskell equivalent to Clojure's
partition fn
Message-ID:
<CAADtM-YE41zyxPyQJL2RQ9yvSx-ht3=2qxkn7zjh3ch9vyr...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hey Jacek,
Thanks very much for this. I took a look around, and ended up using the
*chop* function from that package. So there looks to be a lot of goodies in
that package.
Cheers
Tim
On Sun, Jul 26, 2015 at 2:01 PM, Jacek Dudek <[email protected]> wrote:
> Hi Timothy,
>
> You might want to check out the split package.
> Here's the link: http://hackage.haskell.org/package/split
>
> On 7/25/15, Timothy Washington <[email protected]> wrote:
> > While I can say A), what I really need is B)
> >
> > *A)* > *take 5 $ chunksOf 10 [0..]*
> >
> [[0,1,2,3,4,5,6,7,8,9],[10,11,12,13,14,15,16,17,18,19],[20,21,22,23,24,25,26,27,28,29],[30,31,32,33,34,35,36,37,38,39],[40,41,42,43,44,45,46,47,48,49]]
> >
> > *B)* > take 5 $ someFn 10 1 [0..]
> >
> [[0,1,2,3,4,5,6,7,8,9],[1,2,3,4,5,6,7,8,9,10],[2,3,4,5,6,7,8,9,10,11],[3,4,5,6,7,8,9,10,11,12],[4,5,6,7,8,9,10,11,12,13]]
> >
> >
> > The music theory package indeed has a working partition function (source
> > here <http://rd.slavepianos.org/sw/hmt/Music/Theory/List.hs>). The
> > implementation simply *i)* takes `n` from the source list, *ii)* drops by
> > `m` then recurses.
> >
> > segments :: Int -> Int -> [a] -> [[a]]
> > segments n m p =
> > let q = take n p
> > p' = drop m p
> > in if length q /= n then [] else q : segments n m p'
> >
> >
> >
> > But that's rather manual. So I played around with this using *chop*, and
> > came up with the *divvy* function. It does exactly what I need.
> >
> > divvy :: Int -> Int -> [a] -> [[a]]
> > divvy n m lst =
> > chop (\xs -> (take n xs , drop m xs)) lst
> >
> >
> >> *take 5 $ partitionClojure 10 1 [0..]*
> >
> [[0,1,2,3,4,5,6,7,8,9],[1,2,3,4,5,6,7,8,9,10],[2,3,4,5,6,7,8,9,10,11],[3,4,5,6,7,8,9,10,11,12],[4,5,6,7,8,9,10,11,12,13]]
> >
> >
> > Thanks guys. This helped a lot :)
> >
> >
> > Tim
> >
> >
> > On Sat, Jul 25, 2015 at 10:56 AM, Dan Serban <[email protected]>
> wrote:
> >
> >> It looks like chunksOf will take you most of the way there. Here's my
> >> quick and dirty GHCi session output:
> >>
> >> ?> import Data.List.Split
> >> ?>
> >> ?> let clojurePartition n m = map (take n) $ chunksOf (n+m) [0..]
> >> ?>
> >> ?> take 3 $ clojurePartition 4 6
> >> [[0,1,2,3],[10,11,12,13],[20,21,22,23]]
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150804/feb8b511/attachment-0001.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 86, Issue 2
****************************************