Practical numbers: Difference between revisions

→‎Composition of pure functions: Removed argument with note to see taslk page.
(→‎Composition of pure functions: Explained the semantic type of the central function, which is concealed by the compiler hint.)
(→‎Composition of pure functions: Removed argument with note to see taslk page.)
Line 228:
 
===Composition of pure functions===
SeeOn Haskell vs Python typing see the discussion page.
Note that helpful type comments for the reader have been deleted from this script (without consultation) by a third party,
and replaced with type hints for the compiler.
 
Type hints are interesting, and can be useful in larger Python projects, though it's unclear whether they really earn their keep in small scripts.
 
What is clear is that these type hints are noisier, and less informative, than the comments for the reader which were unilaterally deleted here, and which served a different purpose.
 
See the discussion page.
<lang python>'''Practical numbers'''
 
Line 255 ⟶ 248:
))
 
# Note: Although mypy compliant, type Any below could be improved.
# The real underlying type of this function happens to be
# more concealed than revealed by the compiler type hint.
#
# It actually returns a Bool, and its second argument
# is an Int.
#
# The follow comment on type semantics was orginally attached,
# but was angrily removed by a serial "discourager" of
# rival approaches :-)
#
# sumOfAnySubset :: [Int] -> Int -> Bool
 
 
def sumOfAnySubset(xs: List[int]) -> Callable[[Any], Any]:
Anonymous user