From: rusty craine
Subject: function, #', ' and lambda sans '
Date: 
Message-ID: <71ajm3$ec2$1@excalibur.flash.net>
I don't use common lisp but try to follow most of the examples in the news
group.  One (well maybe several) point confuses me.  That is lambda
functions interanal to a defun.
(defun something (...)
....
(lambda function ......)
.....)

Sometimes I see (lambda function.....) as  #'(lambda function......)
sometimes i see (lambda function......) with no quote as  (lambda
function.....)
sometimes i see (lambda function......) as  '(lambda function.......)

_common lispcraft_ says...function, #', and ' are the same (mostly)

To get lambda functions to run in mulisp i always have to quote them _ever
time_.  to add to my confusion mulisp doesn't support... function or #'  and
will never run a lambda function without a quote but.... i have yet to find
a lambda function that it would not run with just a quote that is no #' or
function.
OK I understand why a lambda function has to be quoted (i think).  I don't
understand why a lambda function runs without being quoted and i don't
understand how quote and #' differ.  Is there a site ya can point me to that
would clear some of the fog?

fog is not an unusual state for me
rusty

From: Barry Margolin
Subject: Re: function, #', ' and lambda sans '
Date: 
Message-ID: <I95_1.25$YF4.432947@burlma1-snr1.gtei.net>
In article <············@excalibur.flash.net>,
rusty craine <········@flash.net> wrote:
>I don't use common lisp but try to follow most of the examples in the news
>group.  One (well maybe several) point confuses me.  That is lambda
>functions interanal to a defun.
>(defun something (...)
>....
>(lambda function ......)
>.....)
>
>Sometimes I see (lambda function.....) as  #'(lambda function......)

This is what CLtL1 originally specified.

>sometimes i see (lambda function......) with no quote as  (lambda
>function.....)

ANSI CL specifies a LAMBDA macro that expands into (function (lambda ...)),
so that you can leave out the #'.

>sometimes i see (lambda function......) as  '(lambda function.......)

CLtL1 allowed this, but it's not permitted by ANSI CL.  Even when it was
allowed, it was generally preferable to avoid it.  Functions used this way
do not capture their lexical context, and they're generally not compiled
either.  I think they were originally included in the language for Maclisp
compatibility.

>_common lispcraft_ says...function, #', and ' are the same (mostly)

#'... is a reader macro that expands into (function ...), so they are the
same.  If the function doesn't make any free references to lexical
variables, '(lambda ...) will work as well in a CLtL1-compatible Lisp.

>To get lambda functions to run in mulisp i always have to quote them _ever
>time_.  to add to my confusion mulisp doesn't support... function or #'  and
>will never run a lambda function without a quote but.... i have yet to find
>a lambda function that it would not run with just a quote that is no #' or
>function.

It doesn't sound like this is a Common Lisp implementation.  #' is mostly
necessary in Lisps that have lexical scoping, and I'll bet mulisp is
dynamically scoped.

>OK I understand why a lambda function has to be quoted (i think).  I don't
>understand why a lambda function runs without being quoted and i don't
>understand how quote and #' differ.  Is there a site ya can point me to that
>would clear some of the fog?

The FUNCTION special form, which is what #' expands into, is used to create
a lexical closure that captures variable bindings at the time that the
function is being created.  If you use a normal quote, all you have is
plain list structure, which will be evaluated when the function is called.
It won't include any information about the lexical environment at the time
the function was created.

Here's an example that shows the difference (it takes advantage of the fact
that most CL implementations have retained as an extension the ability to
call quoted lambda expressions):

(setf (symbol-value 'x) 0)

(let ((x 1))
  (let ((fun1 #'(lambda () (format t "~&With #': ~D~%" x)))
        (fun2 '(lambda () (format t "~&With ': ~D~%" x))))
    (funcall fun1)
    (funcall fun2)))

This will print:

With #': 1
With ': 0

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Don't bother cc'ing followups to me.
From: rusty craine
Subject: Re: function, #', ' and lambda sans '
Date: 
Message-ID: <71atva$k08$1@excalibur.flash.net>
Barry Margolin wrote in message ...
>In article <············@excalibur.flash.net>,
> Barry Wrote...
[snip]

>Here's an example that shows the difference (it takes advantage of the fact
>that most CL implementations have retained as an extension the ability to
>call quoted lambda expressions):
>

Kind Sir you do indeed have the power of explaination and have it well.
The lisping folks i know come in 3 type 1] user/programmer (i'm one)
2]computer science programmer 3] complier programmer.  Lisp lends itself so
readily to the user/programmer, it is a shame that most of the literature i
have found is greared to AI (please nothing wrong with that, but they
generaly solve more difficult problems then the average joe).  Did you ever
think of writting a book for a user/programmer.  Lets say a PhD
psychologist, pharmacist, anesthesiologist (they use lots of interesting
computer stuff), engineer,  in general a non-computer science scientist.  If
ya do i'll take 10 copies.
many thanks
rusty

>(setf (symbol-value 'x) 0)
>
>(let ((x 1))
>  (let ((fun1 #'(lambda () (format t "~&With #': ~D~%" x)))
>        (fun2 '(lambda () (format t "~&With ': ~D~%" x))))
>    (funcall fun1)
>    (funcall fun2)))
>
>This will print:
>
>With #': 1
>With ': 0
>
>--
>Barry Margolin, ······@bbnplanet.com
>GTE Internetworking, Powered by BBN, Burlington, MA
>*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
>Don't bother cc'ing followups to me.
From: rusty craine
Subject: Re: function, #', ' and lambda sans '
Date: 
Message-ID: <71b61i$l1l$1@excalibur.flash.net>
rusty craine wrote in message <············@excalibur.flash.net>...
>
............................................................................
......Did you ever
>think of writting a book for a user/programmer.  Lets say a PhD
>psychologist, pharmacist, anesthesiologist (they use lots of interesting
>computer stuff), engineer,  in general a non-computer science scientist.
If
>ya do i'll take 10 copies.


Looking at my lisp directory i'll give ya the outline (well chapters)
1. evaluation of lisp testing floating point, sin and cos
2. random numbers and test of random function
3. simultaneous solutions of linear eqautions
4 curve-fitting program
5.mean and standard deviation
6.vector and matirx operations
7. date calculations
8. sorting
9. general least-squares curve fitting
10. nonlinear curve-fitting equations
11.solution of equations by newton's method
;;;and maybe something like
12. gaussian error functions
13. hit the engineers don't remmember much of that ??bessel functions

i guess i would put it in a little better order, but geeez now all ya got to
do is wrap a little lisp around it :).

rusty
From: David B. Lamkins
Subject: CL Math Routines (was Re: function, #', ' and lambda sans ')
Date: 
Message-ID: <pta_1.2941$bY1.1871257@news.teleport.com>
In article <············@excalibur.flash.net> , "rusty craine"
<········@flash.net> wrote:

>
>rusty craine wrote in message <············@excalibur.flash.net>...
>>
>............................................................................
>......Did you ever
>>think of writting a book for a user/programmer.  Lets say a PhD
>>psychologist, pharmacist, anesthesiologist (they use lots of interesting
>>computer stuff), engineer,  in general a non-computer science scientist.
>If
>>ya do i'll take 10 copies.
>
>
>Looking at my lisp directory i'll give ya the outline (well chapters)
>1. evaluation of lisp testing floating point, sin and cos
>2. random numbers and test of random function
>3. simultaneous solutions of linear eqautions
>4 curve-fitting program
>5.mean and standard deviation
>6.vector and matirx operations
>7. date calculations
>8. sorting
>9. general least-squares curve fitting
>10. nonlinear curve-fitting equations
>11.solution of equations by newton's method
>;;;and maybe something like
>12. gaussian error functions
>13. hit the engineers don't remmember much of that ??bessel functions
>
>i guess i would put it in a little better order, but geeez now all ya got to
>do is wrap a little lisp around it :).
>
>rusty
>
>

A lot of this already exists.  MIT AI Memo 774, dated 1984-09-27, "Some
Scientific Subroutines in Lisp" by Gerald Roylance, describes an extensive
math library.  I've seen code on the net, but can't find it just now.



---
David B. Lamkins <http://www.teleport.com/~dlamkins/>
From: rusty craine
Subject: Re: CL Math Routines (was Re: function, #', ' and lambda sans ')
Date: 
Message-ID: <71bh57$50r$1@excalibur.flash.net>
David B. Lamkins wrote in message ...
>In article <············@excalibur.flash.net> , "rusty craine"
><········@flash.net> wrote:
>
>>
>>rusty craine wrote in message <············@excalibur.flash.net>...
>>>
>>..........................................................................
..
>>......Did you ever
>>>think of writting a book for a user/programmer.  Lets say a PhD
>>>psychologist, pharmacist, anesthesiologist (they use lots of interesting
>>>computer stuff), engineer,  in general a non-computer science scientist.
>>If
>
>A lot of this already exists.  MIT AI Memo 774, dated 1984-09-27, "Some
>Scientific Subroutines in Lisp" by Gerald Roylance, describes an extensive
>math library.  I've seen code on the net, but can't find it just now.

Well that is kinda my point (but thinks for the tip).  If I recommend lisp
to one of my peers, then hand over 7 or 8 pages of "muture" lisp programming
I'm not sure I helped the issue much.  I do not think lisp is the easiest
language (that is lisp-like porgramming) to pick up on your on.  I have been
using lisp for several years but have learned more in the few months in this
new group about lisp-like programming then I had picked in the rest of those
years.  If you use _Numerical Recipes_ as a source and don't have a lisp
community around...your lisp looks a lot like fortran (of course i think
that says alot for lisp).

At one time not too long ago if you walked into a lab there would be a pc
with bascia up and running.  Most of the programs written on the compture
were less the 2 to 3 hundred lines; well i guess really little more than a
very algorithm dedicated calculators.  Now that those quick and easy
intepreted languages have been taken over with visual basic etc seems like a
good niche for a interactive lisp... if the "how to" literature was
available.

rusty

>
>
>
>---
>David B. Lamkins <http://www.teleport.com/~dlamkins/>
From: Reginald S. Perry
Subject: Re: CL Math Routines (was Re: function, #', ' and lambda sans ')
Date: 
Message-ID: <sxl7lxh961z.fsf@yakko.zso.dec.com>
>"David" == David B Lamkins <········@teleport.com> writes:

> A lot of this already exists.  MIT AI Memo 774, dated 1984-09-27,
> "Some Scientific Subroutines in Lisp" by Gerald Roylance, describes
> an extensive math library.  I've seen code on the net, but can't
> find it just now.

No problemo. Its in the AI repository.

http://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/lisp/code/math/clmath/0.html


-Reggie
From: Lyle Borg-Graham
Subject: Re: CL Math Routines (was Re: function, #', ' and lambda sans ')
Date: 
Message-ID: <363DF00A.794BDF32@cogni.iaf.cnrs-gif.fr>
David B. Lamkins wrote:
> 
> 
> A lot of this already exists.  MIT AI Memo 774, dated 1984-09-27, "Some
> Scientific Subroutines in Lisp" by Gerald Roylance, describes an extensive
> math library.  I've seen code on the net, but can't find it just now.
> 
> ---
> David B. Lamkins <http://www.teleport.com/~dlamkins/>

-- 

> http://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/lisp/code/math/clmath/d�0

............................................................
                              
                      Lyle Borg-Graham
    Equipe Cognisciences, Institut Alfred Fessard, CNRS
                    91198 Gif-sur-Yvette
                           FRANCE
 tel: (33 1) 69 82 34 13           fax: (33 1) 69 82 34 27

                                                                _ o
                                                               / /
                                           .    .   .  . . . _ _/|
From: Lyle Borg-Graham
Subject: Re: CL Math Routines (was Re: function, #', ' and lambda sans ')
Date: 
Message-ID: <363DF094.15FB7483@cogni.iaf.cnrs-gif.fr>
Sorry, munged the URL

> David B. Lamkins wrote:
> >
> >
> > A lot of this already exists.  MIT AI Memo 774, dated 1984-09-27, "Some
> > Scientific Subroutines in Lisp" by Gerald Roylance, describes an extensive
> > math library.  I've seen code on the net, but can't find it just now.
> >
> > ---
> > David B. Lamkins <http://www.teleport.com/~dlamkins/>
> 
> --
> 
> > http://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/lisp/code/math/clmath/
From: Steven D. Majewski
Subject: Re: function, #', ' and lambda sans '
Date: 
Message-ID: <71cojd$pvk$1@murdoch.acc.Virginia.EDU>
You should take a look at XlispStat: 
  http://www.stat.umn.edu/~luke/xls/xlsinfo/xlsinfo.html
  http://www/xlispstat.org/
  http://www.stat.ucla.edu/develop/lisp/xlisp/xlisp-stat/ 
et.al.

XlispStat is a statistical package written ontop of an "enhanced"
version of Xlisp by Luke Tierney. Some of those enhancements include
simple object-oriented graphics, and Lisp callable hooks to vector,
matrix & BLAS functions written in C. There are linerar and non-linear
regression models and lots of other mathematical and statistical
functions included. 

Luke's book, published by Wiley-Interscience, although having rather
different chapter headings, covers much of the material on your wish
list. An online HTML (and postscript) version of a portion of that
book ( chapter 2 and some of the appendix material ) is available
from that first web site. 

See:
<http://www.stat.umn.edu/~luke/xls/tutorial/techreport/techreport.html>



A quick example below plots a series of points (1..29) +/- a random
number, does a linear regression on the points and adds the computed
regression line to the plot:



> ( setf x ( iseq 30 ))
(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
27 28 29)
> ( setf y ( + x (normal-rand 30)))
(-0.4662509912067259 -0.7767208547391651 2.878434873460745
2.544817825094027 5.458711253491559 5.36918544752503      [ ... edited ... ]
26.765809084331224 27.965867500574788 28.827356148075104)
> ( setf p ( plot-points x y ))
#<Object: 1803978, prototype = SCATTERPLOT-PROTO>
> ( setf r ( regression-model (list y) x ))

Least Squares Estimates:

Constant                  0.244553      (0.426293)
Variable 0                0.987114      (2.529333E-2)

R Squared:                0.981948    
Sigma hat:                 1.20374    
Number of cases:                30
Degrees of freedom:             28

#<Object: 1913fb8, prototype = REGRESSION-MODEL-PROTO>
> ( let (( c ( send r :coef-estimates )))
    ( send p :add-lines x ( + (first c) (* (second c) x)) 
           :color 'red :width 2 ))


---|  Steven D. Majewski   (804-982-0831)  <·····@Virginia.EDU>  |---
---|  Department of Molecular Physiology and Biological Physics  |---
---|  University of Virginia             Health Sciences Center  |---
---|  P.O. Box 10011            Charlottesville, VA  22906-0011  |---
"I'm not as big a fool as I used to be, I'm a smaller fool." - Jack Kerouac
Some of the Dharma  <http://members.aol.com/kerouacsis/SomeDharma.html>



In article <············@excalibur.flash.net>,
rusty craine <········@flash.net> wrote:
>
>rusty craine wrote in message <············@excalibur.flash.net>...
>>
>............................................................................
>......Did you ever
>>think of writting a book for a user/programmer.  Lets say a PhD
>>psychologist, pharmacist, anesthesiologist (they use lots of interesting
>>computer stuff), engineer,  in general a non-computer science scientist.
>If
>>ya do i'll take 10 copies.
>
>
>Looking at my lisp directory i'll give ya the outline (well chapters)
>1. evaluation of lisp testing floating point, sin and cos
>2. random numbers and test of random function
>3. simultaneous solutions of linear eqautions
>4 curve-fitting program
>5.mean and standard deviation
>6.vector and matirx operations
>7. date calculations
>8. sorting
>9. general least-squares curve fitting
>10. nonlinear curve-fitting equations
>11.solution of equations by newton's method
>;;;and maybe something like
>12. gaussian error functions
>13. hit the engineers don't remmember much of that ??bessel functions
>
>i guess i would put it in a little better order, but geeez now all ya got to
>do is wrap a little lisp around it :).
>