Skip to content

Commit

Permalink
improving and fixing use of generators, and a new Mersenne prime!
Browse files Browse the repository at this point in the history
  • Loading branch information
ConceptJunkie committed Oct 21, 2024
1 parent 21b004f commit c414b9e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rpn/math/rpnLexicographic.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def combineDigits( n ):
listResult = False

for i in n:
if isinstance( i, ( list, RPNGenerator ) ) and result == 0:
if isinstance( i, ( list, types.GeneratorType, RPNGenerator ) ) and result == 0:
listResult = True
result = combineDigits( i )
elif listResult:
Expand Down
3 changes: 2 additions & 1 deletion rpn/math/rpnNumberTheory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2409,7 +2409,8 @@ def getNthZetaZeroOperator( n ):
48: 57885161,
49: 74207281,
50: 77232917,
51: 82589933
51: 82589933,
52: 136279841
}


Expand Down
7 changes: 5 additions & 2 deletions rpn/special/rpnList.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,13 +920,16 @@ def reduceListOperator( n ):
#******************************************************************************

def calculateGeometricMean( args ):
if isinstance( args[ 0 ], ( list, types.GeneratorType ) ):
return [ calculateGeometricMean( list( arg ) ) for arg in args ]
if not isinstance( args, types.GeneratorType ):
if isinstance( args[ 0 ], ( list, types.GeneratorType ) ):
return [ calculateGeometricMean( arg ) for arg in args ]

result = mpmathify( 1 )
count = 0

for arg in args:
print( 'arg', arg, type( arg ) )

result = fmul( result, arg )
count += 1

Expand Down

0 comments on commit c414b9e

Please sign in to comment.