OSDN Git Service

Merge branch 'master' of git.osdn.net:/gitroot/joypy/Thun
authorSimon Forman <sforman@hushmail.com>
Mon, 22 Nov 2021 18:29:53 +0000 (10:29 -0800)
committerSimon Forman <sforman@hushmail.com>
Mon, 22 Nov 2021 18:29:53 +0000 (10:29 -0800)
1  2 
joy/library.py

diff --cc joy/library.py
@@@ -437,26 -424,39 +437,39 @@@ def take(stack)
  
  
  @inscribe
+ @FunctionWrapper
+ def gcd2(stack, expression, dictionary):
+     '''Compiled GCD function.'''
+     (v1, (v2, stack)) = stack
+     tos = True
+     while tos:
+         v3 = v2 % v1
+         tos = v3 > 0
+         (v1, (v2, stack)) = (v3, (v1, stack))
+     return (v2, stack), expression, dictionary
+ @inscribe
  @SimpleFunctionWrapper
  def choice(stack):
 -      '''
 -      Use a Boolean value to select one of two items.
 -      ::
 +    '''
 +    Use a Boolean value to select one of two items.
 +    ::
  
 -                 A B False choice
 -              ----------------------
 -                 A
 +           A B False choice
 +        ----------------------
 +           A
  
  
 -                 A B True choice
 -              ---------------------
 -                   B
 +           A B True choice
 +        ---------------------
 +             B
  
 -      Currently Python semantics are used to evaluate the "truthiness" of the
 -      Boolean value (so empty string, zero, etc. are counted as false, etc.)
 -      '''
 -      (if_, (then, (else_, stack))) = stack
 -      return then if if_ else else_, stack
 +    Currently Python semantics are used to evaluate the "truthiness" of the
 +    Boolean value (so empty string, zero, etc. are counted as false, etc.)
 +    '''
 +    (if_, (then, (else_, stack))) = stack
 +    return then if if_ else else_, stack
  
  
  @inscribe