Skip to content
Minsing Log
Go back

English Edition

list comprehension in functional style

Programming & CS

Situation

Previously, I had only seen nested for loops in list comprehensions used to create two-dimensional lists.

However, I recently came across a nested for loop that passes the elements contained in a list to a function and stores the return values in a list. I thought list comprehensions were quite interesting.

exist_metrics = [modified_metric_name
                         for metric_name in ragas_metric_names
                         for modified_metric_name in text_modifier(metric_name)
                         if modified_metric_name in self.metrics]

Follow the journey

Get new posts by email.

Short, honest notes on building, startups, learning, failures, and retrospectives, for readers who follow the journey rather than pass through from search.

The newsletter is coming soon. Until then, follow via RSS or email me to get notified.


Share this post:

Comments

Sign in with GitHub to leave a comment.


Previous Post
What Are Synchronous and Asynchronous?
Next Post
When should you use static methods?