我试着清理我的代码.第一个版本使用each_with_index.在第二个版本中,我试图用Enumerable.inject_with_index-construct我在这里找到的代码压缩代码.
它现在有效,但在我看来像第一个代码一样模糊.添加更糟糕我不明白元素周围的括号,索引
.. .inject(groups) do |group_container, (element,index)|
Run Code Online (Sandbox Code Playgroud)
但他们是必要的
class Array
# splits as good as possible to groups of same size
# elements are sorted. I.e. low elements go to the first group,
# and high elements to the last group
#
# the default for number_of_groups is 4
# because the intended use case is
# splitting statistic data in 4 quartiles
#
# a = [1, 8, …Run Code Online (Sandbox Code Playgroud) 我的gnuplot安装失败,因为无法加载libjpeg.
$ gnuplot
dyld: Library not loaded: /usr/local/lib/libjpeg.8.dylib
Referenced from: /usr/local/bin/gnuplot
Reason: image not found
Trace/BPT trap: 5
Run Code Online (Sandbox Code Playgroud)
我使用osx-mavericks + XCode 5.1.Gnuplot最初是在自制的 osx-mountain-lion下安装的.在山狮下它起作用了.我试图在小牛队下重新安装它,但它没有帮助.
brew reinstall gnuplot --tests
==> Reinstalling gnuplot with --tests
..
==> make
==> make check
Reason: image not found
/bin/sh: line 1: 30700 Trace/BPT trap: 5 PATH=$bdir/../src:$PATH GNUPLOT_DRIVER_DIR=$bdir/../src GNUPLOT_LIB=. gnuplot all.dem < /dev/null
make[2]: *** [check-noninteractive] Error 133
make[1]: *** [check-am] Error 2
make: *** [check-recursive] Error 1
Run Code Online (Sandbox Code Playgroud)
附加信息:brew install libjpeg说"jpeg-8d已安装",但我找不到libjpeg.我只找到了几个版本的libpng.
$ brew install …Run Code Online (Sandbox Code Playgroud)