Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.1K Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Apply a list of functions on an element

Posted 2 years ago

I want to find a quick way to create the expression

{Cos[a],Sin[a]}

instead of typing it explicitly.

What I use now is

({Cos[#], Sin[#]} & /@ {a})[[1]]

Is there any shorter way to do it?

I don't see any reason for the a to be part of a list.

POSTED BY: Ehud Behar
3 Replies

You can try

AngleVector[a]
POSTED BY: Gianluca Gorni
Posted 2 years ago

Another form would be:

#[a] & /@ {Cos, Sin}

(* {Cos[a], Sin[a]} *)

What you're looking for is probably the following:

Through[{Cos, Sin}[a]]

(* {Cos[a], Sin[a]} *)

You can accomplish the above, by the way, with AngleVector[a].

Note that there are some other shorthand forms for these kind of things, at least MinMax, ReIm and AbsArg.

POSTED BY: Jari Kirma
Posted 2 years ago

Thanks very much! This is very helpful

POSTED BY: Ehud Behar
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard