MathGroup Archive 2006

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

Search the Archive

Re: Re: Programming style: postfix/prefix vs. functional

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70704] Re: [mg70633] Re: [mg70587] Programming style: postfix/prefix vs. functional
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Mon, 23 Oct 2006 05:45:05 -0400 (EDT)
  • References: <200610200921.FAA11092@smc.vnet.net> <200610210914.FAA29189@smc.vnet.net> <2A8E209D-C4D9-45C1-933B-5E3D955D99C5@mimuw.edu.pl> <acbec1a40610210543k3a861eb7tb3bdb777170618b@mail.gmail.com> <2F11E8C9-D5C5-45EC-BA91-7F52E72CCC3B@mimuw.edu.pl> <acbec1a40610220224h4d154c37rd6b0d909820cfd19@mail.gmail.com>

It seems to me you are making to much of this "correspondence". Why  
does it matter whether something "corresponds" to a "function applied  
at some particular level" or is "just a shorthand" for some  
particular expression? In fact, I think this is what "parsing" is  
about: the "parser" reads your input and converts it (without  
evaluation) to another form which is semantically equivalent . (There  
is a subtle difference between this and "formatting", which affects  
only the visual output).

Andrzej Kozlowski



On 22 Oct 2006, at 18:24, Chris Chiasson wrote:

> On 10/21/06, Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote:
>> Well, I would say that f@x is just a "shorthand" for f[x] and does
>> not "correspond" to any function. It seems to me that same applies to
>> @@ and to @@@ ...
>
> But we know that @@ and @@@ correspond to Apply at level specification
> {0} and {1}, respectively. We also know that /@ and //@ correspond to
> Map at level specification {1} and {0,Infinity} (or just MapAll). It
> seems to me that @ is the odd one out, because it doesn't "correspond
> to a particular function".
>
> On 10/21/06, Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote:
>> (tm) Pro*
>> Well, I would say that f@x is just a "shorthand" for f[x] and does
>> not "correspond" to any function. It seems to me that same applies to
>> @@ and to @@@ and none of these cases ? will yield any information.
>> In fact, ? itself works in a curious way. Sometimes it corresponds to
>> the function Information; as in
>>
>> Information[Sin]
>>
>> which is the same as ?Sin. But in some cases, notably ?@ you can't
>> use Information; this
>> Information[@]  does not parse correctly (I think this is the right
>> way to use "parse" ;-)), in other words, it is not syntactically
>> correct. So ? seems actually work in two different ways: as another
>> way to input Information but also rather like the symbol ! in front
>> of a file name, which displays the contents of the file on the screen
>> and does not correspond to any Mathematica function.
>>
>> Andrzej Kozlowski
>>
>>
>> On 21 Oct 2006, at 21:43, Chris Chiasson wrote:
>>
>> > Andrzej Kozlowski,
>> >
>> > Thanks for the wildcard info!
>> >
>> > So, does @ correspond to Operate? I think Operate is a bit  
>> different
>> > than @, but I am not sure.
>> >
>> > On 10/21/06, Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote:
>> >> (tm) Pro*
>> >>
>> >> On 21 Oct 2006, at 18:14, Chris Chiasson wrote:
>> >>
>> >> > One thing I have wondered is, what function corresponds to the
>> >> short
>> >> > hand "@". I know @ appears in Operate. Also, the ? can sometimes
>> >> tell
>> >> > what function an operator represents (try ?/@ ) , but ?@ only  
>> gives
>> >> > System`$ (the symbol $ in the context System).
>> >>
>> >> That's because the symbol @ already has another meaning as a "wild
>> >> card":
>> >>
>> >> @ , one or more characters excluding upperâ??case letters
>> >>
>> >> (A more general wild card is, of course *). So ?@ returns all the
>> >> symbols defined in the  contexts  of the current session that  
>> do not
>> >> contain capital letters. Evaluate some symbols whose names contain
>> >> only small letter in Mathematica and try ?@ again to see this in
>> >> action.
>> >>
>> >> Andrzej Kozlowski
>> >>
>> >>
>> >> >
>> >> >
>> >> > On 10/20/06, Will Robertson <wspr81 at gmail.com> 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
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> > --
>> >> > http://chris.chiasson.name/
>> >> >
>> >>
>> >>
>> >
>> >
>> > --
>> > http://chris.chiasson.name/
>>
>>
>
>
> -- 
> http://chris.chiasson.name/


  • Prev by Date: Re: question ,,thankx!!!
  • Next by Date: Re: Strange newbie problem
  • Previous by thread: Re: Re: Programming style: postfix/prefix vs. functional
  • Next by thread: Re: Programming style: postfix/prefix vs. functional