MathGroup Archive 2009

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

Search the Archive

Re: New free introductory book on Mathematica programming, and a

  • To: mathgroup at smc.vnet.net
  • Subject: [mg96403] Re: New free introductory book on Mathematica programming, and a
  • From: dh <dh at metrohm.com>
  • Date: Fri, 13 Feb 2009 03:40:16 -0500 (EST)
  • References: <gn11ht$834$1@smc.vnet.net>


Hi Leonid,

I am just reading through your book. Thanks a lot for your contribution.

Let me point out what I think is a small error. On page 189, concerning 

the Hold attribute of functions. The sentence:

"We see that now the evaluation order  has changed : first the function 

< f > was evaluated,  and then the value of   < a > was  substituted"

A held argument is substituted in the body of the function. But the body 

is then normally evaluated. That means as soon as the held attribute is 

encountered, it is replaced by its value. Here is an example:



f[x_] := (

    t = x^2;

    t = t + 1

    );

SetAttributes[f, HoldAll];

a = 4;

f[q] // Trace



regards, Daniel



Leonid Shifrin wrote:

> Dear Group,

> 

> This is my first post here, although I have been

> a long-term Mathematica user. My field is (more correctly,

> was until recently) Theoretical and Mathematical Physics.

> 

> 

> I have been using Mathematica for about 12 years now,

> but only the last 4 as a programmer. Being a Mathematica

> enthusiast, I have written an introductory book (well, a

> first part of it) on Mathematica programming based on my

> own experiences and my compilation of existing literature,

> as an expansion of notes-to-self. The motivation was to

> minimize frustration of learning Mathematica programming for

> someone like myself 4 years ago.

> 

> My experience is that, for a beginner, it is easiest to learn

> Mathematica (programming) when it is illustrated with many simple

> examples and is as much separated from any field-specific

> application as possible. This is what I tried to do in the

> book.

> 

> What I had in mind was a pure programming book about Mathematica

> language, with no reference to any specific field-related

> functionality, with lots of examples being small but complete

> projects, less comprehensive than Mathematica book but containing more

> substantial programs, easier to read than Roman Maeder's books

> (but by no means a substitute), more applied than David Wagner's

> (apart from the fact that it is out of print), going a little deeper into

> the language core and being somewhat more pragmatic than

> Paul Wellin et al (please don't get me wrong - these are all excellent

> books), and centered around functional programming layer, main

> higher-order functions, idiomatic Mathematica programming and

> efficiency.

> 

> An ideal reader for it would be a person who has some Mathematica

> experience as a user, needs to write programs more substantial

> than a few one-liners, and wants to understand the logic of the

> language and ways to program idiomatically, minimize programming

> effort and maximize program's efficiency. Parts of the book

> (chapters 1-4) can also be useful for more occasional Mathematica

>  users, and the last chapter may be of some interest to more

> experienced users as well.

> 

> 

> I much hope that the book will be not completely useless  and

> that I will get some feedback which will help me improve it.  If you think

> that some material is described inaccurately, or missing, or unnecessary,

> or whatever, please let me know!

> 

> The book is available for free from my web site,

> 

> <http://www.mathprogramming-intro.org>,

> 

> and is published under Creative Commons Non-commercial

> share-alike License. It is possible to read it online or

> download a pdf version.

> 

> 

> Apart from the book, I have made several tools that I use

>  myself and that I believe could be of interest to

> some Mathematica users. I plan to sumbit them to MathSource

> soon, but will appreciate any feedback even before that,

> while they are in "alpha".

> 

> All packages are accompanied by Mathematica notebooks with

> numerous examples of use and explanations of all package's

> features. They have been all tested with v.5.2 and 6.0,

> although perhaps my test suits were too thin. The following

> packages are currently freely available  from the same web site,

> <http://www.mathprogramming-intro.org/additional_resources.html>:

> 

> *******************************************************************************************

> 

> - Cache

> 

>     Creates a cached version of a given function and

>     fetches results of frequent function calls  from cache

>     of a fixed user-defined size. Slower than f[x_]:=f[x]=...

>     idiom, but you control the size of DownValues list. Can

>     be useful for functions which are at least minimally

>     computationally demanding, in unattended computations.

> 

> 

> - UnsortedOperations

> 

>     Reasonably fast functions to do various manipulations

>     with several lists without sorting, such as mapping

>     a function on elements of one list being members of

>     another one, unsorted Union, Intersection, Complement,

>     etc. This package is an expansion of the last case

>     study in the last chapter of the book.

> 

> - AttributesOfPureFunctions

> 

>     Produces new pure functions at run-time, with the

>     desired sets of attributes but otherwise the same as

>     the original ones. Can also "wrap" the "normal"

>     (DownValue-based) function into a pure function wrapper,

>     with the pure function sharing with the original all

>     Attributes that make sense for pure functions.

> 

> - CheckOptions

> 

>     For any user-defined (or modified) DownValue-based

>     option-taking function, which uses the ___?OptionQ to

>     declare options, adds new definitions that check

>     options for validity (not just the option name, but

>     also the option's rhs) and can execute arbitrary user-

>     defined code upon receiving inappropriate option(s) (such

>     as returning $Failed, Throw-ing an exception, etc).

>     The limitations are discussed in :Discussion:

>     section of the package documentation.

> 

> 

> 

> - PackageOptionChecks

> 

>     Elevates the functionality of  CheckOptions to the level

>     of the package(context), while retains the control on

>     the level of individual functions as well. Adds an

>     easy-to use interface to "protect" package's functions

>     from inappropriate options. Can work from within the

>     package of interest, or "externally" (in the latter case

>     no code modifications for the package itself are needed).

>     Can be also used for Global` context during interactive

>     development (before putting functions into a package).

>     Essentially, allows to "meta-program" the package by

>     specifying the response actions for each function after

>     (and independently) of the main function's code, and

>     gives the user external control over this responding

>     behavior. Can also be used as a debugging tool.

>     Limitations are discussed in the :Discussion: section of

>     the package documentation.

> 

> 

> - PackageManipulations

> 

>     Allows to dynamically reload, clear or remove the

>     package's context in a way consistent with general

>     package mechanics in Mathematica. Useful for interactive

>     package development, especially for larger projects with

>     many inter-dependent packages. Dynamic re-loader tracks

>     escaping symbols and (optionally) can automatically

>     resolve possible shadowing problems occuring before or

>     during re-loading.

> 

> 

> - PackageSymbolsDependencies

> 

> 

>     For a given package/context, answers the following

>     questions:

> 

>     1. Do there exist symbols in other contexts that

>     depend on symbols in a given one through some global

>     properties (DownValues etc)

>     2. If so, what they are

>     3. For a given arbitrary Mathematica expression, what

>     are the symbols used to build it, and their contexts

>     4. Whether or not a given symbol is shadowed

> 

>     The package is highly customizable, with its efficiency

>     depending mainly on how much we know about the set of

>     possibly dependent symbols. It can be used to analyze

>     inter-context dependencies in larger projects, and to

>     discover/monitor modifications that a given package

>     induces in other contexts (including overloading system

>     functions). This is also a good practical example of

>     <PackageOptionChecks> in action, since options here are

>     protected with PackageOptionChecks.

> 

> 

> *************************************************************************************

> 

> If you intend to use any of these, I will be happy, but  please read the

> disclaimer on my web site. If you find bugs in the packages or in the book,

> I will also greatly appreciate if you let me know - please see the

> <report_bug> section of my web site.

> 

> 

> Everybody thanks a lot for attention,

> and Best Regards!

> 

> 

> Leonid Shifrin

> 

> 




  • Prev by Date: Re: Logarithmic Plot
  • Next by Date: Re: New free introductory book on Mathematica programming, and a few
  • Previous by thread: Re: Superscript in text
  • Next by thread: Re: Re: New free introductory book on Mathematica