Exemple #1
0
def char_between(lower, upper, func_name): 
  '''return current char and step if char is between lower and upper, where 
   @test: a python function with one argument, which tests on one char and return True or False
          @test must be registered with register_function'''
  function = register_function(func_name, 
                      lambda char: lower<=char<=upper)
  return char_on_predicate(function)
Exemple #2
0
def char_in(string, func_name): 
  '''return current char and step if char is in string, where 
   @test: a python function with one argument, which tests on one char and return True or False
          @test must be registered with register_function'''
  function = register_function(func_name, 
                      lambda char: char in string)
  return char_on_predicate(function)
Exemple #3
0
  '''return current char and step if char is between lower and upper, where 
   @test: a python function with one argument, which tests on one char and return True or False
          @test must be registered with register_function'''
  function = register_function(func_name, 
                      lambda char: lower<=char<=upper)
  return char_on_predicate(function)

def char_in(string, func_name): 
  '''return current char and step if char is in string, where 
   @test: a python function with one argument, which tests on one char and return True or False
          @test must be registered with register_function'''
  function = register_function(func_name, 
                      lambda char: char in string)
  return char_on_predicate(function)

is_digit = register_function('is_digit', lambda char: '0'<=char<='9')
digit = char_on_predicate(is_digit)

is_one_to_nine = register_function('is_one_to_nine', lambda char: '1'<=char<='9')
one_to_nine = char_on_predicate(is_one_to_nine)

is_lowcase = register_function('is_lowcase', lambda char: 'a'<=char<='z')
lowcase = char_on_predicate(is_lowcase)

is_uppercase = register_function('is_uppercase', lambda char: 'A'<=char<='Z')
uppercase = char_on_predicate(is_uppercase)

is_letter = register_function('is_letter', 
                                lambda char: ('a'<=char<='z') or ('A'<=char<='Z'))
letter = char_on_predicate(is_letter)