MathGroup Archive 2005

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

Search the Archive

Re: Types in Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg62203] Re: Types in Mathematica
  • From: "Steven T. Hatton" <hattons at globalsymmetry.com>
  • Date: Mon, 14 Nov 2005 03:05:04 -0500 (EST)
  • References: <200511120833.DAA19252@smc.vnet.net> <43762529.7060603@math.umass.edu> <dl8s4g$n41$1@smc.vnet.net> <dl980q$r2a$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

John Doty wrote:

> Steven T. Hatton wrote:
>> and that makes it an integer.
> 
> FORGET CC++. You will *never* understand Mathematica by analogy with C++.

Yes, but contrast may be useful.  

Ironically, I spent several years occasionally visiting Mathematica, and
never really understood it until I spent a little over a year studying C++
very intensely.  I also read a good part of the _GNU Emacs Lisp Reference
Manual_ in that period.  When I returned to Mathematica, everything started
to fall into place.
 
> Mathematica's more like sed than C++: it works by recognizing patterns
> in input and replacing them.

I would say it's like a combination of sed and Lisp.
 
> a=1;
> 
> simply means whenever you see "a", replace it with "1". That's all. No
> type.

But there is IntegerQ.
 
>> 
>> You can reassign to that variable an change the type bound to it.  In
>> that sense Mathematica seems more like Lisp.
> 
> Mathematica has, in general, no idea what a variable is. "a" is a
> Symbol. It might be a variable, it might be something else. For specific
> tthings like Integrate, you get to designate particular Symbols as
> variables (using the meaning of the word "variable" in mathematics,
> *not* computer science).

One can view all symbols in Mathematica as variables in the sense of
computer science.  The Mathematica Book says:

"All expressions in Mathematica are ultimately made up from a small number
of basic or atomic types of objects.

These objects have heads which are symbols that can be thought of as
\[OpenCurlyDoubleQuote]tagging\[CloseCurlyDoubleQuote] their types. The
objects contain \[OpenCurlyDoubleQuote]raw data\[CloseCurlyDoubleQuote],
which can usually be accessed only by functions specific to the particular
type of object. You can extract the head of the object using Head, but you
cannot directly extract any of its other parts."
 
>>  I guess I can do something like
>> 
>> BooleanQ[b_]:= b==True||b==False||Head[b]==Boolean
>> 
>> I'll admit, that really isn't something that has a C++ counterpart.
> 
> FORGET C++.

Why?  Just because Mathematica doesn't behave like C++, doesn't mean there
is no value in comparing the two languages.  I find that C++ templates and
template metaprogramming "feel" a lot like Mathematica, and there are some
other aspects of C++ which have analogs in Mathematica.  There is even:

" The Boost Lambda Library (BLL in the sequel) is a C++ template library,
which implements [a] form of lambda abstractions for C++. The term
originates from functional programming and lambda calculus, where a lambda
abstraction defines an unnamed function. The primary motivation for the BLL
is to provide flexible and convenient means to define unnamed function
objects for STL algorithms."

  
>> I may be mistaken, but I believe 5.2 comes with an independent indexing
>> facility which acts something like htdig.  I have the usual helpbrowser
>> index functionality, but I don't believe that provides a full text
>> search.
> 
> Stop trying to make Mathematica behave like tools you know. Use it on
> its own terms: in its domain it's better than anything you know.
> 
> -jpd

http://www.wolfram.com/products/mathematica/newin52/desktopsearch.html
-- 
The Mathematica Wiki: http://www.mathematica-users.org/
Math for Comp Sci http://www.ifi.unizh.ch/math/bmwcs/master.html
Math for the WWW: http://www.w3.org/Math/


  • Prev by Date: MathTensor notational form
  • Next by Date: Re: Defining variables in $UserBaseDirectory/init.m
  • Previous by thread: Re: Types in Mathematica
  • Next by thread: Re: Re: Types in Mathematica