Jump to content

Generator/Exponential: Difference between revisions

→‎{{header|Python}}: used a def in place of curry and flip
(→‎{{header|Python}}: Added a {Works with} tag to compositional version)
(→‎{{header|Python}}: used a def in place of curry and flip)
Line 2,377:
raised to the nth power.'''
 
def f(x):
return fmapGen(flip(curry(pow))(n))(
countreturn pow(0x, n)
 
)
return fmapGen(flipf)(currycount(pow0))(n))(
 
 
Line 2,398 ⟶ 2,399:
 
# GENERIC -------------------------------------------------
 
 
# curry :: ((a, b) -> c) -> a -> b -> c
def curry(f):
'''A curried function derived
from an uncurried function.'''
return lambda a: lambda b: f(a, b)
 
 
Line 2,438 ⟶ 2,432:
return xs
return lambda xs: go(xs)
 
 
# flip :: (a -> b -> c) -> b -> a -> c
def flip(f):
'''The curried function f with its
arguments reversed.'''
return lambda a: lambda b: f(b)(a)
 
 
9,655

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.