text
stringlengths
1
330k
Which will take the longest amount of repeated characters from a string and one will limit this to 9, e.g. if given the string "aaaaabbbcc" , the answer would be "aaaaa"
I need to define a function, runs, which will do a similiar thing but it will put the string into separate lists, e.g. if the given string is "aaaaabbbccc" , the answer would be ["aaaaa","bbb","cc"], and I need to use the munch function to do this.
The condition of 9 characters applies too, so if the given string is "aaaaaaaaaa" , the answer would be ["aaaaaaaaa","a"]
I've not actually got any implementation apart from something that I found which does pretty much does the same thing without the limit of 9 characters:
runs :: String -> String
runs x = group x
I thought of 2 ways of doing this, but I have no clue on the actual implementation, with one being to run the munch function for however many unique characters there are, i.e if there is an x amount of a , b , c in the given string, it would run 3 times, and then put those lists together into one list.
Another way that I thought of is to use guards. If the number of any single character in the given string is 9 or less, then just use the group function, otherwise, shorten it down using munch, or something like that.
Is anyone able to tell me if the two ideas I mentioned would work at all or suggest an alternative and how to get started? I'm a bit lost.
Tags : string haskell
Answers 2
A quick google gives you exactly what you're looking for.
If it works consider upvoting their answer as I only copied a link
March 14, 2019 20:19 PM
here is another approach
define a split function to break arrays at fixed size chunks
splitn :: Int -> [a] -> [[a]]
splitn _ [] = []
splitn n x = take n x : (splitn n $ drop n x)
now you can write your function as
runs = concatMap (splitn 9) . group
March 14, 2019 20:25 PM
Related Questions
Remove a Character Sequence From a String
Updated December 24, 2016 07:41 AM
how to construct a Map Text Text object?
Updated February 24, 2017 17:26 PM
Haskell: checking the vowels in a String
Updated September 22, 2017 12:26 PM
How do I search for some text in Haskell?
Updated January 11, 2018 00:26 AM
Put the mirror on the correct position, so that the reflected ray hits one of the blue fields. The faster you are the more points you get. You need a score of 77 points to solve the game.
You can only use the mouse for this game.
When your hit does not fit you have to wait a little bit.
Courier IMAP Setup
Courier IMAP
This is a pop3 and imap daemon. The official website is at
Userdb authentication setup
I'm using userdb for authentication. There are other schemes you can use such as PAM, MySQL or Postgres.
userdb is a disk based authentication, similar to standard passwd files.
Initial Setup
1. postfix setup with vmailbox must be setup first.
2. Install packages
Install courier-authlib-userdb, courier-imap-ssl, courier-pop-ssl
3. mkdirs
# mkdir /etc/courier
# touch /etc/courier/userdb
# chmod 600 /etc/courier/userdb
4. Turn on the userdb authentication scheme. Edit /etc/courier/authdaemonrc
set authmodulelist="authuserdb"
5. Decide which daemons or services you will start.
Setup per email
1. Determine uid and gid of vmail
This will be the vmail user setup as part of postfix initial setup
# id vmail
uid=1002(vmail) gid=1002(vmail) groups=1002(vmail)
In the above example, the id is 1002.
2. Add to userdb
# userdb "" set home=/var/mail/vhosts/ \
mail=/var/mail/vhosts/ uid=1234 gid=1234
After this command you should see a new entry in /etc/courier/userdb
The mail parameter is used so it is not defaulted to $home/Maildir/
3. set password
# userdbpw | userdb "" set systempw
it will prompt you for a password.
4. rebuild userdb
# makeuserdb
/etc/courier/userdb.dat will be updated
5. reload services
# service courier-authdaemon restart
* Stopping Courier authentication services authdaemond
* Starting Courier authentication services authdaemond
6. Notify the user their account is ready. Note that their username is their FULL email address.
Published: Saturday, 26 February 2011
Updated: Tuesday, 3 December 2013
Blitz-Inform General Why is smoking a stress-relieving therapy for people
Why is smoking a stress-relieving therapy for people
We all might have to encounter casual bouts of stress at one or another point in our life; however, when one has to suffer from the severe and intense condition of chronic stress every so often then, it is certainly an alarming situation and a call to action for the individuals. However, for the purpose of getting rid ...
However, we need to understand that smoking on a regular basis can cause adverse impacts on our physical and mental health; however, smoking casually or every once in a while just for the sake of having fun is not that harmful to the individuals. Therefore, it is extremely necessary for us to understand the positive as...
There are multiple tips and techniques of reducing stress and anxiety in people but the fact is that nothing is more effective than smoking in reducing the level of stress and strain in our mind. However, smoking is considered as the best therapy for relieving stress in a specified amount of time because it contributes...
Inhibits the production of stress-inducing hormones:
You might have noticed that people who are suffering from stress and depression are more likely to get involved in smoking and other tobacco or nicotine consuming activities. It does not only sooth and calms their mind but also releases “happy hormones” that are effective in making the person happy and relax for a cert...
A Romantic Vision of Mathematics, with Ed Frenkel
Math is not the opposite of art and poetry. In fact, every formula is a formula of love.
Edward Frenkel: So how do we communicate the beauty and power of mathematics?  A few years ago I made a film called Rites of Love and Math with a wonderful French film director, Reine Graves.  I was in Paris doing some mathematical work and suddenly I felt inspired to make a film because I find that sometimes, you know...
So then I thought what if we do something radically different.  What if instead of trying to explain a formula at kind of a rigorous and cerebral level -- what if we tried to do it at the more visceral and emotional, intuitive level.  So instead of trying to explain the details, what if we make a tattoo of a mathematic...
The premise of the film is that the mathematician, after many years of hard work, finds a formula of love.  And at first he is elated -- he's so happy that he found this formula which explains everything and will make everyone happy.  And then, of course, he realizes the flip side of the formula.  It could be used for ...
So we create this mythical world and in this mythical world she -- his lover -- represents mathematics itself.  So the film is really about his love affair with mathematics.  And that's what we tried to convey.  And we tried to show the formula in a different light and we tried to show the passion which is involved in ...
Which when he makes the tattoo he completely shuts himself out from the rest of the world.  It's just him and the formula and nothing else.  That's how we do mathematical research.  It's really a struggle of ideas and struggle with oneself trying to understand things at the deeper level.  It's a very emotional and pass...
So when we show the film, someone always asks, "What does this formula mean?"  And that's exactly what we wanted.  We wanted to peak a viewer's curiosity, to inspire them to ask the question what is the meaning of the formula.  In other words, we wanted the viewer to appreciate the beauty of the formula just in an aest...
And the second question that people like to ask is, "Is there a formula of love?  Does a formula of love really exist?"  And the answer I like to give is that actually every formula we discover is a formula of love.  And that's because these formulas, it represents something deep and fundamental about the world.  And p...
Directed / Produced by Jonathan Fowler and Dillon Fitton
Google Maps apologizes for going rogue in Japan
Strange Maps
Keep reading Show less
This is the best (and simplest) world map of religions
(c) CLO / Carrie Osgood
Strange Maps
• See how religions mix at both national and regional level.
Keep reading Show less