diff options
author | Patrick Simianer <p@simianer.de> | 2018-04-27 18:46:17 +0000 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2018-04-27 18:46:17 +0000 |
commit | 0b17d6e580efd3faac939612c8de2058f24c128f (patch) | |
tree | 1babc820a244257dd4ca35cd9cc3badc4316cbee /inv | |
parent | 8e0ad499ebfd968b8b97fa412e8b43ac43f25e44 (diff) | |
parent | f723db2eb2d3ec007afd184c98520581e6d0a3f1 (diff) |
Merge branch 'master' of https://github.com/pks/nlp_scripts
Diffstat (limited to 'inv')
-rwxr-xr-x | inv | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -0,0 +1,33 @@ +#!/usr/bin/env ruby + +require 'trollop' + +def main + conf = Trollop::options do + opt :only_low, "inverse only for values < 1.0", :type => :bool, :default => false, :short => "-l" + opt :only_high, "inverse only for values > 1.0", :type => :bool, :default => false, :short => "-h" + end + + while line = STDIN.gets + f = line.to_f + + if conf[:only_low] + if f < 1 + puts line.to_f**(-1) + else + puts line.to_f + end + elsif conf[:only_high] + if f > 1 + puts line.to_f**(-1) + else + puts line.to_f + end + else + puts line.to_f**(-1) + end + end +end + +main + |