We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
This is narray version of 100 numpy exercises
Import the narray gem
require "numo/narray"
Create a null vector of size 10
p Numo::Int32.zeros(10) p Numo::Float32.zeros(10)
Create a null vector of size 10 but the fifth value which is 1
Z = Numo::Int32.zeros(10) Z[4] = 1 p Z
Create a vector with values ranging from 10 to 49
Z = Numo::Int32[10..49] p Z
Reverse a vector (first element becomes last)
Z = Numo::Int32[0..49] p Z.reverse
Create a 3x3 matrix with values ranging from 0 to 8
Z = Numo::Int32[0..8].reshape(3,3) p Z