[haskell] toy program

Viewer

copydownloadembedprintName: toy program
  1. import Data.List (delete)
  2.  
  3. keyWord :: String
  4. keyWord = "VIBGYOR" 
  5.  
  6. keyWordLength :: Int
  7. keyWordLength = length keyWord - 1
  8.  
  9. number :: Integer
  10. number = 11
  11.  
  12. colorChoice :: Int -> Char
  13. colorChoice number = if number <= keyWordLength
  14.                        then  keyWord !! number
  15.                      else keyWord !! (number `mod` keyWordLength)
  16.  
  17. uncommon :: Eq a => [a] -> [a] -> [a]
  18. uncommon xs ys = foldr delete xs ys ++ foldr delete ys xs                     
  19.  
  20.  
  21. getInputs :: IO()
  22. getInputs = do
  23.             putStrLn "Enter your name: "
  24.             input1 <- getLine
  25.             putStrLn "Enter another name: "
  26.             input2 <- getLine
  27.             let firstName =  input1 
  28.             let secondName = input2 
  29.             let output = colorChoice (length ( uncommon firstName secondName))
  30.             print output

Editor

You can edit this paste and save as new:


File Description
  • toy program
  • Paste Code
  • 04 Sep-2023
  • 847 Bytes
You can Share it: