Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Types in Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg62186] Re: [mg62152] Types in Mathematica
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Sun, 13 Nov 2005 21:16:31 -0500 (EST)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200511120833.DAA19252@smc.vnet.net> <43762529.7060603@math.umass.edu> <200511122243.04368.hattons@globalsymmetry.com>
  • Reply-to: murray at math.umass.edu
  • Sender: owner-wri-mathgroup at wolfram.com

First, the general issue:  My experience with Mathematica is that I 
simply don't need typing as much as I did when when I was programming in 
a strictly procedural language -- because I try to use meaningful names 
throughout and just don't have as much trouble passing arguments between 
various subsidiary functions.  (Maybe things are helped by Mathematica's 
  expressive combination of functional programming, pattern-matching, 
and array-handling.)

Second, the particulars:

As to being of "type" Boolean: I don't think there is any Head of 
Boolean built-in to Mathematica, that is, as a primitive, so that part 
of your definiton of BooleanQ does not seem to be needed.

As to VectorQ: As I recall, I showed it in the form VectorQ[expr, test]. 
  But you can also use it in its simpler form VectorQ[expr].  As the 
documentation about the later says, "VectorQ[expr] gives True if expr is 
a list or a one-dimensional SparseArray object, none of whose elements 
are themselves lists, and gives False otherwise. VectorQ[expr, test] 
gives True only if test yields True when applied to each of the elements 
in expr."

As to search: You must be referring to the Wolfram Notebook Indexer, 
which was available separately for download from www.wolfram.com but 
which was then shipped with Mathematica 5.2.  It can be used as a 
plug-in for Google Desktop Search (as well as Apple Spotlight and 
Windows Desktop Search).  Google says it's considering making its 
Desktop Search available for Linux, although they don't have it now. 
Perhaps if enough Linux users pester them (politely), they'll create that.

But you can, as I originally said, still use the indexing within the 
Mathematica HelpBrowser to do searching of the HelpBrowser notebooks (only).

Steven T. Hatton wrote:
> On Saturday 12 November 2005 12:23 pm, Murray Eisenberg wrote:
> 
>>Every function you write can be made to type its variables.  E.g.,
>>
>>   f[x_?NumberQ] := x^2
>>
>>   g[lis_List] := Most[lis]
>>
>>   normalize[v_ /; VectorQ[v, NumberQ]] := v/Norm[v]
>>
>>use: the built-in NumberQ function to test a property of the input x,
>>and the pattern test for having a head of List, respectively.
> 
> 
> Looking at the builtin types is what got me thinking about this topic.  I 
> wanted a type Boolean for variables and boolean values.  It seems that in 
> Mathematica, a variable, in and of itself, does not really have a type in the 
> sense of c++.  That is, you don't say 
> 
> Integer a=1;  
> 
> You just say 
> 
> a=1; 
> 
> and that makes it an integer.
> 
> You can reassign to that variable an change the type bound to it.  In that 
> sense Mathematica seems more like Lisp.  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.
> 
> 
> One thing about your example of VectorQ is that it requires the members of the 
> List to be Number types.  What happens if they are functions which will 
> evaluate to numbers?
> 
> 
>>Sections 2.3.4 and 2.3.5 of The Mathematica Book are two places to find
>>this subject discussed.
> 
> 
> This is not the discussion I had in mind.  Somewhere there is an example of 
> creating an expression with a head Vector, and using the head of the 
> expression as a "type".
> 
> 
>>I don't understand why you don't have access to search in your Linux
>>installation: Whenever I've installed in Linux and selected to install
>>the documentation, the usual HelpBrowser becomes available, including
>>its search capability.
> 
> 
> 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.
> 
> Steven
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Re: Re: Types in Mathematica
  • Next by Date: Re: mathcode
  • Previous by thread: Re: Re: Types in Mathematica
  • Next by thread: Re: Types in Mathematica