ここに Haskell の質問があります: ユーザーが 0 を入力するまで数値を繰り返し入力し、これらの数値を順番に表示します。
int のリストを順番に配置する方法を知っています。これは私のコードです:
placeinorder :: [Int] -> [Int]
placeinorder [] = []
placeinorder [x] = [x]
placeinorder (pivot:xs) = placeinorder left ++ [pivot] ++ placeinorder right
where left = filter (<pivot) xs
right = filter (>pivot) xs
さらに、入力から Int を取得する方法を知っています。
getInt :: IO Int
getInt = do
line <- getLine
return (read line :: Int)
しかし、入力数値をリストに変更する方法がわかりません...そして、placeinorder関数を使用できます。
誰かが私のために適切なコードを書くことができますか?
本当にありがとう!!!!