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 Bioinformatics.DNANucleotide as D | |
| main = do | |
| substrand <- getLine | |
| putStrLn . concat . map show . reverse . map D.nucleotideComplement $ map D.charToDNANucleotide substrand |
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 startSplits = split(testText, { $0 == "<" }) | |
| let strippedValues = map(startSplits) { (s) -> String? in | |
| if let endIndex = find(s, ">") { | |
| return s[Range<String.Index>(start: endIndex.successor(), end: s.endIndex)] | |
| } | |
| return nil | |
| } | |
| let strings = strippedValues.filter({ $0 != nil }).filter({ $0 != "" }).map({ $0! }) |
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 testText = "<a href=\"#\">Something</a>" | |
| if let firstEndIndex = find(testText, ">") { | |
| let testText2 = testText[Range<String.Index>(start: firstEndIndex.successor(), end: testText.endIndex)] | |
| if let secondStartIndex = find(testText2, "<") { | |
| let testText3 = testText2[Range<String.Index>(start: testText2.startIndex, end: secondStartIndex)] | |
| } | |
| } |
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
| func find<S : Sliceable>(domain: S, isValue: (S.Generator.Element) -> Bool) -> S.Index? { | |
| return find(domain, domain.startIndex, isValue) | |
| } | |
| func find<S : Sliceable>(domain: S, startingIndex: S.Index, isValue: (S.Generator.Element) -> Bool) -> S.Index? { | |
| if startingIndex == domain.endIndex { | |
| return nil | |
| } | |
| if isValue(domain[startingIndex]) { | |
| return startingIndex | |
| } |
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
| module Bioinformatics.DNANucleotide ( | |
| DNANucleotide (..), | |
| charToDNANucleotide | |
| ) where | |
| import Data.Char | |
| import Data.List | |
| data DNANucleotide = A | C | G | T deriving(Show, Eq, Ord, Read) |
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
| rnaConverter = foldr (\x acc -> if x == 'T' then 'U':acc else x:acc) [] |
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
| doMathFunction :: (Int -> Int -> Int) -> Int -> Int -> Int | |
| doMathFunction func x1 x2 = func x1 x2 | |
| -- doMathFunction (+) 1 2 ==> 3 | |
| -- doMathFunction (*) 4 3 ==> 12 | |
| -- doMathFunction (-) 4 3 ==> 1 |
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
| addFunction :: Int -> Int -> Int | |
| addFunction x1 x2 = x1 + x2 | |
| -- addFunction 1 2 ==> 3 | |
| let add10 = addFunction 10 | |
| -- :t add10 | |
| -- add10 :: Int -> Int | |
| -- add10 5 ==> 15 | |
| -- add10 100 ==> 110 |
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
| data AssignmentGrade = AssignmentGrade { score :: Int, grade :: Char } deriving(Show, Read, Eq) | |
| instance Ord AssignmentGrade where | |
| compare ag1 ag2 = compare (score ag1) (score ag2) |
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.Char | |
| import Data.List | |
| data DNANucleotide = A | C | G | T deriving(Show, Eq, Ord, Read) | |
| charToDNANucleotide :: Char -> DNANucleotide | |
| charToDNANucleotide c = read [toUpper c] :: DNANucleotide | |
| mainCountDNANucleotides = do | |
| dna <- getLine |