Created
April 8, 2016 03:00
-
-
Save davidrichards/b0c45891264b6ee5d67b453cb014ef48 to your computer and use it in GitHub Desktop.
Quick-entry command line number multiplier (because of some quantitative self efforts I'm doing: http://bit.ly/1MXqjTc)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/ruby | |
puts "Space-delimit numbers to multiply" | |
string = gets.chomp | |
until string.length == 0 | |
numbers = string.split(/\s+/).map(&:to_f) | |
result = numbers.reduce(1.0) {|p, e| p * e} | |
puts "Input: #{numbers.inspect}", "Result: ", result, "Another? (return nothing to quit)" | |
string = gets.chomp | |
end | |
puts "Have a #{%w(great wonderful choodesno unbelievable fantastic worthwhile productive enlightened).sample} day!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment