通过一些给定的值构造矩阵 [英] construct a matrix by some given values

查看:56
本文介绍了通过一些给定的值构造矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的perl论坛,


我不知道怎么开始这个。我有一个这样的值的文件:

A 2 - 4

B 3 - 5

C 1 - 6


到最后


我需要制定一个这样的矩阵


ID 1 2 3 4 5 6 7 8 9 10

A 0 1 1 1 0 0 0 0 0 0

B 0 0 1 0 0 0 0 0 0 0

C 1 1 1 1 1 1 0 0 0 0

到最后


在个人拥有的价值范围内打印一个并在它之前和之后打印0。我不知道如何开始这样做。


如果你指导我这将是一个很大的帮助。


谢谢,
Dalila

Dear perl Forum,

I have no clue how to start this. I have a file with values like this:
A 2 - 4
B 3 - 5
C 1 - 6

up to the end

I need to formulate a matrix like this

ID 1 2 3 4 5 6 7 8 9 10
A 0 1 1 1 0 0 0 0 0 0
B 0 0 1 0 0 0 0 0 0 0
C 1 1 1 1 1 1 0 0 0 0

up to the end

print one in the range of the value the individual have and print 0 their before and after it. I have no clue how to start doing this.

If you guide me this will be a great help.

Thanks,
Dalila

推荐答案

问候Dalila,


一种方式如下:

Greetings Dalila,

One way would be the following:

展开 | 选择 | Wrap | 行号


非常感谢Miiler,

我会尝试一下。如果值是不规则递增的,我想我可以把它们放到数组中并在你引导我时使用函数图吗?

我非常感谢你的导游。

Dalila
Many thanks Miiler,
I will try it. If the values are irregulary incremented, I think I can put them into array and use the function map as you guided me?
I really very thankful for your guide.
Dalila


没有什么说你必须使用map。这只是我选择的方法。你可以轻松使用for循环。


- 米勒
Nothing says that you have to use map. That is simply the method that I chose. You could have just as easily used a for loop.

- Miller


这篇关于通过一些给定的值构造矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆