This GraphGist represents a mobile application backend helping users to find adequate drugs and specialists given their physical characteristics, location and current symptoms.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (fn mysteryFunction [s] | |
| ((fn append [mySeq acc] | |
| (let [beginning (butlast mySeq)] | |
| (if (= beginning nil) | |
| (conj acc (first mySeq)) | |
| (append beginning (conj acc (last mySeq))) | |
| ) | |
| ) | |
| ) s []) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| foldl (+) 0 (filter (\n -> n `mod` 3 == 0 || n `mod` 5 == 0) [1..999]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 20 * (1+length (takeWhile (/= True) (map (foldl (&&) True) (map (\n -> (map (\m -> n `mod` m == 0) [1..20])) [20,40..])))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let range = [1..100] in (foldl (+) 0 range)^2 - (foldl (+) 0 (map (^2) range)) |