例如,
bc <- structure(list(time = c("14:56:00", "14:57:00", "14:58:00",
"14:59:00",
"15:00:00", "15:01:00"), bc = c(NA, -76L, 1301L, 1057L, -336L,
490L)), .Names = c("time", "bc"), class = "data.frame",
row.names = c(NA, -6L))
我想知道有多少不同的单线解决方案。这就是我得到的数量(6):
[0.99].to_a
# => [0, 1, 2, 3...]
答案 0 :(得分:2)
1. (0..99).to_a
2. (0..99).map{|e| e}
3. 1.upto(99).inject([]) { |sum, e| sum << e }
4. 1.upto(99).map { |e| e }
5. 99.times.inject([]) { |sum, e| sum << e.next}
答案 1 :(得分:1)
你可以这样做:
import android.graphics.Bitmap;
public void getPixels (int[] pixels, int offset, int stride, int x, int y, int width, int height);
Bitmap bmap = source.renderCroppedGreyscaleBitmap();
int w=bmap.getWidth(),h=bmap.getHeight();
int[] pix = new int[w * h];
bmap.getPixels(pix, 0, w, 0, 0, w, h);
答案 2 :(得分:0)
显而易见的......
Array.new(100) {|i| i}
# the same as:
Array.new(100, &:to_i)
如果我们想对此愚蠢:
Module.const_get([].class.name).new(100, &:to_i)
eval("[1,2,3,*(4..99)]")