MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Programming style: postfix/prefix vs. functional

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70642] Re: Programming style: postfix/prefix vs. functional
  • From: "dimitris" <dimmechan at yahoo.com>
  • Date: Sun, 22 Oct 2006 01:19:13 -0400 (EDT)
  • References: <eha5kn$b82$1@smc.vnet.net>

One other postfix notation you could use is @@@

lst=Table[Random[Integer,{0,10}],{5},{5}]
{{9,4,1,9,9},{0,0,1,1,2},{10,5,7,0,2},{1,9,3,8,2},{3,8,3,9,10}}

Apply[Plus,lst]
Plus@@lst
{23,26,15,27,25}
{23,26,15,27,25}

Apply[Plus,lst,{1}]
Plus@@@lst
{32,4,24,23,33}
{32,4,24,23,33}

Regards
Dimitris

Will Robertson wrote:
> Hello,
>
> As a newcomer to Mathematica, I'm a little unsure on what "good style"
> would be in this programming language. I notice that several functions
> have prefix and postfix notations such as //. for ReplaceRepeated, /@
> for Map, and so on.
>
> Clearly using these forms makes the code more compact, but sacrifices
> some level of readability. Are there guidelines or suggestions that
> have built up over the years of whether these are "good" or "bad" to
> use?
>
> If it's simply personal preference, what do you like to use?
> --
> Many thanks,
> Will Robertson


  • Prev by Date: Re: file question
  • Next by Date: Re: Wolfram Workbench
  • Previous by thread: RE: Programming style: postfix/prefix vs. functional
  • Next by thread: Re: Re: Programming style: postfix/prefix vs. functional