Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/mext/array/dotop.rb,
lib/mext/array/choose.rb,
lib/mext/array/scalarop.rb,
lib/mext/array/vectorize.rb

Defined Under Namespace

Classes: SizeMismatch

Constant Summary collapse

DOT_OPERATIONS =
{
  :dotplus => :+,
  :dotminus => :-,
  :dotmul  => :*,
  :dotdiv  => :/,
  :dotmod  => :%,
  :dotpow  => :**,
}
SCALAR_OPERATIONS =

modifying the behaviour of scalar multiplication for Arrays has the unintended side-effect of killing any File.join() path which contains a [‘..’] * n idiomatic figure.

Better not tamper with it and use another name

[ :+, :-, ]
SCALAR_NEW_OPERATIONS =
[ :smul, :/, :%, :**, ]

Instance Method Summary collapse

Instance Method Details

#chooseObject

choose: choose a random element in the array

returns a random element from the array

:nodoc:



10
11
12
13
# File 'lib/mext/array/choose.rb', line 10

def choose
  idx = (rand()*(self.size-1)).round
  self[idx]
end