Read a specific line from a file: Difference between revisions
Content deleted Content added
No edit summary |
Add Factor example |
||
Line 597:
in function read_a_specific_line:line_nr/2 (read_a_specific_line.erl, line 25)
</pre>
=={{header|Factor}}==
<lang factor>USING: continuations fry io io.encodings.utf8 io.files kernel
math ;
IN: rosetta-code.nth-line
: nth-line ( path encoding n -- str/f )
[ f ] 3dip '[
[ _ [ drop readln [ return ] unless* ] times ]
with-return
] with-file-reader ;
: nth-line-demo ( -- )
"input.txt" utf8 7 nth-line [ "line not found" ] unless*
print ;
MAIN: nth-line-demo</lang>
=={{header|Fortran}}==
|