<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2963" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face="Courier New" size=2>Hi,</FONT></DIV>
<DIV><FONT face="Courier New" size=2>There is a good chance that the compiler
optimizes this for you.</FONT></DIV>
<DIV><FONT face="Courier New" size=2>Code in conventional and good style is
better optimized than tweaky code, because conventional and good style code is
easier 'understood' by the optimizer, I think.</FONT></DIV>
<DIV><FONT face="Courier New" size=2>Jos Koot</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV>((((lambda(x)((((((x x)x)x)x)x)x))<BR> (lambda(x)(lambda(y)(x(x
y)))))<BR> (lambda(x)(write x)x))<BR> "greetings, Jos") </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=albert.neu@gmail.com href="mailto:albert.neu@gmail.com">Albert
Neumüller</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=plt-scheme@list.cs.brown.edu
href="mailto:plt-scheme@list.cs.brown.edu">plt-scheme@list.cs.brown.edu</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, September 19, 2006 9:37
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [plt-scheme] Re: Scheme
efficiency guidelines (or: the fastest wayto calc a cartesian product)</DIV>
<DIV><BR></DIV>Hi!<BR><BR>Consider the following code (that I've just
seen):<BR><BR>(define (length=2? any)<BR> (and (cons?
any)<BR> (cons? (rest
any))<BR> (empty? (rest (rest any)))))<BR><BR>I
would have written (or rearranged the code of) length=2? like
this:<BR><BR>(define (lenght=2? any)<BR> (and (cons?
any)<BR> (local ((define the-rest (rest
any)))<BR> (and (cons?
the-rest)<BR>
(empty? (rest the-rest))))))<BR><BR>This avoids evaluating (rest any)
twice.<BR>But who knows - maby setting up a "local define" thus putting
the<BR>pointer (or however it is done) into memory (and later
garbage<BR>collecting it) is actually less<BR>efficient than just doing the
evaluation twice!?<BR><BR>This is the sort of thing I am interested in. Of
course it depends on<BR>the scheme interpreter that's used and other
factors.<BR>But I suppose on average, there could be some coding guidelines
or<BR>conventions - for speed-efficiency, for readability,
for<BR>memory-efficiency.<BR><BR><BR>On the otherhand, Scheme probably shines
more for its elegance, than<BR>for its speed, so maby most people using
Scheme, favour elegent code,<BR>rather than speed -<BR>and I'd rather code the
way people in the<BR>Scheme-community code (and know what style is favoured),
than try and push<BR>speed-efficiency in a language whose main purpose is not
speed-efficieny in the<BR>first place.<BR><BR>Which lenght=2? would you use?
How would you write cartesian product?<BR><BR>Any kind comments
welcome!<BR><BR>Kind
regards,<BR>Albert<BR>_________________________________________________<BR>
For list-related administrative tasks:<BR> <A
href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</A></BLOCKQUOTE></BODY></HTML>