[Haskell-cafe] Re: split string into n parts

2006-10-24 Thread Jón Fairbairn
I wrote: jim burton [EMAIL PROTECTED] wrote: Thankyou! It's http://www.rubyquiz.com - They are mostly well suited to haskell, lot of mazes etc. I've done 5 or 6 with varying degrees of success but have learned a lot. This thing about strings in fifths is from #1, the solitaire cipher.

Re: [Haskell-cafe] Re: split string into n parts

2006-10-24 Thread Stefan Holdermans
Gah! Brain AWOL. I'm surprised no-one picked me up on that. Why didn't I use: splitAtMb n [] = Nothing splitAtMb n l = Just $ splitAt n l Actually, I've some code lying around doing exactly this (but without the padding ;)), written with the coalgebra inlined: split n = unfoldr $ \xs -

[Haskell-cafe] Re: split string into n parts

2006-10-23 Thread Jón Fairbairn
jim burton [EMAIL PROTECTED] writes: Paul Brown-4 wrote: Cool idea! Can you post a link for the puzzles? Thankyou! It's http://www.rubyquiz.com - They are mostly well suited to haskell, lot of mazes etc. I've done 5 or 6 with varying degrees of success but have learned a lot. This

[Haskell-cafe] Re: split string into n parts

2006-10-23 Thread Jón Fairbairn
jim burton [EMAIL PROTECTED] writes: tweak to in_fives in_fives l = unfoldr (splitAtMb 5) (l ++ replicate (5 - length l `mod` 5) 'X') Whoops! Yes. And a slapped wrist for me for writing a constant three times. Serves me right for not writing groups_of n l = unfolder