Talk:Read a specific line from a file: Difference between revisions

→‎...put it in a variable?: unnatural for FP languages
m (I have not got round to looking at Perl6 yet)
(→‎...put it in a variable?: unnatural for FP languages)
Line 4:
:FWIW The Tcl solution looks like it is using a variable named "line", which is an acceptable solution for the purpose of this task. I cannot read the other two languages, so I can't comment on the solutions. [[User:Markhobley|Markhobley]] 00:59, 24 July 2011 (UTC)
::Looking again, I guess that the Perl6 solution is missing some file opening code, and closing code and is capturing to standard output. It probably just requires a small change. I have not got round to looking at Perl6 yet, so I am not skilled enough to make such changes at this time.[[User:Markhobley|Markhobley]] 01:06, 24 July 2011 (UTC)
:::I guess my point is that assuming there's a variable assumes you're using an imperative language. Perl 6 is more of a functional language, and lines (without other arguments) returns a lazy list of the lines from the file named on the command line, or STDIN, much like <tt><></tt> does in Perl 5. The open and close are implicit in the generator. The <tt>[6]</tt> subscript selects the 7th element of the lazy list and returns it. Then we print that. Storing it in a variable would be an unnecessary step, and rather unidiomatic, and not needed for the main point of the task. --[[User:TimToady|TimToady]] 01:44, 24 July 2011 (UTC)
Anonymous user