We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
# Write a lambda which takes an integer and square itsquare=proc{|num|num**2}# Write a lambda which takes an integer and increment it by 1plus_one=proc{|num|num+1}# Write a lambda which takes an integer and multiply it by 2into_2=proc{|num|num*2}# Write a lambda which takes two integers and adds themadder=proc{|a,b|a+b}# Write a lambda which takes a hash and returns an array of hash valuesvalues_only=proc{|num_hash|num_hash.values.to_a}input_number_1=gets.to_iinput_number_2=gets.to_iinput_hash=eval(gets)a=square.(input_number_1);b=plus_one.(input_number_2);c=into_2.(input_number_1);d=adder.(input_number_1,input_number_2);e=values_only.(input_hash)pa;pb;pc;pd;pe
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Lambdas
You are viewing a single comment's thread. Return to all comments →