Skip to content

Commit

Permalink
issue albertz#10 replace not_a_dashdash with two lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
markjenkins committed Aug 4, 2018
1 parent 7b48236 commit b359423
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions runcprog.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,8 @@
from cparser import State, parse
from interpreter import Interpreter

def not_a_dashdash(x):
return x != "--"

def main():
c_code_files = list(takewhile(not_a_dashdash, argv[1:]))
c_code_files = list(takewhile(lambda x: x != "--", argv[1:]))
if len(c_code_files) == 0:
raise Exception("You must provide at least one C source file")

Expand All @@ -86,7 +83,7 @@ def main():
# that if there's no "--" or nothing after it, this will be an empty
# sequence but chain() below will have no problem with that
arguments_to_c_prog_iter = islice(
dropwhile(not_a_dashdash, argv[1:]), 1, None)
dropwhile(lambda x: x != "--", argv[1:]), 1, None)

# by chaining the program name (first c file) and possible remaining
# arguments we ensure there is at least one
Expand Down

0 comments on commit b359423

Please sign in to comment.