这是我的代码
module Main where
import Control.Monad (mapM)
import Text.Read (readMaybe)
import System.IO (BufferMode(..), stdout, hSetBuffering)
mouth = [('P',0),('(',1),('[',2),(')',3),('O',4)]
eyes = [(':',1),('8',2),(';',3)]
findKey :: (Eq k) => k -> [(k,v)] -> Maybe v
findKey key = foldr (\(k,v) acc -> if key == k then Just v else acc) Nothing
query :: Read a => String -> IO a
query prompt = do
putStr $ prompt ++ ": "
val <- readMaybe <$> getLine
case val of
Nothing -> do
putStrLn "Sorry that's a wrong value - please reenter"
query prompt
Just v -> return v
ngoers :: IO Int
ngoers = query "Enter the number of Concertgoers"
cgoers :: Int -> IO (Int, Double)
cgoers i = do
c <- query prompt
return (fromIntegral i,c)
where prompt = "Enter the emoticon for concertgoer " ++ show (i+1)
concertgoer :: IO [(Int, Double)]
concertgoer = do
n <- ngoers
mapM cgoers [0,1..n-1]
presentResult :: Double -> IO ()
presentResult v = putStrLn $ "The results are: " ++ show v
main :: IO ()
main = do
p <- concertgoer
presentResult $ 0
我想要这个输出
Enter the number of Concertgoers: 4
Enter the emoticon for concertgoer 1: :(
Enter the emoticon for concertgoer 2: :)
Enter the emoticon for concertgoer 3: ;P
Enter the emoticon for concertgoer 4: ;o
The results are: 2 4 3 7
答案 0 :(得分:0)
从您的示例中,我猜测您将每个眼睛和嘴巴与一个数字相匹配,如果有的话,表情符号就是总和...但是您在帖子中对此没有任何解释。假设这样,这是一种非常幼稚的编写方式
import swal from sweetalert
swal({ title: 'Warning',
text: 'some user message',
icon: 'warning',
dangerMode: true,
buttons: {
cancel: {
text: 'No',
value: null,
visible: true,
className: 'btn btn-primary',
closeModal: true
},
confirm: {
text: 'Yes',
value: true,
visible: true,
className: 'btn btn-secondary',
closeModal: true
}
}
})
我认为这是您的期望,但请告诉我