# Longest run of a character in a string

Your challenge: Write a function that takes a string s, a character c, and finds the length of the longest run of c in s. The length of the run will be l.

Rules:

• If s is of length 0 or c is empty, l should be 0.
• If there are no instances of c in s, l should be 0.
• Standard loopholes and Standard I/O Rules apply.
• No matter where in s the run of cs is located, l should be the same.
• Any printable ASCII characters can appear in s and c.

Test cases:

s,c --> l
"Hello, World!",'l'  -->  2
"Foobar",'o'         -->  2
"abcdef",'e'         -->  1
"three   spaces",' ' -->  3
"xxx xxxx xx",'x'    -->  4
"xxxx xx xxx",'x'    -->  4
"",'a'               -->  0
"anything",''        -->  0


Winner:

As with the shortest answer in each language wins.

• – MD XF Jun 8 '17 at 18:01
• Could you include the edge cases of empty s and a c that isn't contained in a non-empty s in your test cases? – Martin Ender Jun 8 '17 at 18:22
• What range of characters can appear in s/c? – Martin Ender Jun 8 '17 at 18:23
• c can be empty? In many languages, a character is just an integer with special semantics, and you can't really have an empty integer either. – Martin Ender Jun 8 '17 at 18:40
• That doesn't really make sense to me. Your test cases suggest that we have to support it. If we don't have to support it, then specifying its required output doesn't make sense, because I can always just say that it's not supported if my solution would do something else in that case. – Martin Ender Jun 8 '17 at 18:45

#(apply max(reductions(fn[r c](if(= c %2)(inc r)0))0 %))