Jump to content

Department numbers: Difference between revisions

m
→‎{{header|Python}}: (defined bind in terms of operator.add)
m (→‎{{header|Python}}: (defined bind in terms of operator.add))
Line 1,925:
14: 6 5 1 </pre>
 
Or, encodingexpressing the options directly and declaratively in terms of '''reduce''' and '''add''', without importing permutations:
 
<lang python>from functools import (reduce)
from operator import (add)
 
 
Line 1,960 ⟶ 1,961:
# bind (>>=) :: [a] -> (a -> [b]) -> [b]
def bind(xs):
return lambda f: reduce(add, map(f, xs), [])
lambda a, b: a + b,
map(f, xs),
[]
)
 
 
9,659

edits

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