version_is detects whether the current dir POM (or the whole Git project POM files) match the specified version.
This can be useful as a sanity check after a merge (where POM versions could have silently changed to a non-desired value).
| def balance(chars: List[Char]): Boolean = { | |
| val result:(Boolean, Int) = chars.foldLeft((true, 0))((tuple:(Boolean, Int), char:Char) => { | |
| val count = balanceCount(tuple._2, char) | |
| (tuple._1 && count >= 0, count) | |
| }) | |
| result._1 && result._2 == 0 | |
| } | |
| private def balanceCount(previousCount: Int, char: Char) : Int = { | |
| char match { |
| foobarqix n = take n [ _substitute x | x <- [1..] ] | |
| _substitute value = __substitute value "" [(3,"Foo"),(5,"Bar"),(7,"Qix")] | |
| __substitute value "" [] = show value | |
| __substitute value replacement [] = replacement | |
| __substitute value replacement multiples = | |
| let multiple = fst (head multiples) | |
| string = snd (head multiples) | |
| rest = tail multiples in |
| foldl (+) 0 (filter (\n -> n `mod` 3 == 0 || n `mod` 5 == 0) [1..999]) |
| fibonacci :: (Ord a, Num a) => a -> [a] | |
| fibonacci limit = _fibonacci limit [1,2] | |
| _fibonacci :: (Ord a, Num a) => a -> [a] -> [a] | |
| _fibonacci limit x | |
| | sum < limit = _fibonacci limit (x++[sum]) | |
| | otherwise = x | |
| where x1x2 = drop ((length x)-2) x | |
| sum = ((head x1x2)+(last x1x2)) |
| import Data.Maybe | |
| import Data.List | |
| primeFactors :: Int -> [Int] | |
| primeFactors = (filter prime) . divisors | |
| prime :: Int -> Bool | |
| prime a = | |
| let upper = floor (sqrt (fromIntegral a)) + 1 in | |
| (a `mod` 2 /= 0) && isNothing (find (isMultiple a) [3,5..upper]) |
| 20 * (1+length (takeWhile (/= True) (map (foldl (&&) True) (map (\n -> (map (\m -> n `mod` m == 0) [1..20])) [20,40..])))) |
| let range = [1..100] in (foldl (+) 0 range)^2 - (foldl (+) 0 (map (^2) range)) |
| primes :: Int -> Int | |
| primes index = last (_primes 0 (index-1) [2] [3,5..]) | |
| _primes :: Int -> Int -> [Int] -> [Int] -> [Int] | |
| _primes cur max p x | |
| | cur >= max = p | |
| | otherwise = | |
| let x0 = head x in | |
| _primes (cur+1) max (p++[x0]) (filter (\n -> n `mod` x0 /= 0) (tail x)) |
| import Data.Char | |
| largestProduct :: Int -> String -> (Int, [Int]) | |
| largestProduct size n = | |
| let digits = map digitToInt n in | |
| findSubsequence size (0, [0]) digits | |
| findSubsequence :: Int -> (Int,[Int]) -> [Int] -> (Int, [Int]) | |
| findSubsequence size prev seq | |
| | length seq < size = prev |