File tree Expand file tree Collapse file tree 2 files changed +16
-19
lines changed
Expand file tree Collapse file tree 2 files changed +16
-19
lines changed Original file line number Diff line number Diff line change @@ -406,13 +406,13 @@ def composel1i(iterable):
406406def _make_compose (direction ): # "left", "right"
407407 def compose_two (f , g ):
408408 def composed (* args ):
409- # co-operate with curry: provide a top-level curry context
410- # to allow passthrough from the function that is applied first
411- # to the function that is applied second.
409+ bindings = {}
412410 if iscurried (f ):
413- with dyn .let (_curry_context = (dyn ._curry_context , composed )):
414- a = g (* args )
415- else :
411+ # co-operate with curry: provide a top-level curry context
412+ # to allow passthrough from the function that is applied first
413+ # to the function that is applied second.
414+ bindings = {"_curry_context" : (dyn ._curry_context , composed )}
415+ with dyn .let (** bindings ):
416416 a = g (* args )
417417 # we could duck-test, but this is more predictable for the user
418418 # (consider chaining functions that manipulate a generator), and
Original file line number Diff line number Diff line change @@ -273,22 +273,19 @@ def pipe(values0, *bodys):
273273 """
274274 xs = values0
275275 n = len (bodys )
276- def doit ():
277- nonlocal xs
278- if isinstance (xs , tuple ):
279- xs = update (* xs )
280- else :
281- xs = update (xs )
282276 for k , update in enumerate (bodys ):
283277 islast = (k == n - 1 )
284- # co-operate with curry: provide a top-level curry context
285- # to allow passthrough from a pipelined function to the next
286- # (except the last one, since it exits the curry context).
278+ bindings = {}
287279 if iscurried (update ) and not islast :
288- with dyn .let (_curry_context = (dyn ._curry_context , update )):
289- doit ()
290- else :
291- doit ()
280+ # co-operate with curry: provide a top-level curry context
281+ # to allow passthrough from a pipelined function to the next
282+ # (except the last one, since it exits the curry context).
283+ bindings = {"_curry_context" : (dyn ._curry_context , update )}
284+ with dyn .let (** bindings ):
285+ if isinstance (xs , tuple ):
286+ xs = update (* xs )
287+ else :
288+ xs = update (xs )
292289 if isinstance (xs , tuple ):
293290 return xs if len (xs ) > 1 else xs [0 ]
294291 return xs
You can’t perform that action at this time.
0 commit comments