0 Members and 1 Guest are viewing this topic.
StringFunction = lambda {|stringInput, pat, rep| #outwards lambda replaceAll = lambda {|inputString, pattern, replacement| #nested while inputString.sub!(pattern, replacement) inputString = inputString.sub(pattern, replacement) end } replaceAll.call(stringInput, pat, rep)}String NonLolzed = StringFunction.call(gets.chomp, " lol ", " 0x5 ")#finally use all those lambdas :roll:puts NonLulzed
I'm running through this and so far it seems to be much the same thing as python with slightly different sntax on the builtin functions
books.values.times {|rate| ++ratings[rate]}
Qvalue = lambda {|a, b, c| Qlambda = lambda{|a, b, c, plus| if plus; -b + Math.sqrt(b**2-(4*a*c)).div(2*a) else;-b - Math.sqrt(b**2-(4*a*c)).div(2*a);end } if a == 0;nil;else [Qlambda.call(a,b,c,true),Qlambda.call(a,b,c,nil)];end }Args = Array.new(3);Names = ['A','B','C']3.times do |location| puts "Input: " << Names[location] << "?" Args[location] = gets.chomp;endAns = Qvalue.call(Args[1].to_f.to_r,Args[2].to_f.to_r,Args[3].to_f.to_r)if Ans;puts 'Answer is ' << Ans[0].to_s << ' and ' << Ans[1].to_s << ' 'else;puts 'No Real Answers';end
I hope this is not a quadratic solver