diff --git a/rpn/makeHelp.py b/rpn/makeHelp.py index 7cb3a7e..264906a 100644 --- a/rpn/makeHelp.py +++ b/rpn/makeHelp.py @@ -187,6 +187,9 @@ def makeCommandExample( command, indent=0, slow=False ): -o, --octal octal mode: equivalent to \'-r8 -w9 -g3 -z\' + -O, --ignore_oeis-cache + ignore cached results from OEIS, accesses the website and updates the cache + -pn, --precision n precision, i.e., number of significant digits to use @@ -2150,9 +2153,9 @@ def makeCommandExample( command, indent=0, slow=False ): ''', ''' ''' + makeCommandExample( '[ 1 2 ] geometric_mean' ) + ''' -''' + makeCommandExample( '[ 1 10 range ] geometric_mean' ) + ''' +''' + makeCommandExample( '1 10 range geometric_mean' ) + ''' Calculate the geometric mean of the first n numbers from 1 to 5: -''' + makeCommandExample( '[ 1 1 5 range range ] geometric_mean' ), +''' + makeCommandExample( '1 1 5 range range lambda x geometric_mean for_each_list' ), [ 'mean', 'agm', 'harmonic_mean', 'root_mean_square' ] ], 'harmonic_mean' : [ @@ -7085,14 +7088,23 @@ def makeCommandExample( command, indent=0, slow=False ): ''' + makeCommandExample( '[ [ 1 2 ] [ 3 4 ] [ 5 6 ] [ 7 8 ] ] lambda x sum for_each_list' ), [ 'for_each', 'sequence' ] ], - 'for_each_list' : [ + 'for_each_list_filter' : [ 'functions', 'filters based on function k on elements of list n, treating each element as a list argument', ''' ''', ''' -''' + makeCommandExample( '[ [ 2 3 ] [ 4 5 ] [ 7 7 ] [ 8 9 ] ] lambda x 0 element x 1 element is_equal for_each_list' ), +''' + makeCommandExample( '[ [ 2 3 ] [ 4 5 ] [ 7 7 ] [ 8 9 ] ] lambda x 0 element x 1 element is_equal for_each_list_filter' ), +[ 'for_each', 'sequence' ] ], + + 'for_each_list_unfilter' : [ +'functions', 'filters based on the inverse of function k on elements of list n, treating each element as a list argument', +''' +''', +''' +''' + makeCommandExample( '[ [ 2 3 ] [ 4 5 ] [ 7 7 ] [ 8 9 ] ] lambda x 0 element x 1 element is_equal for_each_list_unfilter' ), [ 'for_each', 'sequence' ] ], + 'function': [ 'functions', 'creates a user-defined function k named n', ''' diff --git a/rpn/rpn.py b/rpn/rpn.py index d9944fa..2af3a6d 100644 --- a/rpn/rpn.py +++ b/rpn/rpn.py @@ -450,6 +450,7 @@ def rpn( cmdArgs ): parser.add_argument( '-m', '--maximum_fixed', type=int, default=g.defaultMaximumFixed ) parser.add_argument( '-n', '--numerals', type=str, default=g.defaultNumerals ) parser.add_argument( '-o', '--octal', action='store_true' ) + parser.add_argument( '-O', '--ignore_oeis_cache', action='store_true' ) parser.add_argument( '-p', '--precision', type=int, default=g.defaultPrecision ) parser.add_argument( '-r', '--output_radix', type=str, default=g.defaultOutputRadix ) parser.add_argument( '-s', '--list_format_level', nargs='?', type=int, default=0, @@ -550,7 +551,6 @@ def rpn( cmdArgs ): # handle -I g.ignoreCache = args.ignore_cache - g.refreshOEISCache = args.ignore_cache if args.show_timezones: g.showTimeZones = True @@ -571,6 +571,9 @@ def rpn( cmdArgs ): g.integerGrouping = 3 g.bitwiseGroupSize = 9 + # handle -O + g.refreshOEISCache = args.ignore_oeis_cache + # handle -p setPrecision( args.precision ) diff --git a/rpn/special/rpnList.py b/rpn/special/rpnList.py index 5fa8300..3cc3a16 100644 --- a/rpn/special/rpnList.py +++ b/rpn/special/rpnList.py @@ -928,8 +928,6 @@ def calculateGeometricMean( args ): count = 0 for arg in args: - print( 'arg', arg, type( arg ) ) - result = fmul( result, arg ) count += 1 diff --git a/rpn/test/testRPN.py b/rpn/test/testRPN.py index 6125750..245d7b1 100644 --- a/rpn/test/testRPN.py +++ b/rpn/test/testRPN.py @@ -3173,8 +3173,8 @@ def runListOperatorTests( ): # geometric_mean expectEqual( '1 500 range lambda [ x sigma x euler_phi ] geometric_mean is_integer filter', '11257 oeis 500 filter_max' ) # rpn isn't smart enough to let me turn this into a lamdba I can run on a range, so let's just pick 2 particular values to try. - expectEqual( '12 lambda 1 x range powerset eval geometric_mean lambda x is_integer filter count', '326027 oeis 12 element' ) - expectEqual( '14 lambda 1 x range powerset eval geometric_mean lambda x is_integer filter count', '326027 oeis 14 element' ) + expectEqual( '12 lambda 1 x range powerset eval lambda x geometric_mean for_each_list lambda x is_integer filter count', '326027 oeis 12 element' ) + expectEqual( '14 lambda 1 x range powerset eval lambda x geometric_mean for_each_list lambda x is_integer filter count', '326027 oeis 14 element' ) # geometric_range expectEqual( '2 8 8 geometric_range', '0 7 range lambda 2 8 x ** * eval' ) @@ -4951,7 +4951,7 @@ def runPrimeNumberOperatorTests( ): # prime_pi testOperator( '87 prime_pi' ) - expectEqual( '0 998 range lambda x x prime_pi combinations eval', '37031 oeis 999 left' ) + expectEqual( '1 999 range lambda x x prime_pi combinations eval', '37031 oeis 999 left' ) # primes testOperator( '1 5 range 5 primes' )