Hi guyz,
I am trying to learn LISP by using PAIP, the Norvig text book.
Exercise 3.1, page 56: show a lambda expression that is equivalent to the
following let* expression:
(let* ((x 6)
(y (* x x)))
(+ x y)) ;; => 42
I came up with these two:
(setq *test*
((lambda (x)
(+ ((lambda (y)
(* y y))
x)
x)
) 6))
(setq *test2*
((lambda (x)
((lambda (x y)
(+ x y)) x (* x x))
) 6))
I am not sure if (one of) these solutions are the intended ones. Can someone
check this for me?
Gr,
Michiel
"Michiel Borkent" <·······@cs.utwente.nl> writes:
> I am trying to learn LISP by using PAIP, the Norvig text book.
Good choice.
> Exercise 3.1, page 56: show a lambda expression that is equivalent
> to the following let* expression:
>
> (let* ((x 6)
> (y (* x x)))
> (+ x y)) ;; => 42
>
> I came up with these two:
>
> (setq *test*
> ((lambda (x)
> (+ ((lambda (y)
> (* y y))
> x)
> x)
> ) 6))
>
> (setq *test2*
> ((lambda (x)
> ((lambda (x y)
> (+ x y)) x (* x x))
> ) 6))
>
> I am not sure if (one of) these solutions are the intended ones. Can
> someone check this for me?
Please indent better (look closely how Norvig indents).
Omit the silly SETQ and start with
((lambda (x)
((lambda (y)
...)
...))
6)
Regards,
--
Nils G�sche
"Don't ask for whom the <CTRL-G> tolls."
PGP key ID #xEEFBA4AF
In article <··············@darkstar.cartan.de>,
"=?iso-8859-1?q?Nils_G=F6sche?=" <···@cartan.de> wrote:
> "Michiel Borkent" <·······@cs.utwente.nl> writes:
>> I am trying to learn LISP by using PAIP, the Norvig text book.
> Good choice.
>
>> Exercise 3.1, page 56: show a lambda expression that is equivalent to
>> the following let* expression:
>> (let* ((x 6)
>> (y (* x x)))
>> (+ x y)) ;; => 42
>> I came up with these two:
>> (setq *test*
>> ((lambda (x)
>> (+ ((lambda (y)
>> (* y y))
>> x)
>> x)
>> ) 6))
>> (setq *test2*
>> ((lambda (x)
>> ((lambda (x y)
>> (+ x y)) x (* x x))
>> ) 6))
Please note that the use of "lambda" is now obsolete in lisp. It was
retained only for legacy code and programers.
Mike Cox wrote:
>
>
> Please note that the use of "lambda" is now obsolete in lisp. It was
> retained only for legacy code and programers.
That's a bit of an overstatement from someone who's been using Lisp for
24 hours and feels that it's "almost as good as C#"...
LAMBDA is in no way obsolete. Quite the contrary--it is used all of the
time for anonymous functions. Look at the CLHS entry for SORT or MAPCAR
for simple examples:
http://www.lispworks.com/reference/HyperSpec/Body/f_sort_.htm
http://www.lispworks.com/reference/HyperSpec/Body/f_mapc_.htm
David Sletten <·····@slytobias.com> wrote in message news:<·····················@twister.socal.rr.com>...
> Mike Cox wrote:
>
> >
> >
> > Please note that the use of "lambda" is now obsolete in lisp. It was
> > retained only for legacy code and programers.
>
> That's a bit of an overstatement from someone who's been using Lisp for
> 24 hours and feels that it's "almost as good as C#"...
I KNOW computer science. For me to pick up another language is
trivial. Are you familiar with Knuth, or Dijkstra? I am, and with my
solid theoretical knowledge, it is expected that one be able to master
a language in a week.
> LAMBDA is in no way obsolete. Quite the contrary--it is used all of the
> time for anonymous functions. Look at the CLHS entry for SORT or MAPCAR
> for simple examples:
> http://www.lispworks.com/reference/HyperSpec/Body/f_sort_.htm
> http://www.lispworks.com/reference/HyperSpec/Body/f_mapc_.htm
Actually, you are wrong. In earlier versions of lisp, functions were
denoted as lists internally, and the only way lisp was able to know
whether it was a function or list was to look for the lambda symbol.
If it had a lambda as the first element, then it was a function.
This:
(lambda (x) (+ x 100))
should now be written like so:
((x) (+ x 100))
Mike Cox
--
Autor of the *nix "hm" command
············@yahoo.com (Mike Cox) wrote in message news:<····························@posting.google.com>...
> This:
>
> (lambda (x) (+ x 100))
>
> should now be written like so:
>
> ((x) (+ x 100))
:-)
Not in Common Lisp. If you give CL a list to eval, such that the
operand (first element) is itself a list, you will normally get an
error. However, because Lisp is so flexible, you can get it to
interpret any such composition as a lambda-form, as you seem to desire
(I don't know if you were trolling, or joking, or being serious,
actually).
You can define '(' as a reader-macro character so that it would check
if the first element is a list and then insert 'lambda.
But if you are new to Lisp, you probably shouldn't use macros or
reader macros until you get comfortable with the other aspects of the
language.
> Mike Cox
David Fisher <·············@yahoo.com> wrote:
+---------------
| You can define '(' as a reader-macro character so that it would check
| if the first element is a list and then insert 'lambda.
+---------------
Though those with some experience in Scheme might suggest that you
insert 'FUNCALL instead.
-Rob
-----
Rob Warnock <····@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607
·············@yahoo.com (David Fisher) wrote in message news:<····························@posting.google.com>...
> ············@yahoo.com (Mike Cox) wrote in message news:<····························@posting.google.com>...
>
> > This:
> >
> > (lambda (x) (+ x 100))
> >
> > should now be written like so:
> >
> > ((x) (+ x 100))
>
> :-)
>
> Not in Common Lisp. If you give CL a list to eval, such that the
> operand (first element) is itself a list, you will normally get an
> error. However, because Lisp is so flexible, you can get it to
> interpret any such composition as a lambda-form, as you seem to desire
> (I don't know if you were trolling, or joking, or being serious,
> actually).
>
> You can define '(' as a reader-macro character so that it would check
> if the first element is a list and then insert 'lambda.
>
> But if you are new to Lisp, you probably shouldn't use macros or
> reader macros until you get comfortable with the other aspects of the
> language.
>
> > Mike Cox
This is what you need to start using your own lambda-less version of
Lisp:
(defun auto-insert-lambda (stream char)
(declare (ignore char))
(let ((list (read-delimited-list #\) stream)))
(if (and (consp list)
(listp (car list)))
(cons 'lambda list)
list)))
(set-macro-character #\( #'auto-insert-lambda)
That ought to really impress your coworkers, far more so than the
"hm", home command :-)
BTW, how come READ doesn't take readtable as an optional argument?
Seems like an annoyance.
In article <····························@posting.google.com>,
·············@yahoo.com (David Fisher) wrote:
> ·············@yahoo.com (David Fisher) wrote in message
news:<····························@posting.google.com>...
> > ············@yahoo.com (Mike Cox) wrote in message
news:<····························@posting.google.com>...
> >
> > > This:
> > >
> > > (lambda (x) (+ x 100))
> > >
> > > should now be written like so:
> > >
> > > ((x) (+ x 100))
> >
> > :-)
> >
> > Not in Common Lisp. If you give CL a list to eval, such that the
> > operand (first element) is itself a list, you will normally get an
> > error. However, because Lisp is so flexible, you can get it to
> > interpret any such composition as a lambda-form, as you seem to desire
> > (I don't know if you were trolling, or joking, or being serious,
> > actually).
> >
> > You can define '(' as a reader-macro character so that it would check
> > if the first element is a list and then insert 'lambda.
> >
> > But if you are new to Lisp, you probably shouldn't use macros or
> > reader macros until you get comfortable with the other aspects of the
> > language.
> >
> > > Mike Cox
>
>
> This is what you need to start using your own lambda-less version of
> Lisp:
>
>
> (defun auto-insert-lambda (stream char)
> (declare (ignore char))
> (let ((list (read-delimited-list #\) stream)))
> (if (and (consp list)
> (listp (car list)))
> (cons 'lambda list)
> list)))
>
> (set-macro-character #\( #'auto-insert-lambda)
>
>
> That ought to really impress your coworkers, far more so than the
> "hm", home command :-)
I think that's really gonna mess you up when you write something like:
(setf my-alist '((1 2) (3 4)))
or
(let ((x 1)) ...)
E.
·········@jpl.nasa.gov (Erann Gat) wrote in message news:<··························@192.168.1.51>...
> I think that's really gonna mess you up when you write something like:
>
> (setf my-alist '((1 2) (3 4)))
>
> or
>
> (let ((x 1)) ...)
Right. This language requires cooperation from the user. You don't
need special forms or macros like QUOTE and LET. You can live with
LAMBDA alone :-)
>> Mike Cox wrote:
>>
>> > Please note that the use of "lambda" is now obsolete in lisp. It was
>> > retained only for legacy code and programers.
> David Sletten <·····@slytobias.com> wrote in message news:<·····················@twister.socal.rr.com>...
>>
>> LAMBDA is in no way obsolete. Quite the contrary--it is used all of the
>> time for anonymous functions. Look at the CLHS entry for SORT or MAPCAR
>> for simple examples:
>> http://www.lispworks.com/reference/HyperSpec/Body/f_sort_.htm
>> http://www.lispworks.com/reference/HyperSpec/Body/f_mapc_.htm
············@yahoo.com (Mike Cox) writes:
>
> Actually, you are wrong. In earlier versions of lisp, functions were
> denoted as lists internally, and the only way lisp was able to know
> whether it was a function or list was to look for the lambda symbol.
> If it had a lambda as the first element, then it was a function.
Early versions as in forty years ago.
> This:
>
> (lambda (x) (+ x 100))
>
> should now be written like so:
>
> ((x) (+ x 100))
Nonsense.
--
~jrm
Joe Marshall <·············@comcast.net> writes:
> ············@yahoo.com (Mike Cox) writes:
> >
> > Actually, you are wrong. In earlier versions of lisp, functions were
> > denoted as lists internally, and the only way lisp was able to know
> > whether it was a function or list was to look for the lambda symbol.
> > If it had a lambda as the first element, then it was a function.
>
> Early versions as in forty years ago.
Lambda was already present in M-exprs (the original, non-list,
notation for Lisp).
To define a universal Lisp function, a translation from M-eprs to
the data language (S-exprs) was defined. The greek letter lambda
was written as the symbol LAMBDA in that translation.
See http://green.iis.nsk.su/~vp/doc/lisp1.5/node7.html
For forms such as
((lambda ...) ...)
LAMBDA was needed in source code (regardless of how functions
were represented internally) to distinguish the case (as above),
where a function appears directly, from the case of a function-
valued expression, e.g.
((f ...) ...)
where f is the name of a function that returns a function.
By Lisp 1.5, there was the "FUNARG device". Anonymous
functions -- LAMBDA expressions -- that appeared in argument
positions were "quoted" by wrapping (FUNCTION ...) around
them.
The value of (FUNCTION (LAMBDA ...)) was (FUNARG (LAMBDA ...) alist),
where alist gives the variable bindings in effect at the point where
the FUNCTION expression was evaluated.
-- jd
············@yahoo.com (Mike Cox) writes:
> I KNOW computer science. For me to pick up another language is
> trivial. Are you familiar with Knuth, or Dijkstra? I am, and with my
> solid theoretical knowledge, it is expected that one be able to master
> a language in a week.
But do you really meet that expectation? The syntax is one thing.
It doesn't take more than a few minutes to get basic Lisp syntax. C
and Java syntax aren't really difficult either. Harder to write
parsers for, but not harder for humans.
However, there is still the question of vocabulary and idioms. Java
has huge libraries (C is no slouch in that area either). Common Lisp
has a lot of words (which amount to the equivalent of a large
standard library). That doesn't count the defacto features that many
implementations have added to play nice with *nix and windoze systems.
Since Lisp is a programmable language, some of the macros can get
tricky to use right. I've lately had some joy with LOOP. There are
plenty of people who won't touch it, at least in the extended form,
for what seem to be good reasons. There is a debate on LOOP going on
right now.
> This:
>
> (lambda (x) (+ x 100))
>
> should now be written like so:
>
> ((x) (+ x 100))
You know, that is very much like what Paul Graham said on page 26 of
his ACL book. In fact that is precisely the same example that he
gave. The word lambda exists in Common Lisp for the benefit of
humans so I don't see how you are justified in calling it obsolete.
Now if you are so darn familiar with Visual Studio .NET's inner
workings and the .NET byte code standard, why don't you integrate
Lisp into it? You want to make money? Well there is a project some
people just might pay for. If nothing else, you can use it. It may
even give you a competitive advantage.
With your extensive knowledge of CS theory, language and compiler
design, and .NET, you should be able to knock this project right out.
--
Those who do not remember the history of Lisp are doomed to repeat it,
badly.
> (dwim x)
NIL
David Steuber <·············@verizon.net> wrote in message news:<··············@david-steuber.com>...
> ············@yahoo.com (Mike Cox) writes:
>
> > I KNOW computer science. For me to pick up another language is
> > trivial. Are you familiar with Knuth, or Dijkstra? I am, and with my
> > solid theoretical knowledge, it is expected that one be able to master
> > a language in a week.
>
> But do you really meet that expectation? The syntax is one thing.
> It doesn't take more than a few minutes to get basic Lisp syntax. C
> and Java syntax aren't really difficult either. Harder to write
> parsers for, but not harder for humans.
Of course I meet that expectation! 2 weeks ago, I tried lisp for the
first time so I could use emacs. Now I'm about to write a .NET
implementation of lisp, LISP.NET.
> However, there is still the question of vocabulary and idioms. Java
> has huge libraries (C is no slouch in that area either). Common Lisp
> has a lot of words (which amount to the equivalent of a large
> standard library). That doesn't count the defacto features that many
> implementations have added to play nice with *nix and windoze systems.
Well, if you get down to it, MOST libraries are based in theory. If
you understand the algorithms, and the mathematics behind them, most
libraries are *very* similar. I understand multi-threading, having
read Dijkstras early work on it. I read and know the mathematics
behind Knuth. I know how operating systems work, and there are some
universal principles behind every language and framework. Once you
get a few like ATL, WTL, SWING, BONOBO, CORBA TAO down, it becomes
second nature for an expert like myself.
> Since Lisp is a programmable language, some of the macros can get
> tricky to use right. I've lately had some joy with LOOP. There are
> plenty of people who won't touch it, at least in the extended form,
> for what seem to be good reasons. There is a debate on LOOP going on
> right now.
>
> > This:
> >
> > (lambda (x) (+ x 100))
> >
> > should now be written like so:
> >
> > ((x) (+ x 100))
>
> You know, that is very much like what Paul Graham said on page 26 of
> his ACL book. In fact that is precisely the same example that he
> gave.
Hmm. I googled Paul Grahm, and it seems he is a Harvard guy!
Imagine, a Harvard Comp Sci. professor agreeing with me!
>The word lambda exists in Common Lisp for the benefit of
> humans so I don't see how you are justified in calling it obsolete.
I certainly don't put "lambda" in my programs. It doesn't benefit me.
Maybe if I wanted to impress a woman, I'd toss that in there to show
my mastery of lambda calculus, but other than that, no I don't put it
in!
> Now if you are so darn familiar with Visual Studio .NET's inner
> workings and the .NET byte code standard, why don't you integrate
> Lisp into it? You want to make money? Well there is a project some
> people just might pay for. If nothing else, you can use it. It may
> even give you a competitive advantage.
Thanks for the idea. If more people are interested, I'd be happy to
start a project on sourceforge. Cross-post this to a .net newsgroups
and see if more people would be interested in something like this. It
would be a great hobby project.
> With your extensive knowledge of CS theory, language and compiler
> design, and .NET, you should be able to knock this project right out.
Yeah, it would be interesting. If a lot of people are wanting this,
this would be a great thing. Maybe we could team up with the mono
people? YOur thoughts?
Mike Cox.
············@yahoo.com (Mike Cox) wrote in message news:<····························@posting.google.com>...
> David Steuber <·············@verizon.net> wrote in message news:<··············@david-steuber.com>...
> > > This:
> > > (lambda (x) (+ x 100))
> > >
> > > should now be written like so:
> > > ((x) (+ x 100))
> >
> > You know, that is very much like what Paul Graham said on page 26 of
> > his ACL book. In fact that is precisely the same example that he
> > gave.
>
> Hmm. I googled Paul Grahm, and it seems he is a Harvard guy!
> Imagine, a Harvard Comp Sci. professor agreeing with me!
You are one tricky fellow.
> >The word lambda exists in Common Lisp for the benefit of
> > humans so I don't see how you are justified in calling it obsolete.
>
> I certainly don't put "lambda" in my programs. It doesn't benefit me.
> Maybe if I wanted to impress a woman, I'd toss that in there to show
> my mastery of lambda calculus, but other than that, no I don't put it
> in!
Why not rename the sucker? fun, new-function, anon... Conceivably
people may make a big deal about it, but the language gives you the
power. Seize it if you want it.
Tayssir John Gabbour <···········@yahoo.com> wrote:
+---------------
| ············@yahoo.com (Mike Cox) wrote:
| > I certainly don't put "lambda" in my programs. It doesn't benefit me.
|
| Why not rename the sucker? fun, new-function, anon...
+---------------
I seem to recall that ML calls it "fn", and that's what I used once for
a scripting language. Lessee here... Certainly easy enough to do in CL:
> (defmacro fn (&rest rest)
`(lambda ,@rest))
FN
> (mapcar (fn (x y) (+ y (* x 10))) '(1 2 3) '(4 5 6))
(14 25 36)
>
Yup, seems to work just fine.
-Rob
p.s. I once wrote a reader macro for "#$" [duplicating it is left as an
exercise for the discerning reader] which let me use $1, $2, etc. as args
to anonymous functions, like shell scripts, so you didn't have to bother
defining those pesky argument lists! ;-}
> (mapcar #$(+ $2 (* 10 $1)) '(1 2 3) '(4 5 6))
(14 25 36)
>
See how much *shorter* that is than the FN version?!? ;-} ;-}
['Course, it doesn't handle >9 args. Or &OPTIONAL, &REST, &KEYS, etc...]
-----
Rob Warnock <····@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607
············@yahoo.com (Mike Cox) writes:
> > With your extensive knowledge of CS theory, language and compiler
> > design, and .NET, you should be able to knock this project right out.
>
> Yeah, it would be interesting. If a lot of people are wanting this,
> this would be a great thing. Maybe we could team up with the mono
> people? YOur thoughts?
Give it a shot.
Personally, I don't think byte code is such a hot idea.
--
Those who do not remember the history of Lisp are doomed to repeat it,
badly.
> (dwim x)
NIL
············@yahoo.com (Mike Cox) writes:
> David Steuber <·············@verizon.net> wrote in message news:<··············@david-steuber.com>...
>> ············@yahoo.com (Mike Cox) writes:
>>
>> > I KNOW computer science. For me to pick up another language is
>> > trivial. Are you familiar with Knuth, or Dijkstra? I am, and with my
>> > solid theoretical knowledge, it is expected that one be able to master
>> > a language in a week.
>>
>> But do you really meet that expectation? The syntax is one thing.
>> It doesn't take more than a few minutes to get basic Lisp syntax. C
>> and Java syntax aren't really difficult either. Harder to write
>> parsers for, but not harder for humans.
>
> Of course I meet that expectation! 2 weeks ago, I tried lisp for the
> first time so I could use emacs. Now I'm about to write a .NET
> implementation of lisp, LISP.NET.
Damn! Think of all the years of education and the money I've wasted.
--
~jrm
"Joe Marshall" <·············@comcast.net> wrote in message
·················@comcast.net...
> ············@yahoo.com (Mike Cox) writes:
>
> > David Steuber <·············@verizon.net> wrote in message
news:<··············@david-steuber.com>...
> >> ············@yahoo.com (Mike Cox) writes:
> >
> > Of course I meet that expectation! 2 weeks ago, I tried lisp for the
> > first time so I could use emacs. Now I'm about to write a .NET
> > implementation of lisp, LISP.NET.
>
> Damn! Think of all the years of education and the money I've wasted.
>
That's nothing, thanks to a speed reading course and using a preprocessor
to remove all indefinite and definite articles I've learned C in 14.6 hours
instead of 24. I've looked at other people's code and have no problem
understanding them except the files are corrupted. They are great until
there's a '*/'. After that it degenerates into random characters.
--
Geoff
············@yahoo.com (Mike Cox) wrote in message news:<····························@posting.google.com>...
> Of course I meet that expectation! 2 weeks ago, I tried lisp for the
> first time so I could use emacs. Now I'm about to write a .NET
> implementation of lisp, LISP.NET.
4 seconds ago I glanced at the cover of a book on violin making. Now
I'm about to make a violin that's better than anything that
stradyvareus guy ever made. I am 3133T!
`I can call spirits from the vasty deep.'
`Why, so can I, or so can any man; but will they come when you do call
for them?'
"Mike Cox" <············@yahoo.com> wrote in message
·································@posting.google.com...
> David Steuber <·············@verizon.net> wrote in message
news:<··············@david-steuber.com>...
> > ············@yahoo.com (Mike Cox) writes:
> >
> > > I KNOW computer science. For me to pick up another language is
> > > trivial. Are you familiar with Knuth, or Dijkstra? I am, and with my
> > > solid theoretical knowledge, it is expected that one be able to master
> > > a language in a week.
> >
> > But do you really meet that expectation? The syntax is one thing.
> > It doesn't take more than a few minutes to get basic Lisp syntax. C
> > and Java syntax aren't really difficult either. Harder to write
> > parsers for, but not harder for humans.
>
> Of course I meet that expectation! 2 weeks ago, I tried lisp for the
> first time so I could use emacs. Now I'm about to write a .NET
> implementation of lisp, LISP.NET.
Be sure to get in touch with a fellow named Ilias who helped educate this
group a year or two ago. You seem to share CL skill levels and
certain..erm..visionary qualities.
--
Coby Beck
(remove #\Space "coby 101 @ big pond . com")
············@yahoo.com (Mike Cox) wrote in message news:<····························@posting.google.com>...
> Hmm. I googled Paul Grahm, and it seems he is a Harvard guy!
> Imagine, a Harvard Comp Sci. professor agreeing with me!
No, it's you who is agreeing with him. Also, you are selling yourself
too short. If he knew that the author of the famous Linux "hm" command
was agreeing with him, he would be the one bragging about it!
David Sletten wrote:
> Mike Cox wrote:
>
>>
>>
>> Please note that the use of "lambda" is now obsolete in lisp. It was
>> retained only for legacy code and programers.
>
> That's a bit of an overstatement from someone who's been using Lisp for
> 24 hours and feels that it's "almost as good as C#"...
>
Please note that "Mike Cox" is a rather poor wannabee troll.
Not entirely sure why the little sociopath has started targetting
comp.lang.lisp, previously he has hung about on comp.os.linux.*,
check google.
Cock is slang for penis in some english dialects, so his email address
phonetically translates as "My cock's linux".
Now, if he is posting via news.uni-berlin.de, they would have asked for a
real name AFAIK, so maybe it is his real name and he's antisocial because
of years of persecution and misunderstanding :-). But more likely, it's a
pseudonym and the germans didn't catch it due to unfamiliarity with english
slang.
As he's just a nuisance rather than a serious abuser, there's little
point complaining to news.uni-berlin.de, just killfile him.
"Mike Cox" <············@yahoo.com> writes:
> Please note that the use of "lambda" is now obsolete in lisp. It was
> retained only for legacy code and programers.
It could only be obsolete in a language that would not be lisp anymore.
--
__Pascal_Bourguignon__ http://www.informatimago.com/
There is no worse tyranny than to force a man to pay for what he doesn't
want merely because you think it would be good for him.--Robert Heinlein
http://www.theadvocates.org/
> "Mike Cox" <············@yahoo.com> writes:
> > Please note that the use of "lambda" is now obsolete in lisp. It was
> > retained only for legacy code and programers.
>
> It could only be obsolete in a language that would not be lisp anymore.
Actually it was lambda calculus that made me want to learn more about
functional programming... =).
"Michiel Borkent" <·······@cs.utwente.nl> writes:
> > "Mike Cox" <············@yahoo.com> writes:
> > > Please note that the use of "lambda" is now obsolete in lisp. It was
> > > retained only for legacy code and programers.
> >
> > It could only be obsolete in a language that would not be lisp anymore.
>
> Actually it was lambda calculus that made me want to learn more about
> functional programming... =).
It does get annoying when you type something like this:
(lamda (x y)
(+ x y))
And then wonder why the heck it doesn't work.
Damn those silent bees.
--
Those who do not remember the history of Lisp are doomed to repeat it,
badly.
> (dwim x)
NIL
> It does get annoying when you type something like this:
>
> (lamda (x y)
> (+ x y))
>
> And then wonder why the heck it doesn't work.
>
> Damn those silent bees.
When I first saw "lambda" expressions in LISP, before I even knew it was
LISP and before I learnt any, I thought: hmm, why not just use a "\" instead
of "lambda"...
> --
> Those who do not remember the history of Lisp are doomed to repeat it,
> badly.
>
> > (dwim x)
> NIL
On Sun, 14 Mar 2004 15:17:54 +0100, Michiel Borkent
<·······@cs.utwente.nl> wrote:
At the time lambda notation was intrudused \ was not to be found on
keyboards.
So I guess you could say for historical reasons.
>
>> It does get annoying when you type something like this:
>>
>> (lamda (x y)
>> (+ x y))
>>
>> And then wonder why the heck it doesn't work.
>>
>> Damn those silent bees.
>
> When I first saw "lambda" expressions in LISP, before I even knew it was
> LISP and before I learnt any, I thought: hmm, why not just use a "\"
> instead
> of "lambda"...
>
>
>
>> --
>> Those who do not remember the history of Lisp are doomed to repeat it,
>> badly.
>>
>> > (dwim x)
>> NIL
>
>
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
David Steuber <·············@verizon.net> writes:
> "Michiel Borkent" <·······@cs.utwente.nl> writes:
>
> > > "Mike Cox" <············@yahoo.com> writes:
> > > > Please note that the use of "lambda" is now obsolete in lisp. It was
> > > > retained only for legacy code and programers.
> > >
> > > It could only be obsolete in a language that would not be lisp anymore.
> >
> > Actually it was lambda calculus that made me want to learn more about
> > functional programming... =).
>
> It does get annoying when you type something like this:
>
> (lamda (x y)
> (+ x y))
>
> And then wonder why the heck it doesn't work.
>
> Damn those silent bees.
Il use this in emacs to have all the greek letter names display as
greek characters. It works both on lower case and upper case.
(defconstant *greek-letters*
'( "alpha" "beta" "gamma" "delta" "epsilon" "zeta" "eta"
"theta" "iota" "kappa" "lambda" "mu" "nu" "xi" "omicron" "pi"
"rho" "terminalsigma" "sigma" "tau"
"upsilon" "phi" "chi" "psi" "omega" )
"The order of these strings is fixed by the encoding of greek-iso8859-7!"
);;*greek-letters*
(defun greek-letter-font-lock ()
"
RETURN: A font-lock-keywords list mapping greek letter names
to greek characters.
"
(let ((maj 64) (min 96))
(mapcan
(lambda (letter)
(incf maj) (incf min)
`(
(,(format "\\([^A-Za-z0-9]\\|^\\)\\(%s\\)\\([^A-Za-z]\\|$\\)"
(upcase letter))
(2 (progn (compose-region (match-beginning 2)
(match-end 2)
,(make-char 'greek-iso8859-7 maj)
'decompose-region)
nil)))
(,(format "\\([^A-Za-z0-9]\\|^\\)\\(%s\\)\\([^A-Za-z]\\|$\\)"
(downcase letter))
(2 (progn (compose-region (match-beginning 2)
(match-end 2)
,(make-char 'greek-iso8859-7 min)
'decompose-region)
nil)))))
*greek-letters*))
);;greek-letter-font-lock
(defun tree-upcase-strings (tree)
(cond
((stringp tree) (string-upcase tree))
((consp tree) (cons (tree-upcase-strings (car tree))
(tree-upcase-strings (cdr tree))))
(t tree))
);;tree-upcase-strings
(defvar pretty-greek t)
(defun pretty-greek ()
"
Show LAMBDA keyword as a greek letter lambda in lisp source code.
(add-hook 'emacs-lisp-mode-hook 'pretty-greek)
(add-hook 'lisp-mode-hook 'pretty-greek)
"
(interactive)
(unless (and (boundp 'pretty-greek) (not pretty-greek))
(setq font-lock-keywords-case-fold-search nil)
(font-lock-add-keywords nil (greek-letter-font-lock))
));;pretty-greek
--
__Pascal_Bourguignon__ http://www.informatimago.com/
There is no worse tyranny than to force a man to pay for what he doesn't
want merely because you think it would be good for him.--Robert Heinlein
http://www.theadvocates.org/
"Mike Cox" <············@yahoo.com> writes:
> Please note that the use of "lambda" is now obsolete in lisp. It was
> retained only for legacy code and programers.
Ok, you've had your fun now with your latest two or three posts.
Now please, PLEASE go trolling somewhere else.
Like, say, in the middle of a busy street.
"Mike Cox" <············@yahoo.com> wrote in message
····················@ID-222658.news.uni-berlin.de...
> Please note that the use of "lambda" is now obsolete in lisp. It was
> retained only for legacy code and programers.
This is correct, actually. And explains why Mike doesn't want it.
Actually, just think how much more streamlined the spec would be if we
stripped out all that stuff that was retained just for programmers!
--
Coby Beck
(remove #\Space "coby 101 @ big pond . com")
"Coby Beck" <·····@mercury.bc.ca> writes:
> "Mike Cox" <············@yahoo.com> wrote in message
> ····················@ID-222658.news.uni-berlin.de...
>
>> Please note that the use of "lambda" is now obsolete in lisp. It was
>> retained only for legacy code and programers.
>
> This is correct, actually. And explains why Mike doesn't want it.
>
> Actually, just think how much more streamlined the spec would be if we
> stripped out all that stuff that was retained just for programmers!
What a Scheme.
marc
Marc Spitzer wrote:
> "Coby Beck" <·····@mercury.bc.ca> writes:
>
>
>>Actually, just think how much more streamlined the spec would be if we
>>stripped out all that stuff that was retained just for programmers!
>
>
> What a Scheme.
Good one! Hey, where were you? Everyone was crushed by the no-show of
Mr. Reliable. Well here is what you missed:
- really bad service
- a spirited discussion of possible projects appropriate for Google,
where Bob just started
- The Glorious, Spinning, Light-Panel Demo of Cello. Heow liked it,
everyone else did their best to attack it. Same happened in Boulder. I
think I started a tradition by picking on CLIM.
- a couple of newbies, one led to us by word of mouth from all the Lisp
activity down at (help me) Morgan Stanley? Apparently lisp-nyk Michael
Naughton (sp?) has them all learning their car's and cdr's down there.
- and best of all, how cool are Lispniks? At the end of the evening,
with just a few of us remaining, I simply scooped up all the money that
had been tossed on the table, counted it up, and the total left for the
$226 tab was $227. Someone was upset that that meant we were off by the
tip, or 15%, but I thought that was still pretty damn close. Then
someone noticed the tip had already been added since it was a big party.
So we nailed it!
- then a solid "never say die!" contingent ended up at P&Gs where I set
up Cello again and the lisp-nyks met the guy I mentioned who once
supported Lisp systems donated to the city.
// eoreport
Meanwhile, I am running out of excuses for not delivering the web page
for Cello on common-lisp.net. The hold-up is that I hope to create a
(hefty) animated GIF or even QT movie of the Light-panel demo, because a
static screen shot just doesn't do the beast justice.
kt
--
http://tilton-technology.com
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
Your Project Here! http://alu.cliki.net/Industry%20Application
Kenny Tilton <·······@nyc.rr.com> writes:
> - The Glorious, Spinning, Light-Panel Demo of Cello. Heow liked it,
> everyone else did their best to attack it. Same happened in Boulder.
OpenGL, not Cello. Cello is just a cute OpenGL hack, not something to
try to attack. ;)
> Then someone noticed the tip had already been added since it was a big
> party.
Ooo! oo! that was me!
--
Rahul Jain
·····@nyct.net
Professional Software Developer, Amateur Quantum Mechanicist
Rahul Jain wrote:
> Kenny Tilton <·······@nyc.rr.com> writes:
>
>
>>- The Glorious, Spinning, Light-Panel Demo of Cello. Heow liked it,
>>everyone else did their best to attack it. Same happened in Boulder.
>
>
> OpenGL, not Cello. Cello is just a cute OpenGL hack, not something to
> try to attack. ;)
Excellent, the Boulder guy made the same mistake. Neither one of you saw
one line of code, so you have no idea whether Cello/Cells is a powerful
way to build a GUI. Christian impressed me a few times during his visit,
one of which was when he said "OK, let's see the code behind that
widget." Nor apparently did the antialased text displayed from arbitrary
fonts get picked up on your radar, or the speed, or even the original
point of Cello: it is portable in principle, and has been ported in fact
to two Lisp implementaions (ACL and Lw) and two OSes (win32 and Linux
(so OSX should be a breeze)).
Of course you just wanted to be negative, so I can see why you wanted as
few facts as possible.
>
>
>>Then someone noticed the tip had already been added since it was a big
>>party.
>
>
> Ooo! oo! that was me!
Ah, so you do have excellent powers of observation when you feel like
using them.
:)
kenneth
--
http://tilton-technology.com
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
Your Project Here! http://alu.cliki.net/Industry%20Application
Rahul Jain wrote:
> Kenny Tilton <·······@nyc.rr.com> writes:
>
>
>>- The Glorious, Spinning, Light-Panel Demo of Cello. Heow liked it,
>>everyone else did their best to attack it. Same happened in Boulder.
>
>
> OpenGL, not Cello. Cello is just a cute OpenGL hack...
btw, isn't OpenGL incredible? I do give it full credit when /some
people/ gush over the Light Panel. And now any Lisp programmer can use
it without a second thought, with a lot of the painful details handled
by the layer of syntactic sugar I am building up around it.
And you won't believe what I have done with ImageMagick and OpenGL
combined. I do not know if one feature justifies an announcement, but
this one is getting one. RSN.
Mind you, I come at this from a different angle than most Lisp
developers: commercial software development. So silly little things like
attractive screens and anti-aliased text and ease-of-programming get
noticed.
What is it you do again?
:)
kenneth
--
http://tilton-technology.com
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
Your Project Here! http://alu.cliki.net/Industry%20Application
Kenny Tilton <·······@nyc.rr.com> writes:
> btw, isn't OpenGL incredible?
OpenGL is the _only_ thing I ever see on my Mac display.
--
Those who do not remember the history of Lisp are doomed to repeat it,
badly.
> (dwim x)
NIL
David Steuber wrote:
> Kenny Tilton <·······@nyc.rr.com> writes:
>
>
>>btw, isn't OpenGL incredible?
>
>
> OpenGL is the _only_ thing I ever see on my Mac display.
I fell for that line, too. The last step in the rendering is to hand off
to OpenGL, but OpenGL is not being allowed to help with the work unless
the application is building up the framebuffer incrementally with so
many atomic gl/glu calls. The way Cello does.
kt
--
http://tilton-technology.com
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
Your Project Here! http://alu.cliki.net/Industry%20Application
From: Kenny Tilton
Subject: QT, iMovie, other? and errata: Belated, not elated <g>, tho it was a blast [Re: elated Lisp-nyc report ..
Date:
Message-ID: <%ht5c.50529$Wo2.33326@twister.nyc.rr.com>
Kenny Tilton wrote:
> - a spirited discussion of possible projects appropriate for Google,
> where Bob just started
<sigh> "...of possible /Lisp/ projects..."
> Meanwhile, I am running out of excuses for not delivering the web page
> for Cello on common-lisp.net. The hold-up is that I hope to create a
> (hefty) animated GIF..
It woiks! I used the command-line utility that comes with the
ImageMagick distro. But the little JPGs become hefty GIFs (duh) so it's
a tad huger than I thought.
Since so little changes pixel-wise, this is a job for QuickTime, or...
...does anyone know of other movie utility that is smart about which
pixels have changed? I'll fire up my iBook and see if it is time to buy
QuickTime Pro, or maybe iMovie does this?
or even QT movie of the Light-panel demo, because a
> static screen shot just doesn't do the beast justice.
>
> kt
>
>
--
http://tilton-technology.com
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
Your Project Here! http://alu.cliki.net/Industry%20Application
From: Rahul Jain
Subject: Re: QT, iMovie, other? and errata: Belated, not elated <g>, tho it was a blast [Re: elated Lisp-nyc report ..
Date:
Message-ID: <87r7vt77v0.fsf@nyct.net>
Kenny Tilton <·······@nyc.rr.com> writes:
> ...does anyone know of other movie utility that is smart about which
> pixels have changed?
Anything that does MPEG will calculate motion vectors for the pixels, so
it'll compress the rotation of the shape quite well.
--
Rahul Jain
·····@nyct.net
Professional Software Developer, Amateur Quantum Mechanicist
From: Kenny Tilton
Subject: Re: QT, iMovie, other? and errata: Belated, not elated <g>, tho it was a blast [Re: elated Lisp-nyc report ..
Date:
Message-ID: <TUv5c.50816$Wo2.38189@twister.nyc.rr.com>
Rahul Jain wrote:
> Kenny Tilton <·······@nyc.rr.com> writes:
>
>
>>...does anyone know of other movie utility that is smart about which
>>pixels have changed?
>
>
> Anything that does MPEG will calculate motion vectors for the pixels, so
> it'll compress the rotation of the shape quite well.
Thx, I'll give mpeg a try as well. btw, I see MPEG-4 adopts QT. Anyway,
IM/GM seem to support QT, tho my first attempt only converted one frame.
Got a Q into the lists.
kenneth
--
http://tilton-technology.com
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
Your Project Here! http://alu.cliki.net/Industry%20Application
From: james anderson
Subject: Re: QT, iMovie, other? and errata: Belated, not elated <g>, tho it wasa blast [Re: elated Lisp-nyc report ..
Date:
Message-ID: <4056AD95.1E1C91BE@setf.de>
Kenny Tilton wrote:
> ...
>
> Since so little changes pixel-wise, this is a job for QuickTime, or...
>
> ...does anyone know of other movie utility that is smart about which
> pixels have changed? I'll fire up my iBook and see if it is time to buy
> QuickTime Pro, or maybe iMovie does this?
> or even QT movie of the Light-panel demo, because a
> > static screen shot just doesn't do the beast justice.
one need not buy quicktime pro. mcl offers access to osx quicktime generation.
i believe it is available through the trap interface and you don't even need
to access frameworks.
...
From: Brian Mastenbrook
Subject: Re: QT, iMovie, other? and errata: Belated, not elated <g>, tho it was a blast [Re: elated Lisp-nyc report ..
Date:
Message-ID: <160320041056116268%NObmastenbSPAM@cs.indiana.edu>
In article <·····················@twister.nyc.rr.com>, Kenny Tilton
<·······@nyc.rr.com> wrote:
> It woiks! I used the command-line utility that comes with the
> ImageMagick distro. But the little JPGs become hefty GIFs (duh) so it's
> a tad huger than I thought.
>
> Since so little changes pixel-wise, this is a job for QuickTime, or...
>
> ...does anyone know of other movie utility that is smart about which
> pixels have changed? I'll fire up my iBook and see if it is time to buy
> QuickTime Pro, or maybe iMovie does this?
> or even QT movie of the Light-panel demo, because a
You might want to check out Ambrosia's Snapz Pro:
http://www.AmbrosiaSW.com/utilities/snapzprox/
This is what Rainer uses to capture all of his lisp machine videos. I
used it to capture a video of InterLisp and it worked very well.
Brian
--
Brian Mastenbrook
http://www.cs.indiana.edu/~bmastenb/
From: Kenny Tilton
Subject: Re: QT, iMovie, other? and errata: Belated, not elated <g>, tho it was a blast [Re: elated Lisp-nyc report ..
Date:
Message-ID: <JgH5c.52203$Wo2.9016@twister.nyc.rr.com>
Brian Mastenbrook wrote:
> You might want to check out Ambrosia's Snapz Pro:
> http://www.AmbrosiaSW.com/utilities/snapzprox/
>
> This is what Rainer uses to capture all of his lisp machine videos. I
> used it to capture a video of InterLisp and it worked very well.
Thx for the tip, but I am stuck on this POS Win32 platform until I
decide I can live without AllegroCL/win32.
Snapz would meet my immediate requirement of prepping a demo movie for
the Cello web page, but that requirement led at once to development of
the Great Unannounced Mystery Feature (which I have pretty much given
away to anyone paying attention) so what I really need is to gen QT (or
convert to QT) programatically. And portably. James sent me some
hair-raising MCL that hits the QT API directly ... well, this is just a
wild feature I am throwing in because ImageMagick makes it so easy, I
really cannot justify a big project on this.
It is possible ImageMagick will do this if I get the incantations right.
That's an insane library, btw. Programatically read "wow.gif", save as
"wow.jpg", boom, JPEG conversion. Now /that/ is what software should be
like. Today I will load multiple images into an IM wand and save as
".MOV" or ".MPG". Just might work.
kt
--
http://tilton-technology.com
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
Your Project Here! http://alu.cliki.net/Industry%20Application
From: gb
Subject: Re: QT, iMovie, other? and errata: Belated, not elated <g>, tho it was a blast [Re: elated Lisp-nyc report ..
Date:
Message-ID: <n9mk71hui6t.fsf@polimi.it>
Kenny Tilton <·······@nyc.rr.com> writes:
> It woiks! I used the command-line utility that comes with the
> ImageMagick distro. But the little JPGs become hefty GIFs (duh) so
> it's a tad huger than I thought.
>
> Since so little changes pixel-wise,
if you save your screenshots in jpeg (i.e., in a lossy format), you
can't say anything about the littleness of pixel-wise changes...
maybe if you save yor screenshots in a lossless format, ImageMagick
could do better
also, using an 8-bit depth display could help, so that what you see is
what you get in the GIF, otherwise dithering may be thrown into
ciao
gb
--
ATTACKED BY ENORMOUS GNATS 57W 24N. SINKING. U-501.
From: Kenny Tilton
Subject: Re: QT, iMovie, other? and errata: Belated, not elated <g>, tho it was a blast [Re: elated Lisp-nyc report ..
Date:
Message-ID: <M8G6c.463$DV6.302@twister.nyc.rr.com>
gb wrote:
> Kenny Tilton <·······@nyc.rr.com> writes:
>
>
>>It woiks! I used the command-line utility that comes with the
>>ImageMagick distro. But the little JPGs become hefty GIFs (duh) so
>>it's a tad huger than I thought.
>>
>>Since so little changes pixel-wise,
>
>
> if you save your screenshots in jpeg (i.e., in a lossy format), you
> can't say anything about the littleness of pixel-wise changes...
ahhh, good point. but i imagine IM first converts the JPG to pixels
before doing the "what-changed" decision, and JPEG isn't /that/ lossy
that a stable image saved... well, it is certainly worth a test saving
first to a non-lossy format. thx for the "heads up".*
>
> maybe if you save yor screenshots in a lossless format, ImageMagick
> could do better
>
> also, using an 8-bit depth display could help, so that what you see is
> what you get in the GIF, otherwise dithering may be thrown into
OK, I'll keep an eye out for that.
Not sure what I did differently, but I just got a nicely compressed MPEG
out of a sequence of JPG screenshots using the manual convert, so I
killed another night trying to get it to work from the API. There was
some minor pixel messiness, which might derive from the JPGs (or one of
a million other things I don't understand).
But now it seems I have to get my VC++ patched so I can move on to the
latest source-only distro and see if it has the same bugs with its GS10
(Greenspun's Tenth) management of lists of multiple images.
kt
* "heads up" -- noun. Warning. From baseball, where fans in attendance
yell out a warning to other fans who might not have been looking when a
foul ball was hit in their direction, so the latter will look up and see
the ball and be able to avoid it.
k
--
http://tilton-technology.com
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
Your Project Here! http://alu.cliki.net/Industry%20Application
Kenny Tilton <·······@nyc.rr.com> writes:
> Marc Spitzer wrote:
>
>> "Coby Beck" <·····@mercury.bc.ca> writes:
>>
>>>Actually, just think how much more streamlined the spec would be if we
>>>stripped out all that stuff that was retained just for programmers!
>> What a Scheme.
>
> Good one! Hey, where were you? Everyone was crushed by the no-show of
> Mr. Reliable. Well here is what you missed:
The snow threw me off and I was feeling a little uder the weather.
>
> - really bad service
Ooohhhhh
>
> - a spirited discussion of possible projects appropriate for Google,
> where Bob just started
any good ideas?
>
> - The Glorious, Spinning, Light-Panel Demo of Cello. Heow liked it,
> everyone else did their best to attack it. Same happened in Boulder. I
> think I started a tradition by picking on CLIM.
I be dazzled
>
> - a couple of newbies, one led to us by word of mouth from all the
> Lisp activity down at (help me) Morgan Stanley? Apparently lisp-nyk
> Michael Naughton (sp?) has them all learning their car's and cdr's
> down there.
Go Russ Go Go Go
>
> - and best of all, how cool are Lispniks? At the end of the evening,
> with just a few of us remaining, I simply scooped up all the money
> that had been tossed on the table, counted it up, and the total left
> for the $226 tab was $227. Someone was upset that that meant we were
> off by the tip, or 15%, but I thought that was still pretty damn
> close. Then someone noticed the tip had already been added since it
> was a big party. So we nailed it!
>
> - then a solid "never say die!" contingent ended up at P&Gs where I
> set up Cello again and the lisp-nyks met the guy I mentioned who once
> supported Lisp systems donated to the city.
What does this NYC Lisp system do?
>
> // eoreport
>
> Meanwhile, I am running out of excuses for not delivering the web page
> for Cello on common-lisp.net. The hold-up is that I hope to create a
> (hefty) animated GIF or even QT movie of the Light-panel demo, because
> a static screen shot just doesn't do the beast justice.
Oh shiney
marc
Marc Spitzer wrote:
>>- a spirited discussion of possible projects appropriate for Google,
>>where Bob just started
>
>
> any good ideas?
That's Bob's call, but as good as Google is they are still looking for
ways to improve the search experience. Someone made a good point: one
can never find product reviews, every search ends up a an on-line store.
I suggested they use Cello.
>>- then a solid "never say die!" contingent ended up at P&Gs where I
>>set up Cello again and the lisp-nyks met the guy I mentioned who once
>>supported Lisp systems donated to the city.
>
>
> What does this NYC Lisp system do?
Did. Something about connecting info from different agencies to find new
efficiencies. I gather that is still needed.
kt
Kenny Tilton <·······@nyc.rr.com> wrote:
> can never find product reviews, every search ends up a an on-line store.
> I suggested they use Cello.
I assume you ment Cells? Because if not, then I'm lost.
Cheers,
-- Nikodemus
·········@random-state.net wrote:
> Kenny Tilton <·······@nyc.rr.com> wrote:
>
>
>>can never find product reviews, every search ends up a an on-line store.
>>I suggested they use Cello.
>
>
> I assume you ment Cells? Because if not, then I'm lost.
Cello is the gui built atop cells, so it was a bit of a joke since Cello
does not have an HTML backend and we /are/ talking about a Web site. But
once you get your hands on the Light Panel demo, you will see it is an
interactive OpenGL playground in which you can quickly explore its
kazillion options. [google tie-in below.] That is why I created it, btw,
simply to find out what the hell all those options did. The LP merely
sticks a widget on every OpenGL facet I have chosen to investigate, and
because Cello makes it so easy to build GUI I have covered quite a bit.
And now I can not just learn OpenGL, I (or a graphic designer (or a
user!)) can actually design the skin of my app (textures, fonts,
lighting, shininess, opacity, etc etc) and then <feature not yet
implemented> simply hit save all the settings in a READ-friendly format
in the user prefs area.
Oh. Google. Well my idea was to augment Google by offering interfaces to
the Google "smarts". You still get a serial listing of a kazillion
matches, but you also get, say, a list to the side that shows a dozen
categories into which Google feels they all fall, ranked by apparent
occurrence within the totality of matches. Ya click on the ones that
sound right, and Google sculpts the totality to fit. But as with the
Light panel, you can go back and forth, try this try that, and I suppose
as the list reshapes Google smarts can start making other conclusions
about your actual interest, and offer those in a separate list, such as
"you might also be interested in..." etc etc etc
kt
--
http://tilton-technology.com
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
Your Project Here! http://alu.cliki.net/Industry%20Application
>>>>> "N" == nikodemus <·········@random-state.net> writes:
N> Kenny Tilton <·······@nyc.rr.com> wrote:
>> can never find product reviews, every search ends up a an
>> on-line store. I suggested they use Cello.
N> I assume you ment Cells? Because if not, then I'm lost.
It is the new reviewmagick library that Cello links in.
cheers,
BM
Bulent Murtezaoglu wrote:
>>>>>>"N" == nikodemus <·········@random-state.net> writes:
>
> N> Kenny Tilton <·······@nyc.rr.com> wrote:
> >> can never find product reviews, every search ends up a an
> >> on-line store. I suggested they use Cello.
>
> N> I assume you ment Cells? Because if not, then I'm lost.
>
> It is the new reviewmagick library that Cello links in.
You guys are catching on!
"It's the libraries!" -- Spike Lee
"Libraries are everything." -- Andre Agassi
"Where're the libraries?" -- Burger King
"Mmmmmmmm.... Libraries.." -- Homer Simpson
Nuff said?
:)
kt
--
http://tilton-technology.com
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
Your Project Here! http://alu.cliki.net/Industry%20Application
"Michiel Borkent" <·······@cs.utwente.nl> writes:
> > Omit the silly SETQ and start with
>
> I used setq to see if my results were ok, by saying *test*. So my
> first solution was ok?
Nope, the + belongs inside the second LAMBDA.
Regards,
--
Nils G�sche
"Don't ask for whom the <CTRL-G> tolls."
PGP key ID #xEEFBA4AF
Nils G�sche wrote:
> "Michiel Borkent" <·······@cs.utwente.nl> writes:
>
>
>>>Omit the silly SETQ and start with
>>
>>I used setq to see if my results were ok, by saying *test*. So my
>>first solution was ok?
>
>
> Nope, the + belongs inside the second LAMBDA.
>
> Regards,
One way of looking at this is to view LET* as a nested group of LET's:
(let ((x 6))
(let ((y (* x x)))
(+ x y)))
You can use LAMBDA simply to bind new variables in the same way:
((lambda (x)
((lambda (y)
(+ x y)) (* x x))) 6)
Obviously, the outer LAMBDA binds the variable X to 6, and the inner
binds the variable Y to the value of X squared.
In either case, the result form is (+ x y), as Nils pointed out. It's
just a matter of how the variables X and Y are created.
(As a side note, I imagine you understand that a LAMBDA expression can
take the place of a symbol as the first element in a form to be evaluated:
((lambda (x) (> x 0)) 5) vs. (plusp 5) )
David Sletten
"Michiel Borkent" <·······@cs.utwente.nl> writes:
> > Omit the silly SETQ and start with
>
> I used setq to see if my results were ok, by saying *test*.
> So my first solution was ok?
If you're not sure of what your result is (it's always printed by the
REPL, since it's a read eval PRINT loop!), you can always use * to get
again the value of the last result.
[11]> ((lambda (x) (+ ((lambda (y) (* y y)) x) x)) 6)
42
[12]> *
42
[13]>
--
__Pascal_Bourguignon__ http://www.informatimago.com/
There is no worse tyranny than to force a man to pay for what he doesn't
want merely because you think it would be good for him.--Robert Heinlein
http://www.theadvocates.org/
> From: "Michiel Borkent" <·······@cs.utwente.nl>
Code from book:
> (let* ((x 6)
> (y (* x x)))
> (+ x y))
Note that binds x to the value 6, then computes (* x x) i.e. 36 and
binds y to that value. Then in that context, evaluating (+ x y)
performs (+ 6 36) which gives 42.
What you typed, with setq removed and indentation fixed, and one parens
moved up a line to group stuff better:
> ((lambda (x)
> (+ ((lambda (y)
> (* y y))
> x)
> x))
> 6)
That correctly binds x to the value 6, but then simply binds y to the
value of x which is 6 again. Wrong, not a direct translation of the
original let* expression. You can see it if you insert a FORMAT in the
middle:
(let* ((x 6)
(y (* x x)))
(format t "X=~d Y=~d~%" x y)
(+ x y))
X=6 Y=36
42
((lambda (x)
(+ ((lambda (y)
(format t "X=~d Y=~d~%" x y)
(* y y))
x)
x))
6)
X=6 Y=6
42
If you have access to a debugger that lets you single-step through
evaluation of a form, showing the bindings of the variables somewhere
on screen at all times, that would show you more clearly the logic of
what's going on, but the FORMAT is good enough to tell you just what
the bindings are deep inside at one point.
To get the correct bindings as in the LET*, you need to do:
((lambda (x)
((lambda (y)
(format t "X=~d Y=~d~%" x y)
(+ x y) ;See how the innermost expression matches in the LET* ?
) ;This parens moved down a line to more clearly show end of (lambda...
(* x x))
) ;Same here
6)
X=6 Y=36
42
Note the dataflow in both correct and incorrect cases is the same, if
you ignore the bindings, but respecting the bindings they are different
(+ at bends below aren't addition, just bends, beware, only + or *
inside a triangle is a function call):
Correct: 6[x]--+-->+
| | |
| +-----+
| \ * / ;Computes x*x
| \ /
| V
| 36
| [y]
+-+ |
| |
+-----+
\ + /
\ /
V
42
Wrong: 6[x]-->[y]->+ ;Binds y too early, oops!
| | |
| +-----+
| \ * / ;Computes y*y instead, oops, two wrongs make a right??
| \ /
| V
| 36
| |
+---+ |
| |
+-----+
\ + /
\ /
V
42
Because the dataflow, ignoring bindings, is the same, you get the
correct result, but not for the correct reason as was the intention of
the lesson in the book. If all you wanted was the correct answer, 42,
by the correct arithmetic dataflow, but without the correct bindings,
you could have written just:
(+ x (* x x)).
Remember:
(let ((var --valueexpr--))
--innerexpr--)
is the same as
((lambda (var)
--innerexpr--)
--valueexpr--)
As a fun exercise, you might write a program that automatically
translates:
(let* ((var1 --valueexpr1--)
(var2 --valueexpr2--))
--innerexpr--)
into the appropriate lambda equivalent:
((lambda (var1)
((lambda (var2)
--innerexpr--
)
--valueexpr2--)
)
--valueexpr1--)
For this first attempt, don't bother with any cases except exactly two
variables and one inner expression.
Your second attempt is not correct but is cute. I've labeled the two
bindings of x to make it clear what's going on:
> ((lambda (x1)
> ((lambda (x2 y)
> (+ x2 y))
> x1 (* x1 x1)) ;x2 is bound to value of x1, y is bound to (* x1 x1)
> )
> 6))
Copying the original correct diagram and modifying it slightly:
Cute: 6[x1]--+-->+
| | |
| +-----+
| \ * / ;Computes x*x
| \ /
V V
6 36
[x2] [y]
+--+ |
| |
+-----+
\ + /
\ /
V
42
If you just delete the re-binding of x, you'd have the correct answer.
I suppose you didn't realize that Common LISP satisfies lexical
accessibility of variables, so the inner form can "see" the binding of
X from the outer form, you don't have to bring that value inside the
inner form by re-binding it there.
Note if you defined global functions via DEFUN, each with a different
name, nothing nested inside anything else, you *would* need to bring x
as a formal parameter into the inner function:
(defun outer-function (x)
(inner-function x (* x x))
(defun inner-function (x y)
(+ x y))
(outer-function 6)
calls (inner-function 6 36) which returns 42
So your second guess is actually correct if you don't understand the
idea of lexical variables causing a "closure" whereby free references
to some outer variable from with an inner lambda function nevertheless
actually do work. That's why things like this work correctly:
(let ((x 5))
(mapcar (function (lambda (y) (+ x y)))
'(3 5 7)))
==> (8 10 12)
If that reference to the variable x from inside the + expression inside
the lambda function didn't "see" the x from the let, it'd try to look
up a global value for x instead, unless x was declared special, what we
had to do all the time back in the UCI-LISP and MacLISP days, sigh.
Lexical scope of variables fixes those nuisances!!
So I guess I'd give you credit for your second guess if you didn't know
about lexical scope of variables yet.
I would have expected something a little more along the lines of the
following, which is just an expansion of the LET form into LAMBDAs.
((lambda (x)
((lambda (y) (+ x y))
(* x x)))
6)
In each case, you introduce one binding with the lambda and then apply
the resulting function to the value from the let form. The body of the
let become the boddy of the innermost nested lambda. The lambda binding
X is applied to 6 and the lambda binding Y is applied to (* X X). Your
*TEST2* solution came close, but introduced a second X binding. The key
insight is that you don't need that second binding, because the outer
lambda's binding is available in the body of the inner lambda.
Historic Note: Some early Lisp systems implemented LET as a macro that
expanded into just such lambda expressions.
--
Thomas A. Russ, USC/Information Sciences Institute