File input/output: Difference between revisions

Added Racket code
(→‎{{header|Ruby}}: Task changed at 14 February 2012. Create a variable, instead of just passing the value. Remove many extra details and explanations. To copy a file block by block, just use FileUtils.)
(Added Racket code)
Line 1,689:
 
<lang R>file.copy("input.txt", "output.txt", overwrite = FALSE)</lang>
 
=={{header|Racket}}==
<lang Racket>#lang racket
(define file-content
(with-input-from-file "input.txt"
(lambda ()
(let loop ((lst null))
(define new (read-char))
(if (eof-object? new)
(apply string lst)
(loop (append lst (list new))))))))
 
(with-output-to-file "output.txt"
(lambda ()
(write file-content)))</lang>
 
=={{header|RapidQ}}==
Anonymous user