wtaysom
02/25/2020, 9:10 AMStefan
02/25/2020, 9:48 AMwtaysom
02/25/2020, 1:02 PMwtaysom
02/25/2020, 1:31 PMhash_mapping_x_to_fx = Hash[xs.map{|x| [x, f(x)]]
From now on, I'm going with:
hash_mapping_x_to_fx = xs.hap{|x| f(x)}
Remember "Ruby was a Lisp originally, in theory." So the definition, for those unfamiliar, can be simple as:
module Enumerable
def hap
Hash[map{|x| [x, yield(x)]}]
end
end
wtaysom
02/25/2020, 1:37 PM