Inconsistency when using previously defined variables as arguments to functions
Subject: Inconsistency when using previously defined variables as arguments to functions
From: Richard Fateman
Date: Wed, 26 Jan 2011 09:10:36 -0800
On 1/26/2011 8:52 AM, Stavros Macrakis wrote:
> You would write
>
> sum(lambda([n],sum(lambda([k], k),1,n)),1, m)
>
> But the traditional lambda syntax is clumsy and obscure to
> non-computer-scientists.
you could write function[k]:k if that would make people happier.
> Maybe it's as easy as defining a nicer
> syntax, e.g.
>
> sum( sum( k // k, 1:n ) // n, 1:m )
>
> But then what do you do when you *do* want to define a function like
> sum_over (expr, varlist)? Do you define yet another syntax for
> syntactic lambda-construction? Do you use subst or buildq (yuck)? I
> suppose that at least moves the complexity to an 'expert' level.
even if you changed sum(lambda([k],k),1,n) to return lambda([n],
(n+n^2)/2) you would not
be able to do the same with sum(lambda[k],k),n,m). You would need to
respond with
something like lambda([n,m] ....).
People writing code in idiomatic Scheme might be more comfortable with
such stuff, but
the typical applied-math user would probably be uncomfortable with
explicit functional notation.
For what it is worth, much
of the practical applied math books etc are jumbles of mismatched
notation, but an expert
has sufficient context so that he/she not only is comfortable, but
doesn't even notice the subtle
ambiguity. This is noticeable if you try to write a formal recognition
program (i.e. for
typeset math formulas in books).
You also probably want a summation notation that allows sum over
1<=i,j<=n, i /= j, or over
sets like odd(i).
RJF