Example #1
0
class Calculator(object):

    def __init__(self, input_string):
        self.input = Parser().parse(input_string)

    def add(self):
        if self.input == "":
            return ""
        else:
            return reduce(lambda x, y: x + y, map(lambda x: int(x), self.input.split(",")))
Example #2
0
class Calculator(object):
    def __init__(self, input_string):
        self.input = Parser().parse(input_string)

    def add(self):
        if self.input == "":
            return ""
        else:
            return reduce(lambda x, y: x + y,
                          map(lambda x: int(x), self.input.split(",")))
Example #3
0
 def __init__(self, input_string):
     self.input = Parser().parse(input_string)
Example #4
0
 def test_that_it_converts_delimiters_to_commas(self):
     self.assertEquals(Parser().parse("//;\n1;2"), "1,2")
Example #5
0
 def test_that_it_converts_newline_characters_to_commas(self):
     self.assertEquals(Parser().parse("1\n2,3"), "1,2,3")
Example #6
0
 def __init__(self, input_string):
     self.input = Parser().parse(input_string)