What learning APL taught me about Python
mathspp.com
What learning APL taught me about Python
1–10 of 104 posts
Re: What learning APL taught me about Python
#2Re: What learning APL taught me about Python
#3len(age for age in ages if age > 17)
Re: What learning APL taught me about Python
#4The only thing this does for me is ask why its not named count instead of sum.
Re: What learning APL taught me about Python
#5Also, Python is a wonderful functional language when used functionally.
Re: What learning APL taught me about Python
#6The only thing this does for me is ask why its not named count instead of sum.
Re: What learning APL taught me about Python
#7I know nothing about APL. But I think I would write it the same way as the OP. I also think use len is better to convey counting operation: len(age for age in ages if age > 17)
Re: What learning APL taught me about Python
#8I know nothing about APL. But I think I would write it the same way as the OP. I also think use len is better to convey counting operation: len(age for age in ages if age > 17)
sum(1 for age in ages if age > 17)Re: What learning APL taught me about Python
#9I find that the more language you learn the better you can utilize all of them. Also, Python is a wonderful functional language when used functionally.
Re: What learning APL taught me about Python
#10I know nothing about APL. But I think I would write it the same way as the OP. I also think use len is better to convey counting operation: len(age for age in ages if age > 17)
I don’t think you can do that with a generator expression. You would have to write: sum(1 for age in ages if age > 17)