L
Li Chen
Hi all,
I modify James' code and want to return a hash with all values set to
0. But I only get an empty hash. I wonder what is wrong with my codes.
Thanks,
Li
def table(array,word_size=1,word='')
hash_table=Hash.new(0)
array.each do |e|
if word_size==1
hash_table["#{word+e}" ]=0
else
table(array,word_size-1,word+e )
end
end
return hash_table
end
######################
array=['A','C','G','T']
p table(array,2)
### here is ressults:###
I modify James' code and want to return a hash with all values set to
0. But I only get an empty hash. I wonder what is wrong with my codes.
Thanks,
Li
def table(array,word_size=1,word='')
hash_table=Hash.new(0)
array.each do |e|
if word_size==1
hash_table["#{word+e}" ]=0
else
table(array,word_size-1,word+e )
end
end
return hash_table
end
######################
array=['A','C','G','T']
p table(array,2)
### here is ressults:###