About Matrix

2015-12-14 0 1,011
About Matrix
#!/usr/bin/env perl6

use v6;

sub MAIN(Str :f($file)) {
	my @lines 	= $file.IO.lines;
	my @subjects 	= @lines.shift.words;
	my @datas	= [,] @lines.map: *.words[1 .. * - 1];
	my @names	= [,] @lines.map: *.words[0];

	my @row = @datas.map: -> @r { @r <</>> [+] @r };
	my @col = [Z] ([Z] @datas).map: -> @c { @c <</>> [+] @c }; 
	my @all = @datas.map: -> @r { @r <</>> ([+] @datas.map(|*)) };
	
	print(@subjects, @names, @row);
	print(@subjects, @names, @col);
	print(@subjects, @names, @all);
}

sub print(@subjects, @names, @data) {
	say @subjects.join("\t");
	for (@names Z @data) -> @one {
		say @one.map(|*).join("\t");
	}
}

遇见资源网 perl About Matrix http://www.ox520.com/12965.html

上一篇:

已经没有上一篇了!

下一篇:

已经没有下一篇了!

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务