问题描述:

Why is the code below not working- it is not giving the desired output.I want it to sort a string(e.g cba -> abc ) .After I signal end of file with

^D i just get: cba .

import Data.List

import Data.Char

import System.IO (isEOF)

main =

interact (concat . sort .lines)

网友答案:

Looks like you want something more like:

import Data.List

main = interact (unlines . map sort . lines)

This sorts each line entered.

相关阅读:
Top