Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Math/Matrix.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ multi method new( @m ) {
self.bless( rows => @m );
}
multi method new (Str $m){
Math::Matrix.new( $m.lines.map: { .words.map: {.Bool.Str eq $_ ?? .Bool !! .Numeric} } );
Math::Matrix.new( $m.lines.map: { .words.map: {$_ eq "False" ?? False !! $_ eq "True" ?? True !! .Numeric} } );
}

submethod BUILD( :@rows!, :$density, :$trace, :$determinant, :$rank, :$nullity,
Expand Down
4 changes: 3 additions & 1 deletion t/020-constructors.rakutest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use Test;

use Math::Matrix;

plan 32;
plan 33;

dies-ok { my $matrix = Math::Matrix.new() } , "Constructor need params";
dies-ok { my $matrix = Math::Matrix.new( [] ) } , "Empty row Array is not enough";
Expand All @@ -19,6 +19,8 @@ lives-ok { my $matrix = Math::Matrix.new( [[1,2],[3,4+i]]) } , "Able to create a
lives-ok { my $matrix = Math::Matrix.new( [[True, False],[False,True]]) }, "created a Bool matrix";
lives-ok { my $matrix = Math::Matrix.new( ((1,2),(3,4))) } , "Able to create matrix with List of List syntax";
lives-ok { my $matrix = Math::Matrix.new( "1 2 \n 3 4") } , "Able to create a int matrix with Str syntax";
lives-ok { my $matrix = Math::Matrix.new( "True True\n True False") }, "Able to create a Bool matrix with Str syntax";


my $matrixa = Math::Matrix.new([[1,2],[3,4]]);
ok $matrixa ~~ Math::Matrix , "object was created of right type";
Expand Down