Reid Barton wrote:
I'm surprised everyone is giving clever recursive solutions rather than
concatMap (\n - replicateM n ['a'..'z']) [1..]
Regards,
Reid
Well, you've lost efficient sharing with respect to my previous solution
and one other.
But it's a fair call, so...
tail $ concat $
On Wed, 17 Jun 2009, Richard O'Keefe wrote:
On 17 Jun 2009, at 2:01 pm, Richard O'Keefe wrote:
On second thoughts,
let strings = : [pref++[last] | pref - strings, last - ['a'..'z']]
in tail strings
last:pref instead of pref++[last] should do more sharing.
You can also write it this way:
On Wed, 17 Jun 2009, Matthew Brecknell wrote:
Reid Barton wrote:
I'm surprised everyone is giving clever recursive solutions rather than
concatMap (\n - replicateM n ['a'..'z']) [1..]
Regards,
Reid
Well, you've lost efficient sharing with respect to my previous solution
and one other.
Hi guys,
I'd like to generate an infinite list, like
[a, b, c .. z, aa, ab, ac .. az, ba, bb, bc ..
bz, ca ...]
When I had set out to do this I thought, oh yeah no prob, in a heartbeat.
Uhm.
Help, pls!
Günther
PS: I know this should be a no-brainer, sry
One (rather ugly) option is:
tail . map (\y - showIntAtBase 26 (\x - chr (x + 96)) y ) $ [0..]
but I'm sure there's a prettier one out there :)
On Tue, Jun 16, 2009 at 8:28 PM, GüŸnther Schmidtgue.schm...@web.de wrote:
Hi guys,
I'd like to generate an infinite list, like
[a, b, c .. z, aa,
Here's a way using list comprehensions:
Prelude Data.List take 1000 $ concat.concat $ [ [ replicate n c | c
- ['a'..'z'] ] | n - [1..] ]
abcdefghijklmnopqrstuvwxyzaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvw
letterCombos = map (:[]) ['a'..'z'] ++ concatMap (\c - map ((c++) . (:
[])) ['a'..'z']) letterCombos
Not hugely efficient, if you generate the strings in reverse then you
can use (c:) rather than ((c++) . (:[])), but that may not be useful
to you.
Bob
On 17 Jun 2009, at 02:28, Günther
this appears to work:
alphabet=map (\x-x:[]) ['a'..'z']
series=alphabet++[x++y|x-series,y-alphabet]
On Tue, Jun 16, 2009 at 8:28 PM, GüŸnther Schmidt gue.schm...@web.dewrote:
Hi guys,
I'd like to generate an infinite list, like
[a, b, c .. z, aa, ab, ac .. az, ba, bb, bc .. bz,
ca ...]
On 17 Jun 2009, at 12:28 pm, Günther Schmidt wrote:
Hi guys,
I'd like to generate an infinite list, like
[a, b, c .. z, aa, ab, ac .. az, ba, bb, bc ..
bz, ca ...]
When I had set out to do this I thought, oh yeah no prob, in a
heartbeat.
Let me change this slightly.
My solution attempted to exploit this using Numeric.showIntAtBase but
failed because of the lack of 0 prefixes in the numbers. If you can
find a simple way to fix it without duplicating the showIntAtBase
code, I'd be interested!
On Tue, Jun 16, 2009 at 10:01 PM, Richard O'Keefeo...@cs.otago.ac.nz
Thomas Davie wrote:
letterCombos = map (:[]) ['a'..'z'] ++ concatMap (\c - map ((c++) . (:
[])) ['a'..'z']) letterCombos
Not hugely efficient, if you generate the strings in reverse then you
can use (c:) rather than ((c++) . (:[])), but that may not be useful
to you.
Bob
I think
On 17 Jun 2009, at 2:01 pm, Richard O'Keefe wrote:
On second thoughts,
let strings = : [pref++[last] | pref - strings, last -
['a'..'z']]
in tail strings
seems more Haskellish than the stupidly clever counting-based
code I had in mind. With this it's much easier to see what it's up
At 4:25 PM +1200 6/17/09, Richard O'Keefe wrote:
On 17 Jun 2009, at 2:01 pm, Richard O'Keefe wrote:
On second thoughts,
let strings = : [pref++[last] | pref - strings, last - ['a'..'z']]
in tail strings
seems more Haskellish than the stupidly clever counting-based
code I had in mind.
On Wed, Jun 17, 2009 at 02:28:55AM +0200, Gü?nther Schmidt wrote:
Hi guys,
I'd like to generate an infinite list, like
[a, b, c .. z, aa, ab, ac .. az, ba, bb, bc ..
bz, ca ...]
I'm surprised everyone is giving clever recursive solutions rather than
concatMap (\n - replicateM n
On Wed, 17 Jun 2009 00:45:56 -0400, you wrote:
And here's a version along similar lines that avoids (++) for greater
sharing and efficiency:
let sss = [] : [ [ c:s | c - ['a'..'z'], s - ss ] | ss - sss ]
in concat (tail sss)
Sheer genius!
I just inverted it since I like to see the main
15 matches
Mail list logo