def test_put_line(self) -> None: pm = MyMock() action = put_line("hello, world!") action() self.assertEqual(pm.value, "hello, world!")
def test_put_line(self): pm = MyMock() io = put_line("hello, world!") io(print=pm.print) self.assertEqual(pm.value, "hello, world!")
from oslash import put_line, get_line main = put_line("What is your name?") | (lambda _: get_line() | (lambda name: put_line("What is your age?") | (lambda _: get_line() | (lambda age: put_line("Hello " + name + "!") | (lambda _: put_line("You are " + age + " years old")))))) if __name__ == "__main__": main()
from oslash import put_line, get_line main = put_line("What is your name?") >> (lambda _: get_line() >> (lambda name: put_line("What is your age?") >> (lambda _: get_line() >> (lambda age: put_line("Hello " + name + "!") >> (lambda _: put_line("You are " + age + " years old")))))) if __name__ == "__main__": main()
"""Hello example using do-notation.""" from oslash import put_line, get_line, do, let main = do(put_line("What is your name?"), let(name=get_line()), put_line("What is your age?"), let(age=get_line()), lambda e: put_line("Hello " + e.name + "!"), lambda e: put_line("You are " + e.age + " years old")) if __name__ == "__main__": #print(main) main()