On Saturday, 26 March 2016 at 08:34:04 UTC, cym13 wrote:
Sorry, it seems I completely misunderstood you goal. I thought
that take() consumed its input (which mostly only shows that I
really am careful about not reusing ranges). Writting a take
that consume shouldn't be difficult though:
On Saturday, 26 March 2016 at 02:28:53 UTC, Hanh wrote:
On Friday, 25 March 2016 at 08:01:04 UTC, cym13 wrote:
// This consume
auto buffer3 = range.take(4).array;
assert(buffer3 == [0, 5, 10, 15]);
}
Thanks for your help. However the last statement is incorrect.
I
On Friday, 25 March 2016 at 08:01:04 UTC, cym13 wrote:
// This consume
auto buffer3 = range.take(4).array;
assert(buffer3 == [0, 5, 10, 15]);
}
Thanks for your help. However the last statement is incorrect. I
am in fact looking for a version of 'take' that consumes
On Thursday, 24 March 2016 at 07:52:27 UTC, Hanh wrote:
On Wednesday, 23 March 2016 at 19:07:34 UTC, cym13 wrote:
In Scala, 'take' consumes bytes from the iterator. So the
same code would be
buffer = range.take(N).toArray
Then just do that!
import std.range, std.array;
auto buffer =
On Wednesday, 23 March 2016 at 19:07:34 UTC, cym13 wrote:
In Scala, 'take' consumes bytes from the iterator. So the same
code would be
buffer = range.take(N).toArray
Then just do that!
import std.range, std.array;
auto buffer = range.take(N).array;
auto example = iota(0, 200, 5)
On Wednesday, 23 March 2016 at 03:17:05 UTC, Hanh wrote:
Thanks for your help everyone.
I agree that the issue is due to the misusage of an InputRange
but what is the semantics of 'take' when applied to an
InputRange? It seems that calling it invalidates the range; in
which case what is the r
On Wed, 23 Mar 2016 03:17:05 +, Hanh wrote:
> In Scala, 'take' consumes bytes from the iterator. So the same code
> would be buffer = range.take(N).toArray
import std.range, std.array;
auto bytes = byteRange.takeExactly(N).array;
There's also take(N), but if the range contains fewer than N el
Thanks for your help everyone.
I agree that the issue is due to the misusage of an InputRange
but what is the semantics of 'take' when applied to an
InputRange? It seems that calling it invalidates the range; in
which case what is the recommended way to get a few bytes and
keep on advancing.
On Tuesday, 22 March 2016 at 07:17:41 UTC, Hanh wrote:
input.take(3).array;
foreach (char c; input) {
Never use an input range twice. So, here's how to use it twice:
If it's a "forward range" you can use save() to get a copy to use
later (but all the std.stdio.* ranges don't i
On 03/22/2016 12:17 AM, Hanh wrote:
> Hi all,
>
> I'm trying to process a rather large file as an InputRange and run into
> something strange with byChunk / take.
>
> void test() {
> auto file = new File("test.txt");
> auto input = file.byChunk(2).joiner;
> input.take(3).array;
>
On Tuesday, 22 March 2016 at 07:17:41 UTC, Hanh wrote:
Hi all,
I'm trying to process a rather large file as an InputRange and
run into something strange with byChunk / take.
void test() {
auto file = new File("test.txt");
auto input = file.byChunk(2).joiner;
input.take
On Tuesday, 22 March 2016 at 07:17:41 UTC, Hanh wrote:
Hi all,
I'm trying to process a rather large file as an InputRange and
run into something strange with byChunk / take.
void test() {
auto file = new File("test.txt");
auto input = file.byChunk(2).joiner;
input.take
Hi all,
I'm trying to process a rather large file as an InputRange and
run into something strange with byChunk / take.
void test() {
auto file = new File("test.txt");
auto input = file.byChunk(2).joiner;
input.take(3).array;
foreach (char c; input) {
13 matches
Mail list logo