Practical numbers: Difference between revisions

Content added Content deleted
(→‎Composition of pure functions: Explained the semantic type of the central function, which is concealed by the compiler hint.)
Line 254: Line 254:
range(1, n)
range(1, n)
))
))

# 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




Line 369: Line 381:




def until(p:bool) -> Any:
def until(p: bool) -> Any:
'''The result of repeatedly applying f until p holds.
'''The result of repeatedly applying f until p holds.
The initial seed value is x.
The initial seed value is x.
Line 403: Line 415:
# MAIN ---
# MAIN ---
if __name__ == '__main__':
if __name__ == '__main__':
main()</lang>
main()
</lang>


{{Out}}
{{Out}}