リスト内のすべての要素の出現回数をカウントして最大シーケンスを返すプログラムを作成します。私は自分の入力部分に問題があります。Haskell 'String - > [Int]'と '[a0]'と一致しませんでした
入力はいくつかのテストケースで構成されています。各テストケースは、2つの整数nとq(1≦n、q≦100000)を含む行から始まります。次の行には、n個の整数a1、...、anが含まれています(-100000≦ai≦100000
readNQでnとqを[int]として取得し、n要素を読み込み[int ]
module Main where
import Text.Printf
import Data.List
main :: IO()
main = interact (showResults . maxSeqLength . readArray. readNQ)
readNQ :: String -> [Int]
readNQ = take 2 . (map read) . words
readArray :: [Int] -> String -> [Int]
readArray (n:xs) = take n . (map read) . words
showResults :: Int -> String
showResults x = printf "\n %d" x
maxSeqLength :: Eq a => [a] -> Int
maxSeqLength [] = 0
maxSeqLength xs = (maximum . map length . group) xs
ただし、次のようなエラーがある
frequent.hs:13:47:エラー:?
• Couldn't match type ‘String -> [Int]’ with ‘[a0]’
Expected type: String -> [a0]
Actual type: String -> String -> [Int]
• Probable cause: ‘(.)’ is applied to too few arguments
In the second argument of ‘(.)’, namely ‘readArray . readNQ’
In the second argument of ‘(.)’, namely
‘maxSeqLength . readArray . readNQ’
In the first argument of ‘interact’, namely
‘(showResults . maxSeqLength . readArray . readNQ)’
readNQとreadArrayの種類と何が間違っている