[ create a new paste ] login | about

Link: http://codepad.org/YH4fgsFX    [ raw code | output | fork ]

fgtrjhyu - Python, pasted on Feb 6:
#!env python

from __future__ import print_function
from random import randint

def run(pred, f, somep, otherp, elsep):
  def wrap(g):
    def p(x):
      result = f(x)
      if result:
        g()
      return result
    return p

  def inrun(someproc, otherproc, elseproc):
    p = pred()
    if p == 0:
      result = someproc(0)
    elif p == 1:
      result = otherproc(2)
    else:
      result = elseproc(4)
    return result

  return inrun(wrap(somep), wrap(otherp), wrap(elsep))

print(
  run(
    lambda: randint(0, 2)
  , lambda x: x % 2 == 0
  , lambda: print("some")
  , lambda: print("other")
  , lambda: print("else")
  )
)


Output:
1
2
3
4
  Line 31
    , lambda: print("some")
                  ^
SyntaxError: invalid syntax


Create a new paste based on this one


Comments: