September 03, 2015
>
> ep18.d(10): Error: no property 'split' for type 'char[]'
> /usr/include/dmd/phobos/std/algorithm.d(427):        instantiated from here: MapResult!(__lambda1, ByLine!(char, char))
> ep18.d(10):        instantiated from here: map!(ByLine!(char, char))
>
> and then a long list to the end of my code
>  Error: undefined identifier a

Hmm, seems I forgot to add std.string, now it works, but words seems not to be an array, at least I cannot access it like an array. words[0][0] leads to

 Error: no [] operator overload for type MapResult!(__lambda1, ByLine!(char, char))

So is is a map? How can I convert all the elements in it to integer and store it in a real array?
September 03, 2015
On Thursday, 3 September 2015 at 22:21:57 UTC, Namal wrote:
>>
>> ep18.d(10): Error: no property 'split' for type 'char[]'
>> /usr/include/dmd/phobos/std/algorithm.d(427):        instantiated from here: MapResult!(__lambda1, ByLine!(char, char))
>> ep18.d(10):        instantiated from here: map!(ByLine!(char, char))
>>
>> and then a long list to the end of my code
>>  Error: undefined identifier a
>
> Hmm, seems I forgot to add std.string, now it works, but words seems not to be an array, at least I cannot access it like an array. words[0][0] leads to
>
>  Error: no [] operator overload for type MapResult!(__lambda1, ByLine!(char, char))
>
> So is is a map? How can I convert all the elements in it to integer and store it in a real array?

I believe it's by using array:
auto words = file.byLine()           // you've all lines in  range
                  .map!(a => a.split).array();



September 03, 2015
On Thursday, 3 September 2015 at 22:48:01 UTC, Jordan Wilson wrote:
> On Thursday, 3 September 2015 at 22:21:57 UTC, Namal wrote:
>>>
>>> ep18.d(10): Error: no property 'split' for type 'char[]'
>>> /usr/include/dmd/phobos/std/algorithm.d(427):        instantiated from here: MapResult!(__lambda1, ByLine!(char, char))
>>> ep18.d(10):        instantiated from here: map!(ByLine!(char, char))
>>>
>>> and then a long list to the end of my code
>>>  Error: undefined identifier a
>>
>> Hmm, seems I forgot to add std.string, now it works, but words seems not to be an array, at least I cannot access it like an array. words[0][0] leads to
>>
>>  Error: no [] operator overload for type MapResult!(__lambda1, ByLine!(char, char))
>>
>> So is is a map? How can I convert all the elements in it to integer and store it in a real array?
>
> I believe it's by using array:
> auto words = file.byLine()           // you've all lines in  range
>                   .map!(a => a.split).array();

Sorry, I didn't notice the "convert all the elements in it to integer" part.
I think I saw reference to the to! before...that is one way to convert.

auto words = file.byLine()           // you've all lines in range
                   .map!(a => a.split)
		   .map!(a => to!int(a)).array();


September 03, 2015
> Sorry, I didn't notice the "convert all the elements in it to integer" part.
> I think I saw reference to the to! before...that is one way to convert.
>
> auto words = file.byLine()           // you've all lines in range
>                    .map!(a => a.split)
> 		   .map!(a => to!int(a)).array();


import std.file, std.stdio, std.string, std.conv;

void main(){

	auto file = File("text.txt");
	auto numbers = file.byLine()
               .map!(a => a.split)
               .map!(a => to!int(a)).array();
	
	writeln(numbers);
}

ep18.d(7): Error: no property 'map' for type 'ByLine!(char, char)'


September 03, 2015
Actually, need an extra map I think:

auto word = file.byLine()
                    .map!(a => a.split)
                    .map!(a => map!(a => to!int(a))(a))
                    .array();


September 03, 2015
And also:
import std.algorithm

Sorry, I should have taken the time to answer properly and fully.
September 03, 2015
On Thursday, 3 September 2015 at 23:25:52 UTC, Jordan Wilson wrote:
> And also:
> import std.algorithm
>
> Sorry, I should have taken the time to answer properly and fully.

import std.file, std.stdio, std.string, std.conv, std.algorithm;

void main(){

	auto file = File("text.txt");
	auto numbers = file.byLine()
                 .map!(a => a.split)
                 .map!(a => map!(a => to!int(a))(a))
                 .array();
	
	writeln(numbers);
}

Error: no property 'array' for type 'MapResult!(__lambda2, MapResult!(__lambda1, ByLine!(char, char)))'

Still an error.
September 03, 2015
On Thursday, 3 September 2015 at 23:28:37 UTC, Namal wrote:
> On Thursday, 3 September 2015 at 23:25:52 UTC, Jordan Wilson wrote:
>> And also:
>> import std.algorithm
>>
>> Sorry, I should have taken the time to answer properly and fully.
>
> import std.file, std.stdio, std.string, std.conv, std.algorithm;
>
> void main(){
>
> 	auto file = File("text.txt");
> 	auto numbers = file.byLine()
>                  .map!(a => a.split)
>                  .map!(a => map!(a => to!int(a))(a))
>                  .array();
> 	
> 	writeln(numbers);
> }
>
> Error: no property 'array' for type 'MapResult!(__lambda2, MapResult!(__lambda1, ByLine!(char, char)))'
>
> Still an error.

import std.array

September 03, 2015
On Thu, Sep 03, 2015 at 11:22:09PM +0000, Namal via Digitalmars-d-learn wrote:
> >Sorry, I didn't notice the "convert all the elements in it to integer"
> >part.
> >I think I saw reference to the to! before...that is one way to convert.
> >
> >auto words = file.byLine()           // you've all lines in range
> >                   .map!(a => a.split)
> >		   .map!(a => to!int(a)).array();
> 
> 
> import std.file, std.stdio, std.string, std.conv;
> 
> void main(){
> 
> 	auto file = File("text.txt");
> 	auto numbers = file.byLine()
>                .map!(a => a.split)
>                .map!(a => to!int(a)).array();
> 
> 	writeln(numbers);
> }
> 
> ep18.d(7): Error: no property 'map' for type 'ByLine!(char, char)'

	import std.algorithm : map;


T

-- 
Never step over a puddle, always step around it. Chances are that whatever made it is still dripping.
September 03, 2015
On Thu, Sep 03, 2015 at 11:28:36PM +0000, Namal via Digitalmars-d-learn wrote:
> On Thursday, 3 September 2015 at 23:25:52 UTC, Jordan Wilson wrote:
> >And also:
> >import std.algorithm
> >
> >Sorry, I should have taken the time to answer properly and fully.
> 
> import std.file, std.stdio, std.string, std.conv, std.algorithm;
> 
> void main(){
> 
> 	auto file = File("text.txt");
> 	auto numbers = file.byLine()
>                  .map!(a => a.split)
>                  .map!(a => map!(a => to!int(a))(a))
>                  .array();
> 
> 	writeln(numbers);
> }
> 
> Error: no property 'array' for type 'MapResult!(__lambda2,
> MapResult!(__lambda1, ByLine!(char, char)))'
> 
> Still an error.

	import std.array : array;


T

-- 
Do not reason with the unreasonable; you lose by definition.