From: ·················@gmail.com
Subject: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <1176813417.400206.195320@d57g2000hsg.googlegroups.com>
I just learned some lisp, and after usual book samples, i made port of
my old program to lisp and  started a dynamic web  project.
I pay my rent doing Deplhi and some Basic(i know Basic sucks but money
aren't  bad) ,so recently i've noticed that i do things differently
than  before i started with lisp.
Things  like :avoiding assignment, functions instead of procedures,
fewer fields in the class, using TList and TStringList instead of
array,  creating  locally SQL Dataset and Queries,
fewer local variables etc
I found this style denser and easier to read but i'm afraid that this
isn't very efficient,
especially  i fear Greenspun's Tenth.

Does anybody had a similiar experience?

Pet

From: Rob St. Amant
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <f02p5c$4s$1@blackhelicopter.databasix.com>
·················@gmail.com writes:

> Does anybody had a similiar experience?

There's a purely stylistic thing I've noticed about the way I write C
code (when I have to): I tend to spell out variable names
consistently.  For example, I was adding onto a moderately-sized C++
graphics program some time ago, and IIRC the variable name I'd have
used in Lisp, pixel-color, had been rendered (so to speak) pix_col,
pxl_col, PixCol, and various other ways in different places in the
program.  Aargh.
From: Didier Verna
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <muxwt0bxiq0.fsf@uzeb.lrde.epita.fr>
·················@gmail.com wrote:

> Does anybody had a similiar experience?

That's a long time ago, but I think Lisp influenced my C style in some
respects, like naming conventions (predicates ending with a p and
stuff). Also, I found myself writing a lot of preprocessors wrappers
like WITH_OPEN_FILE ( ... ) { ... }  or the like.

Not sure that's a good thing though. It probably makes your code less
readable by other people, and in the end, it's probably better to stick
to the native way of your language and make beauty out if (read the
jazzblog ;-).

-- 
Read the Jazz Blog !! http://jazzblog.didierverna.com

Didier Verna, ······@lrde.epita.fr, http://www.lrde.epita.fr/~didier

EPITA / LRDE, 14-16 rue Voltaire   Tel.+33 (1) 44 08 01 85
94276 Le Kremlin-Bic�tre, France   Fax.+33 (1) 53 14 59 22   ······@xemacs.org
From: Ken Tilton
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <ML8Vh.32$r%3.8@newsfe12.lga>
·················@gmail.com wrote:
> I just learned some lisp, and after usual book samples, i made port of
> my old program to lisp and  started a dynamic web  project.
> I pay my rent doing Deplhi and some Basic(i know Basic sucks but money
> aren't  bad) ,so recently i've noticed that i do things differently
> than  before i started with lisp.
> Things  like :avoiding assignment, functions instead of procedures,
> fewer fields in the class, using TList and TStringList instead of
> array,  creating  locally SQL Dataset and Queries,
> fewer local variables etc
> I found this style denser and easier to read but i'm afraid that this
> isn't very efficient,
> especially  i fear Greenspun's Tenth.
> 
> Does anybody had a similiar experience?

No, I was already doing my best to write in a functional and OO and meta 
style when I discovered Lisp, so it was more like cutting loose a sea 
anchor.

As for the effect on my coding in other languages, does eliminating it 
count?

kxo


-- 
http://www.theoryyalgebra.com/

"Algebra is the metaphysics of arithmetic." - John Ray

"As long as algebra is taught in school,
there will be prayer in school." - Cokie Roberts

"Stand firm in your refusal to remain conscious during algebra."
    - Fran Lebowitz

"I'm an algebra liar. I figure two good lies make a positive."
    - Tim Allen
From: Dan Bensen
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <f03hmm$ck6$1@wildfire.prairienet.org>
Ken Tilton wrote:
> No, I was already doing my best to write in a functional and OO and meta 
> style when I discovered Lisp

I had a similar experience.  I had no technical supervision when I was
writing C++ code, so it was drenched in macros.  I was horrified when
I discovered that people frown on that in every language except Lisp.

-- 
Dan
www.prairienet.org/~dsb/
From: Frank Buss
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <8mvnhb9wefdp$.14ydckfewa5p$.dlg@40tude.net>
Dan Bensen wrote:

> I had a similar experience.  I had no technical supervision when I was
> writing C++ code, so it was drenched in macros.  I was horrified when
> I discovered that people frown on that in every language except Lisp.

You mean the preprocessor #define macros, like e.g. misused in MFC? If I
had to maintain such code, I would be horrified, too :-) In C++ you could
use template metaprogramming for creating nice usable code by the
application programmer. Unlike #define macros, C++ templates are turing
complete, so in theory you can write anything what you can do with Lisp
macros with C++ templates, too.

-- 
Frank Buss, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
From: John Thingstad
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <op.tqyasvhupqzri1@pandora.upc.no>
On Wed, 18 Apr 2007 00:57:27 +0200, Frank Buss <··@frank-buss.de> wrote:

> Dan Bensen wrote:
>
>> I had a similar experience.  I had no technical supervision when I was
>> writing C++ code, so it was drenched in macros.  I was horrified when
>> I discovered that people frown on that in every language except Lisp.
>
> You mean the preprocessor #define macros, like e.g. misused in MFC? If I
> had to maintain such code, I would be horrified, too :-) In C++ you could
> use template metaprogramming for creating nice usable code by the
> application programmer. Unlike #define macros, C++ templates are turing
> complete, so in theory you can write anything what you can do with Lisp
> macros with C++ templates, too.
>

I remember working with one of the first versions of STL under a
Borland compiler. It was a nightmare. Sure it was great when it worked.
But when it failed it was never clear what failed.
The error occurred way away form the code that caused the error and the  
message
was cryptic.
There was no way to expand a template and see if it worked as
expected. Then there was the fact the the implementation of STL was
it self full of bugs.
The only way to find these bugs was to remove half the program.
If the problem persisted paste the code back in. remove half of
the remaining code. So by binary search you would eventually find the
offending line. Then you had to work your way back to the template and fix  
it.
It often took half a day to fix one bug.

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
From: Tim X
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <87hcrbzuht.fsf@lion.rapttech.com.au>
Frank Buss <··@frank-buss.de> writes:

> Dan Bensen wrote:
>
>> I had a similar experience.  I had no technical supervision when I was
>> writing C++ code, so it was drenched in macros.  I was horrified when
>> I discovered that people frown on that in every language except Lisp.
>
> You mean the preprocessor #define macros, like e.g. misused in MFC? If I
> had to maintain such code, I would be horrified, too :-) In C++ you could
> use template metaprogramming for creating nice usable code by the
> application programmer. Unlike #define macros, C++ templates are turing
> complete, so in theory you can write anything what you can do with Lisp
> macros with C++ templates, too.
>

Its been over 12 years since I had to write any C++ and I've been told C++
templates have come a long way, but they must have not only come a long way,
but morphed into a totally new beastie if they can now generate 'nice usable
code"! Back then, they didn't even behave consistently between different
compilers (or even compiler versions in some cases). 

I'll readily admit having a strong bias against C++. This often seems strange
even to me since my first language (and consequently, still one of my
favorites) was C. 

I rarely use C anymore because I find it hard to justify the additional work
required compared to using almost any of the other languages I now have skill
in. It seems these days, development time is a much bigger factor than it use
to be and generally, the systems I find myself working on are larger and more
complex. 

Lisp is what I like to use now when exploring solutions or gaining more
understanding of input data sets etc. It allows me to do things in a 'quick and
dirty' style that seems to actually be doing what you expect. 

Tim
 

-- 
tcross (at) rapttech dot com dot au
From: Chris Russell
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <1177099836.431563.35340@d57g2000hsg.googlegroups.com>
On Apr 17, 11:57 pm, Frank Buss <····@frank-buss.de> wrote:
> Dan Bensen wrote:
> > I had a similar experience.  I had no technical supervision when I was
> > writingC++code, so it was drenched in macros.  I was horrified when
> > I discovered that people frown on that in every language except Lisp.
>
> You mean the preprocessor #define macros, like e.g. misused in MFC? If I
> had to maintain such code, I would be horrified, too :-) InC++you could
> use template metaprogramming for creating nice usable code by the
> application programmer. Unlike #define macros,C++templates are turing
> complete, so in theory you can write anything what you can do with Lisp
> macros withC++templates, too.
>
> --
> Frank Buss, ····@frank-buss.dehttp://www.frank-buss.de,http://www.it4-systems.de

Ha. I wish. In this context Turing complete just means that any
algorithm output can theoretically be precomputed.
Not that you can transform any arbitrary text into an arbitrary code
expression.
It also makes no guarantees about what type of output you can get from
your pre-processor, I think the only things you can get out are
recursively defined objects and ints.

Chris
From: Frank Buss
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <6woxdwehi1lb.1a5a7krycyx6h$.dlg@40tude.net>
Chris Russell wrote:

> Ha. I wish. In this context Turing complete just means that any
> algorithm output can theoretically be precomputed.
> Not that you can transform any arbitrary text into an arbitrary code
> expression.

But C++ programmers wouldn't think that this is a restriction. You have to
use the restrictions of the syntax of the language, but within these rules
you can implement arbitrary transformations (but with some problems for the
destination of the transformation, because you have to find clever tricks
how to implement your ideas in a way that it can be expressed as a
transformation result). The advantage of the restrictions is more checks at
compile time.

Of course, I like more the Lisp way of macros. Looks like the simpler the
syntax of a computer language, the easier it is to express more complex
ideas. I wonder how simple a language can be and still be useful, like
Forth, which is even simpler than Lisp and where interesting
implementations with modern concepts like GC and continuations exists, like
http://factorcode.org/

-- 
Frank Buss, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
From: Frank Buss
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <195qxlu9j1acb$.l3ypt0a8a6aq.dlg@40tude.net>
·················@gmail.com wrote:

> I found this style denser and easier to read but i'm afraid that this
> isn't very efficient,
> especially  i fear Greenspun's Tenth.

You can benchmark your program and optimize it, if it is too slow, e.g.
using again arrays for time critical parts instead of lists (same in Lisp),
but I don't think that it hurts performance much, because the compiler can
optimize. And if you have already functions for list manipulation in
Delphi, it's not Greenspun's Tenth, unless you don't start writing things
like "eval", "compile" and "defmacro".

> Does anybody had a similiar experience?

Yes. I'm developing in Java and C++ for money and e.g. I'm writing
functions with less side-effects.

Try Forth, too, it will change your coding style again, e.g. using much
shorter functions. The very good book "The Pragmatic Programmer" suggests
to learn at least one new computer language every year. Even if you don't
use it, some concepts may be usable with your current language.

-- 
Frank Buss, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
From: ·················@gmail.com
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <1176821146.880591.222360@d57g2000hsg.googlegroups.com>
On Apr 17, 3:10 pm, Frank Buss <····@frank-buss.de> wrote:
> ·················@gmail.com wrote:
> > I found this style denser and easier to read but i'm afraid that this
> > isn't very efficient,
> > especially  i fear Greenspun's Tenth.
>
> You can benchmark your program and optimize it, if it is too slow, e.g.
> using again arrays for time critical parts instead of lists (same in Lisp),
> but I don't think that it hurts performance much, because the compiler can
> optimize. And if you have already functions for list manipulation in
> Delphi, it's not Greenspun's Tenth, unless you don't start writing things
> like "eval", "compile" and "defmacro".
>
> > Does anybody had a similiar experience?
>
> Yes. I'm developing in Java and C++ for money and e.g. I'm writing
> functions with less side-effects.
>
> Try Forth, too, it will change your coding style again, e.g. using much
> shorter functions.
I'm currently in love with s-expression but maybe later .

>The very good book "The Pragmatic Programmer" suggests
> to learn at least one new computer language every year. Even if you don't
> use it, some concepts may be usable with your current language.
>
> --
> Frank Buss, ····@frank-buss.dehttp://www.frank-buss.de,http://www.it4-systems.de

I already did, and feels pretty meatless compared with The Practice of
Programming,
more like something managers should read .

Pet
From: Dan Bensen
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <f03h5n$ce9$1@wildfire.prairienet.org>
·················@gmail.com wrote:
> On Apr 17, 3:10 pm, Frank Buss <····@frank-buss.de> wrote:
>> The very good book "The Pragmatic Programmer" suggests
>> to learn at least one new computer language every year. Even if you don't
>> use it, some concepts may be usable with your current language.
> I already did, and feels pretty meatless compared with The Practice of
> Programming, more like something managers should read .

Managers need to read Peopleware.  TPP isn't heavily technical,
and it is a good book for somewhat technically experienced managers,
but it also has plenty of info about software design and good
development practices.

-- 
Dan
www.prairienet.org/~dsb/
From: Tim X
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <87lkgnzv8u.fsf@lion.rapttech.com.au>
Frank Buss <··@frank-buss.de> writes:

>
> Yes. I'm developing in Java and C++ for money and e.g. I'm writing
> functions with less side-effects.
>
> Try Forth, too, it will change your coding style again, e.g. using much
> shorter functions. The very good book "The Pragmatic Programmer" suggests
> to learn at least one new computer language every year. Even if you don't
> use it, some concepts may be usable with your current language.
>

I tend to agree. Learning new languages, especially ones that are substantially
different to what you normally work in, are a useful way of both gaining
appreciation for alternative approaches and often for learning new techniques. 

For me, lisp both affected by coding style and introduced me to a more
exploratory way of solving problems. While I don't get to use lisp in my paid
employment, I often spend time testing ideas and exploring solutions in lisp
that I later implement at work in other languages. Much of my personal working
environment is also customized/controlled through various lisp based languages
such as lush, guile, rep, elisp etc. 

tim

-- 
tcross (at) rapttech dot com dot au
From: Sacha
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <X%7Vh.125284$EG4.964665@phobos.telenet-ops.be>
·················@gmail.com wrote:
> I just learned some lisp, and after usual book samples, i made port of
> my old program to lisp and  started a dynamic web  project.
> I pay my rent doing Deplhi and some Basic(i know Basic sucks but money
> aren't  bad) ,so recently i've noticed that i do things differently
> than  before i started with lisp.
> Things  like :avoiding assignment, functions instead of procedures,
> fewer fields in the class, using TList and TStringList instead of
> array,  creating  locally SQL Dataset and Queries,
> fewer local variables etc

Just a little note:

Delphi's TList and TStringList really are arrays underneath.
It is _very_ inefficient using these as the lisp linked lists.

The good news is that it's very easy to implement a linked list in any 
language. So you're free to greenspun all you want !

Sacha
From: Pascal Costanza
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <58kibuF14jocdU1@mid.individual.net>
·················@gmail.com wrote:
> I just learned some lisp, and after usual book samples, i made port of
> my old program to lisp and  started a dynamic web  project.
> I pay my rent doing Deplhi and some Basic(i know Basic sucks but money
> aren't  bad) ,so recently i've noticed that i do things differently
> than  before i started with lisp.
> Things  like :avoiding assignment, functions instead of procedures,
> fewer fields in the class, using TList and TStringList instead of
> array,  creating  locally SQL Dataset and Queries,
> fewer local variables etc
> I found this style denser and easier to read but i'm afraid that this
> isn't very efficient,
> especially  i fear Greenspun's Tenth.
> 
> Does anybody had a similiar experience?

Recently, I have hacked a few Java examples again. Yes, the Java code 
that I write now is better than that I have written before. I don't 
attribute this so much to Lisp as such, but rather to the broader range 
of programming styles that Lisp enables. Lisp gives you a lot more 
freedom to switch between various programming styles, and I now kind of 
expect that from other languages as well. Before, I guess I have 
subconsciously tried to stick to a more purist OOP approach (although I 
have never actually been a real purist, but that's a different story).

The essence of Greenspun's Tenth Rule (as I understand it) is not so 
much the inefficiency, but the boilerplate you have to (re)create to get 
at the same level of expressiveness as in Common Lisp, which in the end 
will of course create an overhead because this is essentially all 
infrastructure code that is systematically applied everywhere. You can 
notice that effect, for example, when lots of design patterns are used 
in some framework or in an application to make the code more flexible, 
"just in case."

However, if you use a couple of idioms every now and then to simulate 
various Lispy constructs, I don't think this will seriously hurt. 
Micro-efficiency is generally far too overrated and rarely makes an 
important difference.


Pascal

-- 
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: ·······@gmail.com
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <1176873667.931624.62390@d57g2000hsg.googlegroups.com>
On Apr 17, 8:36 am, ·················@gmail.com wrote:
> I just learned some lisp, and after usual book samples, i made port of
> my old program to lisp ...
> I found this style denser and easier to read but i'm afraid that this
> isn't very efficient,
> especially  i fear Greenspun's Tenth.
>
> Does anybody had a similiar experience?
>
> Pet

This is what happened to me:

I used to count the number of 1's in the binary expansion of an
unsigned int in C like this:

int bits(unsigned n) {
    int i = 0;
    while (n > 0) {
       n &= n-1;
       i++;
    }
   return i;
}

In Lisp this became


(defun lsb (n i)
           (cond
             ((eq n 0) i)
             (T (lsb (logand (- n 1) n) (+ i 1)))
           )
         )

(defun bits (n) (lsb n 0))

after which, this is what happened to my C code

int functional( int (*f)(unsigned n, i), unsigned n, int i) {
    if (!n) return i;
   return f(n & (n-1), i+1);
}

int fixedpoint(unsigned n, int i) {
    return functional(fixedpoint, n, i);
}

int bits(unsigned n) {
  return fixedpoint(n, 0);
}
From: Rob Warnock
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <yqudnbocodd3SbjbnZ2dnUVZ_vXinZ2d@speakeasy.net>
·······@gmail.com <·······@gmail.com> wrote:
+---------------
| I used to count the number of 1's in the binary expansion of an
| unsigned int in C like this:
| 
| int bits(unsigned n) {
|     int i = 0;
|     while (n > 0) {
|        n &= n-1;
|        i++;
|     }
|    return i;
| }
| 
| In Lisp this became
| 
| (defun lsb (n i)
|            (cond
|              ((eq n 0) i)
|              (T (lsb (logand (- n 1) n) (+ i 1)))
|            )
|          )
| 
| (defun bits (n) (lsb n 0))
+---------------

Which, after learning a little more CL, should have
resulted in just using CL's builtin LOGCOUNT instead...  ;-}  ;-}


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Brian Adkins
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <pan.2007.04.18.15.21.00.797252@gmail.com>
On Wed, 18 Apr 2007 03:20:58 -0500, Rob Warnock wrote:

> ·······@gmail.com <·······@gmail.com> wrote:
> +---------------
> | I used to count the number of 1's in the binary expansion of an
> | unsigned int in C like this:
> | 
> | int bits(unsigned n) {
> |     int i = 0;
> |     while (n > 0) {
> |        n &= n-1;
> |        i++;
> |     }
> |    return i;
> | }
> | 
> | In Lisp this became
> | 
> | (defun lsb (n i)
> |            (cond
> |              ((eq n 0) i)
> |              (T (lsb (logand (- n 1) n) (+ i 1)))
> |            )
> |          )
> | 
> | (defun bits (n) (lsb n 0))
> +---------------
> 
> Which, after learning a little more CL, should have
> resulted in just using CL's builtin LOGCOUNT instead...  ;-}  ;-}

Cool. Although, doesn't that only work for half the values (i.e. ones with
MSB off) ?

> 
> 
> -Rob
> 
> -----
> Rob Warnock			<····@rpw3.org>
> 627 26th Avenue			<URL:http://rpw3.org/> San Mateo, CA 94403
> (650)572-2607
From: Rob Warnock
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <DvydnUNv5oc6Q7vbnZ2dnUVZ_oSnnZ2d@speakeasy.net>
Brian Adkins  <·················@gmail.com> wrote:
+---------------
| Rob Warnock wrote:
| > Which, after learning a little more CL, should have
| > resulted in just using CL's builtin LOGCOUNT instead...  ;-}  ;-}
| 
| Cool. Although, doesn't that only work for half the values
| (i.e. ones with MSB off) ?
+---------------

What is this "MSB" thing of which you speak?!?  ;-}  ;-}
Unlimited-precision integers don't *have* an
"MSB" per se. If you really, really need a
finite-width integer, then force it to be such:

    (logcount (logand x #.(1- (ash 1 +word-width+))))

E.g.:

    > (defparameter +word-width+ 32)

    +WORD-WIDTH+
    > (let ((x -375))
	(list (logcount x)  ; For negative values, counts zeros instead.
	      (logcount (logand x #.(1- (ash 1 +word-width+))))))

    (6 26)
    > 


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: ·······@gmail.com
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <1177397017.206640.16270@n35g2000prd.googlegroups.com>
On Apr 18, 11:14 pm, ····@rpw3.org (Rob Warnock) wrote:
> Brian Adkins  <·················@gmail.com> wrote:
> +---------------| Rob Warnock wrote:
>
> | > Which, after learning a little more CL, should have
> | > resulted in just using CL's builtin LOGCOUNT instead...  ;-}  ;-}
> |
> | Cool. Although, doesn't that only work for half the values
> | (i.e. ones with MSB off) ?
> +---------------
>
> What is this "MSB" thing of which you speak?!?  ;-}  ;-}
> Unlimited-precision integers don't *have* an
> "MSB" per se. If you really, really need a
> finite-width integer, then force it to be such:
>
>     (logcount (logand x #.(1- (ash 1 +word-width+))))
>
> E.g.:
>
>     > (defparameter +word-width+ 32)
>
>     +WORD-WIDTH+
>     > (let ((x -375))
>         (list (logcount x)  ; For negative values, counts zeros instead.
>               (logcount (logand x #.(1- (ash 1 +word-width+))))))
>
>     (6 26)
>     >
>
> -Rob
>
> -----
> Rob Warnock                     <····@rpw3.org>
> 627 26th Avenue                 <URL:http://rpw3.org/>
> San Mateo, CA 94403             (650)572-2607


Here's a most significant bit function, which I define as the largest
power of two appearing in the binary expansion of a nonnegative
integer (I'm not considering negatives). This and the trick for
killing off the least significant bit can be used to compute the Grey
code permutation of the natural numbers.

First, I need to kill least significant bits (of a non-negative
integer):

(DEFUN KILL-LSB (n) (LOGAND (- n 1) n))

I use that to compute the MSB (of a non-negative integer)

(DEFUN MSB (n)
           (COND ((EQUAL (KILL-LSB n) 0) n)
                 (T (MSB (KILL-LSB n)))))

You can use MSB to compute the Grey permutation GREY:N ->N; this is
defined in Knuth's TAOCP, Volume 4 Fascicle 2, Generating All Tuples
and
Permutations (2005).

(DEFUN GREY  (n)
       (COND
         ((= n 0) 0)
         ((= n 1) 1)
         (T (LET ((x (MSB n))) (+ x (GREY (- (- x 1) (- n x))))))))

Restricting the domain and range of the GREY map to [0, 2^n -1]
is a (well-defined) permutation; for example:

CL-USER> (MAPCAR #'GREY '(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15))
(0 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8)

P.S.

;-) ;-) (^_^)
From: fireblade
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <1177402773.674750.61760@t39g2000prd.googlegroups.com>
A bit of my code though( i doubt it'll get a proper formatting)
TServiceReply.Create(Self,
                               FieldByName('FromClient').AsString,
                               FieldByName('DocNo').AsString,
                               FieldByName('DocType').AsString,
                               FieldByName('wYear').AsString,
                              getEmailFromUsername
 
(ClientDataSet2.FieldByName('UserName').AsString),
                              StringReplace
 
(ClientDataSet2.FieldByName('MailCc').AsString,
                              getEmailFromUsername(appUser)+ ';',
                              '',[rfReplaceAll, rfIgnoreCase]),
                              StringReplace
 
(ClientDataSet2.FieldByName('MailBcc').AsString,
                              getEmailFromUsername(appUser)+ ';',
                              '',[rfReplaceAll, rfIgnoreCase]),
 
ClientDataSet2.FieldByName('Subject').AsString,
 
getFirstAndLastNameFromUsername(appUser),
 
ClientDataSet2.FieldByName('DocLine').AsInteger);
From: Brian Adkins
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <pan.2007.04.18.15.18.10.790775@gmail.com>
On Tue, 17 Apr 2007 22:21:07 -0700, ·······@gmail.com wrote:

> On Apr 17, 8:36 am, ·················@gmail.com wrote:
>> I just learned some lisp, and after usual book samples, i made port of
>> my old program to lisp ...
>> I found this style denser and easier to read but i'm afraid that this
>> isn't very efficient,
>> especially  i fear Greenspun's Tenth.
>>
>> Does anybody had a similiar experience?
>>
>> Pet
> 
> This is what happened to me:
> 
> I used to count the number of 1's in the binary expansion of an
> unsigned int in C like this:
> 
> int bits(unsigned n) {
>     int i = 0;
>     while (n > 0) {
>        n &= n-1;
>        i++;
>     }
>    return i;
> }
> 
> In Lisp this became
> 
> 
> (defun lsb (n i)
>            (cond
>              ((eq n 0) i)
>              (T (lsb (logand (- n 1) n) (+ i 1)))
>            )
>          )
> 
> (defun bits (n) (lsb n 0))
> 
> after which, this is what happened to my C code
> 
> int functional( int (*f)(unsigned n, i), unsigned n, int i) {
>     if (!n) return i;
>    return f(n & (n-1), i+1);
> }
> 
> int fixedpoint(unsigned n, int i) {
>     return functional(fixedpoint, n, i);
> }
> 
> int bits(unsigned n) {
>   return fixedpoint(n, 0);
> }

So, you're saying that learning Lisp caused you to write C code in 25%
more lines and that takes 2.5 times longer to run than before? :)
From: =?windows-1251?Q?Torsten_Zu=22hlsdorff?=
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <f04k77$q2h$1@registered.motzarella.org>
·················@gmail.com schrieb:
> I just learned some lisp, and after usual book samples, i made port of
> my old program to lisp and  started a dynamic web  project.
[..]
> 
> Does anybody had a similiar experience?

Yes. Normally i use PHP, but while learning LISP i wrote many
PHP-Scripts which "rebuild" some LISP-Features in a very simple way -
for example Macros. It is not the orignal, but better than none of them :P
And if i wrote a little interpreter (interpreted by PHP) i used the
LISP-Syntax.

Bye,
Torsten
From: Tamas
Subject: Re: Does learning Lisp changes the way of your coding in other languages?
Date: 
Message-ID: <1176931635.603175.179240@l77g2000hsb.googlegroups.com>
On Apr 17, 8:36 am, ·················@gmail.com wrote:
> I just learned some lisp, and after usual book samples, i made port of
> my old program to lisp and  started a dynamic web  project.
> I pay my rent doing Deplhi and some Basic(i know Basic sucks but money
> aren't  bad) ,so recently i've noticed that i do things differently
> than  before i started with lisp.
> Things  like :avoiding assignment, functions instead of procedures,
> fewer fields in the class, using TList and TStringList instead of
> array,  creating  locally SQL Dataset and Queries,
> fewer local variables etc
> I found this style denser and easier to read but i'm afraid that this
> isn't very efficient,
> especially  i fear Greenspun's Tenth.
>
> Does anybody had a similiar experience?
>
> Pet

I am a Lisp newbie, who has been using Lisp for less than a few
weeks.  I still do my urgent projects in R (a fine numerical language,
first-order functions, etc) but recently I find that I am getting
frustrated because I can't use powerful Lisp constructs in other
languages.

Tamas