home > 比較編 > F#, Scala, Haskell > environment and i/o >

ForNext

Only Do What Only You Can Do

116. read from file

VBScript

JScript

Perl

PHP

Python

Ruby

PowerShell

Scala

import scala.io.Source
val src = Source.fromFile("/etc/passwd")
for (line <- src.getLines)
  print(line)










F#

OCaml

let ic = open_in "/etc/passwd" in
let line = input_line ic in
print_endline line;;











Haskell

import IO
readAndPrintLines h = do
  eof <- hIsEOF h
  if eof
    then return ()
    else do
      line <- hGetLine h
      putStrLn line
      readAndPrintLines h
main = do
  h <- openFile "/etc/passwd" ReadMode
  readAndPrintLines h


C

C++

C++Builder

VC++

C#

Java

Objective-C

D

VB

VB.NET

Delphi

Ada

PL/SQL

T-SQL

inserted by FC2 system