On Friday, 27 December 2013 at 20:30:52 UTC, Ivan Kazmenko wrote:
Hmm?.. From my experience, attempting to use a range in a
wrong way usually results in a compilation error. For example,
I can't do
n.iota.map!(_ = readln).sort())
since MapResult isn't a random access range with swappable
Many thanks to Marco, Ali and Jakob for the answers!
On Saturday, 28 December 2013 at 08:56:53 UTC, Jakob Ovrum wrote:
On Friday, 27 December 2013 at 20:30:52 UTC, Ivan Kazmenko
wrote:
Hmm?.. From my experience, attempting to use a range in a
wrong way usually results in a compilation error.
Am Fri, 27 Dec 2013 14:26:59 +
schrieb Ivan Kazmenko ga...@mail.ru:
Quick question.
(1) I can do
n.iota.map!(_ = readln)
to get the next n lines from stdin.
(2) However, when I do
readln.repeat(n)
it looks clearer but works differently: preserves front and reads
only one line.
On 12/27/2013 06:26 AM, Ivan Kazmenko wrote:
n.iota.map!(_ = readln)
to get the next n lines from stdin.
So, what I ask for is some non-caching repeat for functions with side
effects. More idiomatic than (1).
This request comes up once in a while.
Is there something like that in Phobos?
On Friday, 27 December 2013 at 18:32:29 UTC, Jakob Ovrum wrote:
(1) I can do
n.iota.map!(_ = readln)
to get the next n lines from stdin.
This has several issues:
* The result claims to have all kinds of range capabilities
that don't make sense at all. Attempting to actually use these
On Friday, 27 December 2013 at 20:30:52 UTC, Ivan Kazmenko wrote:
On Friday, 27 December 2013 at 18:32:29 UTC, Jakob Ovrum wrote:
If repeat could know whether its first argument is pure, it
could then enable or disable front caching depending on
purity... no way currently?
`readln.repeat(n)`
Am Fri, 27 Dec 2013 20:34:02 +
schrieb Ivan Kazmenko ga...@mail.ru:
Maybe the imperative should be repeat is a function, and
arguments of functions should be evaluated only once? It does
make sense from a language point of view, but somewhat breaks the
abstraction for me.
The