Created
April 23, 2013 11:55
-
-
Save arianvp/5442976 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main | |
( main | |
) where | |
import System.Environment (getArgs) | |
main :: IO () | |
main = putStrLn . unlines . (map (unwords .reverse . words)) . lines =<< readFile . head =<< getArgs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
public class Main { | |
public static void main(String[] args) throws IOException { | |
FileReader fileReader = new FileReader(args[0]); | |
try { | |
BufferedReader reader = new BufferedReader(fileReader); | |
String line; | |
while ((line = reader.readLine()) != null) { | |
String[] words = line.split("\\s+"); | |
for (int i = words.length - 1; i >= 0; --i) { | |
System.out.print(words[i] + " "); | |
} | |
System.out.println(); | |
} | |
} finally { | |
fileReader.close(); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$<.each{ |line| puts line.split(/\s+/).reverse.join(' ') } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment