Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \begin{code}
- import qualified Data.Char as Char
- data Tree = L | T(Int, Tree, Tree)
- getAllKeys [] = []
- getAllKeys ((x, n):xs)= x:(getAllKeys xs)
- biggestValue [] val = val
- biggestValue ((x, n):xs) val = if(val < n) then (biggestValue xs n)
- else (biggestValue xs val)
- getMaxValueKey ((x, n):xs) = (getMaxValueKeyCompute ((x, n):xs) (biggestValue ((x, n):xs) 0))
- getMaxValueKeyCompute ((x, n):xs) val = if(val == n) then x
- else (getMaxValueKeyCompute xs val)
- firstWord (x:xs) = (firstWordCompute (x:xs) 0)
- firstWordCompute (x:xs) flag = if(flag == 0 && x == ' ') then (firstWordCompute xs 0)
- else if(flag == 0 && x /= ' ') then x:(firstWordCompute xs 1)
- else if(flag == 1 && x /= ' ') then x:(firstWordCompute xs 1)
- else []
- firstWordCompute [] 1 = []
- firstWordCompute [] 0 = []
- formatSentence (x:xs) = (formatSentenceCompute (x:xs) 0)
- formatSentenceCompute (x:xs) flag = if(flag == 0 && x == ' ') then (formatSentenceCompute xs 0)
- else if(flag == 0 && x /= ' ') then x:(formatSentenceCompute xs 1)
- else if(flag == 1 && x == ' ') then x:(formatSentenceCompute xs 2)
- else if(flag == 1 && x /= ' ') then x:(formatSentenceCompute xs 1)
- else if(flag == 2 && x /= ' ') then x:(formatSentenceCompute xs 1)
- else (formatSentenceCompute xs 2)
- formatSentenceCompute [] 1 = []
- formatSentenceCompute [] 0 = []
- formatSentenceCompute [] 2 = []
- formatText (x:xs) = (formatTextCompute (x:xs) 0)
- formatTextCompute (x:xs) flag = if(flag == 0 && x /= ' ') then (Char.toUpper x):(formatTextCompute xs 1)
- else if(flag == 0 && x == ' ') then x:(formatTextCompute xs 0)
- else if(flag == 1 && x /= ' ') then x:(formatTextCompute xs 1)
- else x:(formatTextCompute xs 0)
- formatTextCompute [] 1 = []
- formatTextCompute [] 0 = []
- my_map f [] = []
- my_map f (x:xs) = (f x):(my_map f xs)
- dropit (x:xs) = (dropCompute (x:xs) 1)
- dropCompute [] 1 = []
- dropCompute [] 2 = []
- dropCompute (x:xs) flag = if(flag == 1) then x:(dropCompute xs 2)
- else (dropCompute xs 1)
- sumit L = 0
- sumit (T(k,left,right)) = (k + (sumit left) + (sumit right))
- replaceAll [] charC charR = []
- replaceAll (x:xs) (y:ys) (g:gs) = if(x == y) then g:(replaceAll xs (y:ys) (g:gs))
- else x:(replaceAll xs (y:ys) (g:gs))
- isPower2 x = if(x `mod` 2 == 0 && x < 6 || x == 1) then True
- else if(x `mod` 2 == 1 && x < 6) then False
- else (isPower2 (x `div` 2))
- dropitp (x:xs) = (dropComputep (x:xs))
- dropComputep [] = []
- dropComputep (x:xs) = if(isPower2 x) then (dropComputep xs)
- else x:(dropComputep xs)
- getElement [] val = val
- getElement (x:xs) val = (getElement xs x)
- functie [] = []
- functie (x:xs) = if((getElement x ' ') == 'a') then 1:(functie xs)
- else 0:(functie xs)
- pairSum [] = 0
- pairSum ((x,y):xs) = ((x*y) + (pairSum xs))
- formatText2 (x:xs) = (formatTextCompute2 (x:xs) 0)
- formatTextCompute2 (x:xs) flag = if(flag == 0 && x /= ' ') then (toEnum(fromEnum x - 32)::Char):(formatTextCompute2 xs 1)
- else if(flag == 0 && x == ' ') then x:(formatTextCompute2 xs 0)
- else if(flag == 1 && x /= ' ') then x:(formatTextCompute2 xs 1)
- else x:(formatTextCompute2 xs 0)
- formatTextCompute2 [] 1 = []
- formatTextCompute2 [] 0 = []
- \end{code}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement