Mathematica: 'Through' is your more functional friend.

Webel IT Australia promotes the amazing Mathematica tool and the powerful Wolfram Language and offers professional Mathematica services for computational computing and data analysis. Our Mathematica tips, issue tracking, and wishlist is offered here most constructively to help improve the tool and language and support the Mathematica user community.
DISCLAIMER: Wolfram Research does not officially endorse analysis by Webel IT Australia.
Icon class
icon_class
far fa-sticky-note
icon_class_computed
far fa-sticky-note
Note kind
Keywords

The Through command is definitely worth knowing about. When you have an expression you'd like to apply more than one function to (not nested/chained, just one after the other), Through is your friend.

Let's say you have an expression, but you want to avoid using a holding variable (because you are nice and DRY) just so that you can use it as the target of more than one function. Through to the rescue:


Through[{f1,f2}][expr]

{f1[expr], f2[expr]}

Here, expression could be a long String, and f1 and f2 could be different Print formatting wrappers that send the String to different targets, such a your main notebook and the Messages console (in which case you'd just discard the output of Through).

Sometimes the List output of Through is what you want.

Relates to
Related notes
Related notes (backlinks)
Related snippets (extracts)
Visit also
Visit also (backlinks)
External links