Questions tagged [ruby-1.8.7]

For issues relating to developing in Ruby, version 1.8.7.

Use this specific tag along with the generic one: .

202 questions
-1
votes
2 answers

How to get an average from matrix[array]

(Before start, I am using Ruby 1.8.7, so I won't be able to use fancy stuff.) As title says, I want to calculate the average of column or row. But, I can't even find the way to traverse/iterate Matrix form of array from online. Let's say you have…
GothLoli
  • 19
  • 1
  • 5
-1
votes
3 answers

regex to match everything except protocol from url

I have the following regex pattern: (?:http.?:\/\/) This matches the protocol component from a web url, I want a regex to do the opposit, to match everything except the protocol, so far my every attempt has not worked at all. Becuase ultimatly what…
Thermatix
  • 2,224
  • 13
  • 36
-1
votes
3 answers

Inject in array

I am trying to do some calculation like the following. option is an empty hash and aes is an array. options = {} aes = [1,2] test = aes.inject([]) do |array, value| array << value + 2 array << value -1 if options[:calculation] # here…
Arvind Kumar
  • 217
  • 2
  • 11
-1
votes
1 answer

Greedy conditional algorithm

I have a list of k artistes mapped to their respective music videos that they have starred in. This is represented in a multidimensional array: musicvid_arr = [["MUSICVID 1", 2014, ["ARTISTE 1", "ARTISTE 2", "ARTISTE 3"]], ["MUSICVID 2", 2014,…
JQuack
  • 21
  • 4
-1
votes
1 answer

Array of IDs to array of function results

I currently have this code def objects(ids) array = [] ids.each do |id| array << object(id) # => # end array end objects([1, 2, 3]) # => [#, #, #] It seems like there should be a cleaner way to…
Dan Grahn
  • 8,166
  • 3
  • 33
  • 67
-1
votes
2 answers

Ruby: Permutation on an Array

Say, I have an array: a = [1,2] and n = 3 I want output like this: [[1, 1, 1], [1, 1, 2], [1, 2, 1], [1, 2, 2], [2, 1, 1], [2, 1, 2], [2, 2, 1], [2, 2, 2]] This are all possible combinations of length n of elements from array a. Most importantly…
rony36
  • 3,073
  • 1
  • 27
  • 40
-5
votes
2 answers

adding a new table using rails migration..?

I want to add new table using rails migration: **table_name** users_location_track **columns** id (primary key, auto increment serial), user_id (reference to users), location_info (string), creation_time(time-stamp) please…
piyushmandovra
  • 3,673
  • 2
  • 17
  • 29
1 2 3
13
14