Determine if a string has all unique characters: Difference between revisions
Determine if a string has all unique characters (view source)
Revision as of 21:47, 29 December 2019
, 4 years ago→Python :: Functional
Line 1,159:
)
]))
return Just(second(fmap(fst))(
key=lambda kv:
)) if duplicates else
else:
return Nothing()
Line 1,263 ⟶ 1,261:
None is m or m.get('Nothing')
) else f(m.get('Just'))
'''A simple function lifted to a function over a tuple,
with f applied only the second of two values.
'''▼
Line 1,269 ⟶ 1,275:
'''Second member of a pair.'''
return tpl[1]
▲# splitArrow (***) :: (a -> b) -> (c -> d) -> ((a, c) -> (b, d))
▲def splitArrow(f):
▲ '''
▲ return lambda g: lambda tpl: (f(tpl[0]), g(tpl[1]))
|