Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Newbie - 2 Small problems
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 64 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dr. Edmund Weitz  
View profile  
 More options Mar 9 2002, 9:21 pm
Newsgroups: comp.lang.lisp
From: e...@agharta.de (Dr. Edmund Weitz)
Date: 10 Mar 2002 03:21:09 +0100
Local: Sat, Mar 9 2002 9:21 pm
Subject: Re: Newbie - 2 Small problems

TejimaNoHimitsu <b...@test.com> writes:
> I'm not sure if this is the right place to ask, but since it is a lisp
> forum I thought it couldn't hurt ;)

> 1)  Is there any way to test for option arguments in a function?  For
> example, if I do:

> (defun test (list1 list2 &key k)

> is there a way to test in the body of that function whether or not k
> exists?  If k doesn't exist, the value is NIL, but I don't know how to
> compare if something's value is NIL.  I know I should know, but I
> don't.  I would use an if statement, but k is either NIL or the key
> value....  

  * (defun bar (&key (foo nil supplied-foo-p))
      (format t "~%foo is ~A" foo)
      (format t "~%foo was ~Aprovided" (if supplied-foo-p "" "not ")))
  BAR
  * (bar)
  foo is NIL
  foo was not provided
  NIL
  * (bar :foo nil)
  foo is NIL
  foo was provided
  NIL
  * (bar :foo 'baz)
  foo is BAZ
  foo was provided
  NIL

See 3.4.1 of the CLHS for details.

> 2) is there an easy way to swap items in a list?  For example, I
> want to swap the 2nd and 4th items in the list '(1 4 3 2 5)....  is
> there an easy way to do it? I can't explicitly set the value of an
> element in a list, can I?

  * (defparameter *my-list* '(1 2 3 4 5))
  *MY-LIST*
  * (rotatef (second *my-list*) (fourth *my-list*))
  NIL
  * *my-list*
  (1 4 3 2 5)
  * (setf (third *my-list*) 42)
  42
  * *my-list*
  (1 4 42 2 5)

HTH,
Edi.

--

Dr. Edmund Weitz
Hamburg
Germany

The Common Lisp Cookbook
<http://cl-cookbook.sourceforge.net/>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Parker  
View profile  
 More options Mar 9 2002, 9:31 pm
Newsgroups: comp.lang.lisp
From: Michael Parker <desp...@pdq.net>
Date: Sat, 09 Mar 2002 20:31:05 -0600
Local: Sat, Mar 9 2002 9:31 pm
Subject: Re: Newbie - 2 Small problems

TejimaNoHimitsu wrote:

> I'm not sure if this is the right place to ask, but since it is a lisp
> forum I thought it couldn't hurt ;)

> 1)  Is there any way to test for option arguments in a function?  For
> example, if I do:

> (defun test (list1 list2 &key k)

> is there a way to test in the body of that function whether or not k
> exists?  If k doesn't exist, the value is NIL, but I don't know how to
> compare if something's value is NIL.  I know I should know, but I
> don't.  I would use an if statement, but k is either NIL or the key
> value....

(defun test (list1 list2 &key (k nil k-supplied-p))
 ...)

> 2)  is there an easy way to swap items in a list?  For example, I want
> to swap the 2nd and 4th items in the list '(1 4 3 2 5)....  is there
> an easy way to do it?  I can't explicitly set the value of an element
> in a list, can I?

Sure.  Both elt and nth are setf forms.  As are first, second, third,
etc.
Keep in mind that unlike in Python these functions are linear-time, not
constant-time operations.

1> (setq *foo* (list 'a 'b 'c))
(A B C)

2> (setf (nth 1 *foo*) 'd)
D

3> *foo*
(A D C)

4> (setf (elt *foo* 2) 'e)
E

5> *foo*
(A D E)

> Sorry for the wierd questions.  I've been trying to figure them out
> for hours but can't =(

> Thanks!

The CLHS is your friend.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kent M Pitman  
View profile  
 More options Mar 9 2002, 9:39 pm
Newsgroups: comp.lang.lisp
From: Kent M Pitman <pit...@world.std.com>
Date: Sun, 10 Mar 2002 02:38:58 GMT
Local: Sat, Mar 9 2002 9:38 pm
Subject: Re: Newbie - 2 Small problems
e...@agharta.de (Dr. Edmund Weitz) writes:

> > 2) is there an easy way to swap items in a list?  For example, I
> > want to swap the 2nd and 4th items in the list '(1 4 3 2 5)....  is
> > there an easy way to do it? I can't explicitly set the value of an
> > element in a list, can I?

>   * (defparameter *my-list* '(1 2 3 4 5))
>   *MY-LIST*
>   * (rotatef (second *my-list*) (fourth *my-list*))
>   NIL
>   * *my-list*
>   (1 4 3 2 5)
>   * (setf (third *my-list*) 42)
>   42
>   * *my-list*
>   (1 4 42 2 5)

However, note that it will traverse the list twice to do this.  lists
elements are directly accessed, they are obtained by cdr'ing down the
chain of conses each time.

Usually, if you are going to be swapping arbitrary elements, it's a
hint that you do not want a list as your basic data structure.  This
is a basic issue of algorithmic design and would be true in any
language, except languages that lie to you and tell you that they have
a list data structure when really they are using an array.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve Long  
View profile  
 More options Mar 9 2002, 10:27 pm
Newsgroups: comp.lang.lisp
From: Steve Long <sal6...@hotmail.com>
Date: Sat, 09 Mar 2002 07:47:02 -0800
Local: Sat, Mar 9 2002 10:47 am
Subject: Re: Newbie - 2 Small problems

TejimaNoHimitsu wrote:
> I'm not sure if this is the right place to ask, but since it is a lisp
> forum I thought it couldn't hurt ;)

> 1)  Is there any way to test for option arguments in a function?  For
> example, if I do:

> (defun test (list1 list2 &key k)

> is there a way to test in the body of that function whether or not k
> exists?  If k doesn't exist, the value is NIL, but I don't know how to
> compare if something's value is NIL.  I know I should know, but I
> don't.  I would use an if statement, but k is either NIL or the key
> value....

By exists, you mean (boundp k) is non-nil? I believe an arg always has to
have something bound to it.

> 2)  is there an easy way to swap items in a list?  For example, I want
> to swap the 2nd and 4th items in the list '(1 4 3 2 5)....  is there
> an easy way to do it?  I can't explicitly set the value of an element
> in a list, can I?

Yes.  One non-destructive technique (function) might be

(defun swap-elt (seq n1 n2)
   (let ((new-seq (copy-seq seq)))
     (setf (elt new-seq n1) (elt seq n2))
     (setf (elt new-seq n2) (elt seq n1))
     new-seq))
swap-elt

(setf x '(1 2 3 4 5))
(1 2 3 4 5)

(swap-elt x 1 2)
(1 3 2 4 5)
x
(1 2 3 4 5)

(swap-elt x 0 4)
(5 2 3 4 1)
x
(1 2 3 4 5)

(setf x "god")
god
(swap-elt x 0 2)
dog

Many ways to skin this cat.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Mar 9 2002, 10:46 pm
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.net>
Date: Sun, 10 Mar 2002 03:46:06 GMT
Local: Sat, Mar 9 2002 10:46 pm
Subject: Re: Newbie - 2 Small problems
* TejimaNoHimitsu <b...@test.com>
| Thanks guys!  I really appreciate your help.  I never knew about the
| CLHS....  I'll have to look over this!  =)

  What are you using to learn to program in Common Lisp now?  I really hope
  you have found a textbook, and are not _only_ using documentation that
  comes with your Common Lisp environment.  Both a tutorial on the language
  and the reference will come in very handy very quickly.  There is no
  nutshell handbook on Common Lisp yet, for instance, because the standard
  (CLHS among friends) is sufficient, but it is not pedagogical in nature.

  www.lisp.org is a good start.

///
--
  In a fight against something, the fight has value, victory has none.
  In a fight for something, the fight is a loss, victory merely relief.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rahul Jain  
View profile  
 More options Mar 9 2002, 11:00 pm
Newsgroups: comp.lang.lisp
From: Rahul Jain <rj...@sid-1129.sid.rice.edu>
Date: 09 Mar 2002 21:57:46 -0600
Local: Sat, Mar 9 2002 10:57 pm
Subject: Re: Newbie - 2 Small problems

Michael Parker <desp...@pdq.net> writes:
> Both elt and nth are setf forms. ...
> Keep in mind that unlike in Python these functions are linear-time, not
> constant-time operations.

ELT is neither constant- nor linear-time. (in the big theta sense,
which is what I assume you mean)

ELT is a generic sequence accessor, and so, takes the appropriate
amount of time for the sequence being acessed. If it is a list, it
takes linear time. If it is an array it takes constant-time. Note that
the Real Python (CMUCL's and SBCL's compiler) has the list-accessors
take linear-time. It's just that Fake Python that has the Fake Lambda
and Fake List where accesses take constant-time, and lists can't share
structure. :)

--
-> -/                        - Rahul Jain -                        \- <-
-> -\  http://linux.rice.edu/~rahul -=-  mailto:rj...@techie.com   /- <-
-> -/ "Structure is nothing if it is all you got. Skeletons spook  \- <-
-> -\  people if [they] try to walk around on their own. I really  /- <-
-> -/  wonder why XML does not." -- Erik Naggum, comp.lang.lisp    \- <-
|--|--------|--------------|----|-------------|------|---------|-----|-|
   (c)1996-2002, All rights reserved. Disclaimer available upon request.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Newbie - 2 MORE Small problems?" by Erik Naggum
Erik Naggum  
View profile  
 More options Mar 10 2002, 3:40 pm
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.net>
Date: Sun, 10 Mar 2002 20:40:17 GMT
Local: Sun, Mar 10 2002 3:40 pm
Subject: Re: Newbie - 2 MORE Small problems?
* TejimaNoHimitsu <b...@test.com>
| The above function is supposed to take a predicate, a number, and a
| sorted list of numbers and insert elm into lis at the proper spot
| based on the boolean predicate p.  For example, if you call:
|
| (insert-n-sort #'< 3 '(2 4 6 8))
|
| You should get
|
| (2 3 4 6 8)  back.

  Not to spoil your fun here, but either of these will produce the correct
  result with very little overhead:

(merge 'list (list 3) (list 2 4 6 8) #'<)
(sort (list* 3 (list 2 4 6 8) #'<))

  Please note that sort is destructive, so do not use a quoted argument.

| 1)  How can I change all the setf crap to let statements?  I know it's
| bad form to use setf

  setf is not bad form.  It is bad karma to teach that it is.  Your
  professor may return as a Scheme programmer if he keeps this up.  (Or he
  may done something terrible in his previous life and actually be a Scheme
  programmer.)

  It _is_ bad form to setf a component of a quoted constant, however.

|  I can never get the syntax for let working properly...

  It is really quite simple: (let (<binding>*) <declaration>* <form>*).
  A <binding> has the form (<variable> <value>), or just <variable> if you
  plan to set it before you use it.

| 2)  Is there an easy way to sort the list produced by the mapcar?  By
| easy, I don't mean calling (sort timp #'<)  because we aren't allowed to
| use the sorting function.  In fact, we shouldn't even need to sort the
| list... but that's the only way I can get it to work.  Program is a piece
| of cake in Java, C++, C#, etc.... but I don't know lisp well enough to do
| something like a minsort (hence why I asked how to swap elements)  ;)

  I am so strongly opposed to the pointless exercises in re-inventing the
  wheel using idiotic restrictions in order to learn what a wheel is that I
  think teachers who do this to their students should be terminated.

  Having to reimplement basic functionality is not as illuminating as
  reading and understanding a professional programmer's implementation of
  it -- "learn by doing" is good for muscular training.  Programming is a
  process of thinking, so you learn by thinking, not by unthinkingly
  replicating the mere results of other people's thinking.  I also think
  every writer learns to write by reading observantly, taking notes, using
  a very large dictionary to discover nuances and details in meaning, and
  paying attention to details everywhere.  I think this is what studying is
  all about -- learning merely to repeat what others have done before you
  is not study.

| I know I asked for help once already so I understand if people are
| reluctant to provide more aid....

  As long as they keep learning and ask intelligent questions and work on
  your own, it is actually a joy to help people.

///
--
  In a fight against something, the fight has value, victory has none.
  In a fight for something, the fight is a loss, victory merely relief.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Bushnell, BSG  
View profile  
 More options Mar 10 2002, 5:10 pm
Newsgroups: comp.lang.lisp
From: tb+use...@becket.net (Thomas Bushnell, BSG)
Date: 10 Mar 2002 14:02:17 -0800
Local: Sun, Mar 10 2002 5:02 pm
Subject: Re: Newbie - 2 MORE Small problems?

Erik Naggum <e...@naggum.net> writes:
> | 1)  How can I change all the setf crap to let statements?  I know it's
> | bad form to use setf

>   setf is not bad form.  It is bad karma to teach that it is.  Your
>   professor may return as a Scheme programmer if he keeps this up.  (Or he
>   may done something terrible in his previous life and actually be a Scheme
>   programmer.)

I consider it bad form to introduce needless side-effects; when a setf
could be done in let, I always prefer let.  Then again, I don't use
any languages that have setf; I use set!.  :)

Thomas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Mar 10 2002, 6:35 pm
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.net>
Date: Sun, 10 Mar 2002 23:35:51 GMT
Local: Sun, Mar 10 2002 6:35 pm
Subject: Re: Newbie - 2 MORE Small problems?
* tb+use...@becket.net (Thomas Bushnell, BSG)
| I consider it bad form to introduce needless side-effects; when a setf
| could be done in let, I always prefer let.  Then again, I don't use
| any languages that have setf; I use set!.  :)

  set! is bad form.  setf is not.  Just another one of those differences
  between real Lisps like Common Lisp and toy lisps like Scheme.

///
--
  In a fight against something, the fight has value, victory has none.
  In a fight for something, the fight is a loss, victory merely relief.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kenny Tilton  
View profile  
 More options Mar 10 2002, 6:39 pm
Newsgroups: comp.lang.lisp
From: Kenny Tilton <ktil...@nyc.rr.com>
Date: Sun, 10 Mar 2002 23:37:46 GMT
Local: Sun, Mar 10 2002 6:37 pm
Subject: Re: Newbie - 2 MORE Small problems?

TejimaNoHimitsu wrote:
> The above function is supposed to take a predicate, a number, and a
> sorted list of numbers and insert elm into lis at the proper spot
> based on the boolean predicate p.

the exciting thing to me is that the spec does not say the sorted list
is sorted by the same predicate as the argument, which could make for
great fun. But I will assume the two are the same.

> for let working properly.....    (let (gimp (list elm x))  (if.....))

(let ((gimp (list elm x))) (if ...))

btw, i think you want (list* elm x) or (cons elm x)

>  we aren't allowed
> to use the sorting function.

can you use rotatef? rplaca?

--

 kenny tilton
 clinisys, inc
 ---------------------------------------------------------------
 "Be the ball...be the ball...you're not being the ball, Danny."
                                               - Ty, Caddy Shack


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Bushnell, BSG  
View profile  
 More options Mar 10 2002, 7:20 pm
Newsgroups: comp.lang.lisp
From: tb+use...@becket.net (Thomas Bushnell, BSG)
Date: 10 Mar 2002 16:17:28 -0800
Local: Sun, Mar 10 2002 7:17 pm
Subject: Re: Newbie - 2 MORE Small problems?

Erik Naggum <e...@naggum.net> writes:
> * tb+use...@becket.net (Thomas Bushnell, BSG)
> | I consider it bad form to introduce needless side-effects; when a setf
> | could be done in let, I always prefer let.  Then again, I don't use
> | any languages that have setf; I use set!.  :)

>   set! is bad form.  setf is not.  Just another one of those differences
>   between real Lisps like Common Lisp and toy lisps like Scheme.

Ah, so this is an insult battle.  Not interested here.

Thomas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kent M Pitman  
View profile  
 More options Mar 10 2002, 7:45 pm
Newsgroups: comp.lang.lisp
From: Kent M Pitman <pit...@world.std.com>
Date: Mon, 11 Mar 2002 00:44:26 GMT
Local: Sun, Mar 10 2002 7:44 pm
Subject: Re: Newbie - 2 MORE Small problems?
tb+use...@becket.net (Thomas Bushnell, BSG) writes:

> Erik Naggum <e...@naggum.net> writes:

> > | 1)  How can I change all the setf crap to let statements?  I know it's
> > | bad form to use setf

> >   setf is not bad form.  It is bad karma to teach that it is.  Your
> >   professor may return as a Scheme programmer if he keeps this up.  (Or he
> >   may done something terrible in his previous life and actually be a Scheme
> >   programmer.)

> I consider it bad form to introduce needless side-effects;

An assignment is not a side-effect.

It is a notational gesture.

 (let ((x 3))
   (let ((x (+ x 1)))
     x))

and

 (let ((x 3))
   (setq x (+ x 1))
   x)

do the same thing.  It is purely a notational choice which you use.

> when a setf could be done in let, I always prefer let.

Sometimes (e.g., in iterations) it is very hard to construct the
former style syntactically without introducing an apparent recursion.

Personally, I think recursions make things harder to read and would
prefer a SETQ. But others disagree.  It is again just a personal
choice issue how much you're going to want to perturb the written
structure of the program in order to accomodate a style choice.  SETQ
facilitates incremental change by not forcing a whole program to be
restructured just to accomodate a small conceptual change.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Mar 10 2002, 7:52 pm
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.net>
Date: Mon, 11 Mar 2002 00:52:46 GMT
Local: Sun, Mar 10 2002 7:52 pm
Subject: Re: Newbie - 2 MORE Small problems?
* Thomas Bushnell, BSG
| Ah, so this is an insult battle.

  No.  Try some other explanation.

///
--
  In a fight against something, the fight has value, victory has none.
  In a fight for something, the fight is a loss, victory merely relief.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Bushnell, BSG  
View profile  
 More options Mar 10 2002, 8:10 pm
Newsgroups: comp.lang.lisp
From: tb+use...@becket.net (Thomas Bushnell, BSG)
Date: 10 Mar 2002 17:07:11 -0800
Local: Sun, Mar 10 2002 8:07 pm
Subject: Re: Newbie - 2 MORE Small problems?

Erik Naggum <e...@naggum.net> writes:
> * Thomas Bushnell, BSG
> | Ah, so this is an insult battle.

>   No.  Try some other explanation.

When you call Scheme a "toy Lisp", you are trolling, much like those
who call Lisp a toy language.  Maybe it seems that way if you haven't
done much really serious programming in it, of real sophisticated
systems.  

Any language without call/cc looks totally like a toy to me, actually.

Thomas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Bushnell, BSG  
View profile  
 More options Mar 10 2002, 8:20 pm
Newsgroups: comp.lang.lisp
From: tb+use...@becket.net (Thomas Bushnell, BSG)
Date: 10 Mar 2002 17:18:02 -0800
Local: Sun, Mar 10 2002 8:18 pm
Subject: Re: Newbie - 2 MORE Small problems?
Kent M Pitman <pit...@world.std.com> writes:

> An assignment is not a side-effect.

Um, sometimes an assignment is equivalent to side-effect free form,
tis true--such is the case with your examples.

But in general, assignments introduce side-effects.  In general, the
following two are *not* equivalent:

(begin
  (set! x 3)
  ...)

(let ((x 3))
  ...)

The latter is side-effect free; the former is not.  Functions which
only include side-effect free forms have values which depend purely on
their arguments; this is not (in general) true if you use set!.

I belabor this only because in the Scheme world, at least, this is
exactly the normal definition of a side-effect.

Right--some uses of set! are side-effect free.  But all uses of let
are always side-effect free.

> > when a setf could be done in let, I always prefer let.

> Sometimes (e.g., in iterations) it is very hard to construct the
> former style syntactically without introducing an apparent recursion.

Um, in the Scheme world, we always call these "apparent recursions" by
the name "iteration".  The avoidance of syntactic recursion in Lisp
dates back to the days before proper tail recursion was de rigeur.

> Personally, I think recursions make things harder to read and would
> prefer a SETQ. But others disagree.  

I think this is just a matter of what you are most used to reading.
Erik Naggum is certainly right that use of setf (and friends) is very
prevalent in the Lisp world, but in the Scheme world, it's regarded as
bad form--and once, the same was in fact true in the Lisp world.

> It is again just a personal
> choice issue how much you're going to want to perturb the written
> structure of the program in order to accomodate a style choice.  SETQ
> facilitates incremental change by not forcing a whole program to be
> restructured just to accomodate a small conceptual change.

Oh, quite the contrary, actually.  Side-effects, as a rule,
incorporate lots of non-local dependencies, which must be very
carefully managed.  (Not that this is hard to do; it's just one extra
thing to think about, and one extra source of bugs.)  Side effect free
programming, on the other hand, saves an awful lot of that work.

Surely side effects are often necessary to express a computation
cleanly, but as SICP points out, such cases really occur when you have
things like state-maintaining objects of some sort.

I fully agree that this is an issue of taste, culture, and style.  I
only entered the discussion to point out that people who's style
includes the maxim "avoid unnecessary set! and friends" have a
legitimate and useful style, and that the original poster was probably
coming from that background.

Incidentally, this is not really a Scheme v. Lisp issue.  Side effects
are looked down on by a huge number of older Lisp texts and
implementations and programmers.  Modern Common Lisp looks more like
PL/I to me, so I guess all kinds of weird things are now normal
there.  :)

Thomas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Mar 10 2002, 8:39 pm
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.net>
Date: Mon, 11 Mar 2002 01:39:15 GMT
Local: Sun, Mar 10 2002 8:39 pm
Subject: Re: Newbie - 2 MORE Small problems?
* Thomas Bushnell, BSG
| When you call Scheme a "toy Lisp", you are trolling, much like those
| who call Lisp a toy language.  Maybe it seems that way if you haven't
| done much really serious programming in it, of real sophisticated
| systems.  
|
| Any language without call/cc looks totally like a toy to me, actually.

  The key was the difference between the communities.  Scheme is a toy seen
  from Common Lisp.  This is a Common Lisp forum.  Whatever Scheme freaks
  need to disparage in order to feel good about Perl, no, wait, Scheme, is
  trolling in comp.lang.lisp.  I find it odd that you did not recognize
  that you were trolling to begin with, and only got "insulted" when you
  got a response in kind.  Scheme freaks go nuts about set! and call upon
  various deities to ensure that people who use it do not get a second
  chance, while Kent Pitman has offered us a reasonable distinction between
  intra-scope assignment and extra-scope side-effects.  So Scheme's silly
  knee-jerk reaction to set! is the same as the knee-jerk reaction to goto
  -- failure to understand when it has its uses causes a religious response
  to its presence.  I also wonder why you keep trolling if you think it is
  in any way inappropriate.  Me, I think poking fun at Scheme is one of the
  few available pleasures that nobody could _possibly_ be hurt by, since it
  is such a toy language.  Now, if I posted that in comp.lang.scheme, it
  would be trolling and insulting.  Much like it would have been if I had
  posted any of my acidic comments on that XML failure to comp.text.xml.
  And considering all the venomous crap that Scheme freaks pour over the
  real Lisp, I think we should stay away from Northern Ireland-like ways to
  deal with our feeling "insulted" by what other people say.  Including,
  but not limited to people who now are "insulted" by my reference to the
  bellicose cultures of Northern Ireland.  Trust me, if I had used Israel
  and Palestine as the canonical example of, no, wait, let's not do that.

///
--
  In a fight against something, the fight has value, victory has none.
  In a fight for something, the fight is a loss, victory merely relief.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Bushnell, BSG  
View profile  
 More options Mar 10 2002, 9:00 pm
Newsgroups: comp.lang.lisp
From: tb+use...@becket.net (Thomas Bushnell, BSG)
Date: 10 Mar 2002 17:56:35 -0800
Local: Sun, Mar 10 2002 8:56 pm
Subject: Re: Newbie - 2 MORE Small problems?

Erik Naggum <e...@naggum.net> writes:
>   The key was the difference between the communities.  Scheme is a toy seen
>   from Common Lisp.  This is a Common Lisp forum.  Whatever Scheme freaks
>   need to disparage in order to feel good about Perl, no, wait, Scheme, is
>   trolling in comp.lang.lisp.  I find it odd that you did not recognize
>   that you were trolling to begin with, and only got "insulted" when you
>   got a response in kind.  

Scheme is usually represented as one dialect of Lisp.  comp.lang.lisp
*predates* Common Lisp, however.  It seems to me that comp.lang.lisp
should therefore be for all Lisps (and principally for those in
current use, of course).

>   Scheme freaks go nuts about set! and call upon
>   various deities to ensure that people who use it do not get a second
>   chance, while Kent Pitman has offered us a reasonable distinction between
>   intra-scope assignment and extra-scope side-effects.  

Yes, and that's a reasonable case.  Like I said, I think it's also an
issue of style, and the two programming communities have legitimate
differences of style.

>   So Scheme's silly
>   knee-jerk reaction to set! is the same as the knee-jerk reaction to goto
>   -- failure to understand when it has its uses causes a religious response
>   to its presence.  

Depends on the context.  set! is often exactly the right thing; Scheme
programmers who exert weird contortions to avoid it are certainly
making a mistake.  goto is perfectly reasonable in C code too.  

I would never say something like "never use set!"; I'd say (in accord
with usual Scheme style) "you get clearer Scheme programs if you only
use set! where it's really necessary--which is usually when you are
implementing some kind of state-preserving object".

>   And considering all the venomous crap that Scheme freaks pour over the
>   real Lisp, I think we should stay away from Northern Ireland-like ways to
>   deal with our feeling "insulted" by what other people say.  

Well, I wasn't insulted, I just said it seemed like you wanted an
argument--which seems true indeed.

You seem to have a common pattern here: you post something really
provocative, you accuse someone else of trolling when you were the
first really provocative poster, etc, etc.

It may be the only option for me here is to just skip your posts
entirely, but I'd hate to do that, because amidst the 10% of venom is
90% of very interesting elucidating stuff.

I haven't said any "venomous crap" against "the real Lisp" (which is,
of course, Maclisp) :).  I haven't said anything venomous against that
other PL/I Lisp (you know, Common Lisp).  Actually, the first edition
of Common Lisp was a really nifty achievement, but the later stuff is
baffling to me.  It's an issue of style though, unlike many, I don't
have any particular zealoutry to convince everyone that my way is the
only true way.

Thomas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Mar 10 2002, 10:02 pm
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.net>
Date: Mon, 11 Mar 2002 03:01:34 GMT
Local: Sun, Mar 10 2002 10:01 pm
Subject: Re: Newbie - 2 MORE Small problems?
* Thomas Bushnell, BSG
| Scheme is usually represented as one dialect of Lisp.  comp.lang.lisp
| *predates* Common Lisp, however.  It seems to me that comp.lang.lisp
| should therefore be for all Lisps (and principally for those in
| current use, of course).

  The nature and process of newsgroup splits dictates that if you get a
  forum for yourself, you do _not_ bother the general community.

  comp.lang.scheme decided to make have own community, and they should be
  happy there instead of wanting _two_: One for your own little pet
  language, and for the the general "Lisp" that you refuse to recognize
  that you are no longer a member of by virtue of your own forum.

  The same goes for Dylan, but we have _thankfully_ been relieved of D*lan
  propaganda, lately.

| Well, I wasn't insulted, I just said it seemed like you wanted an
| argument--which seems true indeed.

  I respond to your accusation that I want an insult battle.  Do not use a
  rejection of your position as proof that it was true.  Such dishonesty is
  usually reserved for extreme and ultra-conservative politicians, not
  people who have honest intentions with what they do.

  Some people I have argued against in the past have a very serious problem
  seeing a difference between my arguing against what they argue for and my
  arguing for what they argue against.  I suggest you think this over and
  make sure you know what people are actually arguing for and against.  If
  you have a philosoophy background, this difference should be _really_
  easy to see.

| You seem to have a common pattern here: you post something really
| provocative, you accuse someone else of trolling when you were the first
| really provocative poster, etc, etc.

  Really?  I wrote:

> set! is bad form.  setf is not.  Just another one of those differences
> between real Lisps like Common Lisp and toy lisps like Scheme.

  after _you_ had opened up for a comparison between Common Lisp and Scheme
  with a goddamn smiley, but when I joke back, you find it "really
  provocative", and _you_ insult me with something so stupid as this:

| Ah, so this is an insult battle.  Not interested here.

  Could it _possibly_ be that you were the first to go hostile here, and
  that you are so blind to your own actions that you are _never_ at fault?

  There are a lot of people out there who have deep psychological barriers
  to accepting that they behave badly in some way and who defend themselves
  by accusing the other party of everything that could possibly apply to
  themselves, and who even play the stupid mirror game, but the refusal to
  consider that the other party is at fault is _not_ the moronic argument
  that one is not.  You have to think in such terms to even arrive at the
  idea that that is what other people do.  If you are only used to such
  people, I pity you, but a _little_ room for a balanced view of things
  _should_ be available even in the most prejudiced who really need to
  regard themselves as "good guys" _all_ the time.

  The biggest, if not the _only_, problem on USENET is that people need to
  defend themselves, usually because someone thinks that they defend
  themselves best by accusing somebody of something completely outlandish
  that they never expressed, implied, or opened up to be inferred.

| I haven't said any "venomous crap" against "the real Lisp" (which is, of
| course, Maclisp) :).  I haven't said anything venomous against that other
| PL/I Lisp (you know, Common Lisp).

  Why is _this_ not "really provocative"?  You are in a forum where people
  are interested in Common Lisp in particular, yet you go on and on with
  your stupid insults towards Common Lisp, but as soon as I have a little
  fun with your toy lanauge, you find it "really provocative" and go nuts?
  Are you for real?

| Actually, the first edition of Common Lisp was a really nifty
| achievement, but the later stuff is baffling to me.  It's an issue of
| style though, unlike many, I don't have any particular zealoutry to
| convince everyone that my way is the only true way.

  "Actually" is usually reserved for facts, not biased opinions.

  Regardless of what you _feel_, it is probably smart to avoid provoking
  people in the forum where people expressly congegrate to enjoy what you
  do not.  This is why I poke fun at Scheme and XML and Perl and C++ _here_
  -- not in their newsgroups.  Do you grasp this difference?  Can you
  _quit_ being so sensitive about your stupid toy language when you are not
  in _its_ particular forum and community?  Of _course_ people have a right
  to think Scheme sucks here -- you guys got your own newsgroup so you
  could discuss Scheme without fighting with real Lispers.

///
--
  In a fight against something, the fight has value, victory has none.
  In a fight for something, the fight is a loss, victory merely relief.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Bushnell, BSG  
View profile  
 More options Mar 10 2002, 11:20 pm
Newsgroups: comp.lang.lisp
From: tb+use...@becket.net (Thomas Bushnell, BSG)
Date: 10 Mar 2002 20:20:55 -0800
Local: Sun, Mar 10 2002 11:20 pm
Subject: Re: Newbie - 2 MORE Small problems?

Erik Naggum <e...@naggum.net> writes:
>   The biggest, if not the _only_, problem on USENET is that people need to
>   defend themselves, usually because someone thinks that they defend
>   themselves best by accusing somebody of something completely outlandish
>   that they never expressed, implied, or opened up to be inferred.

I'm happy with a rule that nobody ever needs to defend themselves.

It goes along with a rule against thin skins and so forth.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bruce Hoult  
View profile  
 More options Mar 10 2002, 11:47 pm
Newsgroups: comp.lang.lisp
From: Bruce Hoult <br...@hoult.org>
Date: Mon, 11 Mar 2002 17:47:42 +1300
Local: Sun, Mar 10 2002 11:47 pm
Subject: Re: Newbie - 2 MORE Small problems?
In article <3224804504056...@naggum.net>, Erik Naggum <e...@naggum.net>
wrote:

So, by logical extension, I take it that you feel users of Franz Lisp
and Macintosh Common Lisp do not belong here and should not discuss
things with real Lispers?

Or, conversely, that if the groups comp.lang.lisp.scheme and
comp.lang.lisp.dylan had been proposed and passed, that discussion of
those would then be welcome here?

-- Bruce


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kenny Tilton  
View profile  
 More options Mar 11 2002, 12:25 am
Newsgroups: comp.lang.lisp
From: Kenny Tilton <ktil...@nyc.rr.com>
Date: Mon, 11 Mar 2002 05:23:00 GMT
Subject: Re: Newbie - 2 MORE Small problems?

> Ah, so this is an insult battle.  Not interested here.

Twice in as many days! No one not interested makes this post.

We need a design pattern for this, and I have to credit Woodward &
Bernstein for the original "non-denial denial". But it seems the NG
equivalent arrow goes the other way, we've had a continuing
con-continuation and an interested lack of interest.

Needless to say, I'm not going to say anything about this.

--

 kenny tilton
 clinisys, inc
 ---------------------------------------------------------------
 "Be the ball...be the ball...you're not being the ball, Danny."
                                               - Ty, Caddy Shack


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul Foley  
View profile  
 More options Mar 11 2002, 2:09 am
Newsgroups: comp.lang.lisp
From: Paul Foley <mycr...@actrix.gen.nz>
Date: 11 Mar 2002 20:09:12 +1300
Local: Mon, Mar 11 2002 2:09 am
Subject: Re: Newbie - 2 MORE Small problems?
On 10 Mar 2002 17:56:35 -0800, Thomas Bushnell, BSG wrote:

> Erik Naggum <e...@naggum.net> writes:
>> The key was the difference between the communities.  Scheme is a toy seen
>> from Common Lisp.  This is a Common Lisp forum.  Whatever Scheme freaks
>> need to disparage in order to feel good about Perl, no, wait, Scheme, is
>> trolling in comp.lang.lisp.  I find it odd that you did not recognize
>> that you were trolling to begin with, and only got "insulted" when you
>> got a response in kind.  
> Scheme is usually represented as one dialect of Lisp.  comp.lang.lisp
> *predates* Common Lisp, however.

No it doesn't.

The first post to comp.lang.lisp was in November of 1986; _Common
Lisp, The Language_ was published in 1984.

>                                  It seems to me that comp.lang.lisp
> should therefore be for all Lisps (and principally for those in
> current use, of course).

It is.  Common Lisp is the only one in current common use, except for
specialized implementations in Emacs and AutoCAD, etc., which have
their own groups.  [Scheme, of course, without regard to how it's
"usually represented" (i.e., by Schemers), isn't a Lisp]

--
Oh dear god.  In case you weren't aware, "ad hominem" is not latin for
"the user of this technique is a fine debater."
                                                      -- Thomas F. Burdick
(setq reply-to
  (concatenate 'string "Paul Foley " "<mycroft" '(#\@) "actrix.gen.nz>"))


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Bushnell, BSG  
View profile  
 More options Mar 11 2002, 2:30 am
Newsgroups: comp.lang.lisp
From: tb+use...@becket.net (Thomas Bushnell, BSG)
Date: 10 Mar 2002 23:31:56 -0800
Local: Mon, Mar 11 2002 2:31 am
Subject: Re: Newbie - 2 MORE Small problems?

Paul Foley <mycr...@actrix.gen.nz> writes:
> > Scheme is usually represented as one dialect of Lisp.  comp.lang.lisp
> > *predates* Common Lisp, however.

> No it doesn't.

> The first post to comp.lang.lisp was in November of 1986; _Common
> Lisp, The Language_ was published in 1984.

Oh, that's just an artifact of the Great Renaming, which was 1986-7.
comp.lang.lisp is the new name of the old net.lang.lisp.  The first
message was there can be found at
http://groups.google.com/groups?hl=en&group=net.lang.lisp&scoring=d&a...

And is dated 1982-03-27 23:56:29 PST.

It's by John Foderaro.  The first sentence is:

"The net.lang.lisp newsgroup is for the discussion of any and all lisp
dialects."

> It is.  Common Lisp is the only one in current common use, except for
> specialized implementations in Emacs and AutoCAD, etc., which have
> their own groups.  [Scheme, of course, without regard to how it's
> "usually represented" (i.e., by Schemers), isn't a Lisp]

Well, I typed "lisp faq" into google.  The very first hit was a faq at
cs.cmu.edu, and question 1-1 says "What is the difference between
Scheme and Common Lisp".  The answer begins "Scheme is a dialect of
Lisp that stresses...."  The same faq occurs many places on the web as
it happens, and is sometimes cited as the "old comp.lang.lisp faq".

I also found http://www-jcsu.jesus.cam.ac.uk/~csr21/lispfaq.html.  It
has the more cagey "Scheme is a member of the greater family of Lisp
languages", and suggest that conversations like the present one are
pointless.  (Before Erik Naggum gets upset, it was he, not me, that
insisted that there must be some rigid demarcation between Scheme and
"true lisp", whatever that is.)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kenny Tilton  
View profile  
 More options Mar 11 2002, 2:48 am
Newsgroups: comp.lang.lisp
From: Kenny Tilton <ktil...@nyc.rr.com>
Date: Mon, 11 Mar 2002 07:45:10 GMT
Local: Mon, Mar 11 2002 2:45 am
Subject: Re: Newbie - 2 MORE Small problems?
(defun insert-n-sort (p elm lis)
     (mapcar #'(lambda (x)
                 (setf gimp (list elm x))
                 (if (apply p gimp)...
;
; ok, i see now: you are really just testing (<predicate> elm x), so
; you could just say (when (funcall p elm x)...notice i used WHEN for a
minor
; clarity boost over (if <test> <only-the-true-branch>)
;
; so now...

(defun insert-n-sort (p elm lis)
     (mapcar #'(lambda (x)
                 (when (funcall p elm x)
                     (setf...
;
; the spec said LIS was already sorted (I am guessing by P) so
; there is no need for a SETF, you just have to return whatever you whip
up to
; insert elm in the list, using RETURN-FROM insert-n-sort
;
(defun insert-n-sort (p elm lis)
     (mapcar #'(lambda (x)
                 (when (funcall p elm x)
                     (return-from insert-n-sort
                       (append
                        (append
;
; no big deal, but append takes multiple (&rest) args, so one will do:
;
(defun insert-n-sort (p elm lis)
     (mapcar #'(lambda (x)
                 (when (funcall p elm x)
                     (return-from insert-n-sort
                       (append
                        (subseq lis 0 (position x lis))
                        (list elm)
;
; no big deal again, but you may as well just say (cons elm <the
rest>)...
; not sure even which is clearer. anyway, i'd save a cons cell and code
up...
;
(defun insert-n-sort (p elm lis)
  (mapcar #'(lambda (x)
              (when (funcall p elm x)
                (return-from insert-n-sort
                  (append
                   (subseq lis 0 (position x lis))
                   (cons elm (subseq lis (position x lis)
                                     (length lis)))))))
    lis))
;
; we are forced into the needless effort of position and subseq calls
because mapcar
; hands just the car of a cons cell to the mapping function, so when you
find the
; insertion point you do not know where you are. maplist passes each
cons
; cell to the mapping function
;
(defun insert-n-sort (p elm lis)
  (maplist #'(lambda (lis-remaining)
              (when (funcall p elm (car lis-remaining))
                ;
                ; the bad news is we only know what comes after (not
before) the insertion point,
                ; but if we understand cons cells (the point of this
exercise?) we
                ; can splice in place:
                ;
                (setf (cdr lis-remaining)
                  (cons (car lis-remaining) (cdr lis-remaining)))
                (setf (car lis-remaining) elm)
                ;
                ; we be jammin
                ;
                (return-from insert-n-sort lis)))
           lis)
  ;
  ; predicate was never satisfied if we get here, so elm "loses" and
goes to end
  ;
  (nconc lis (list elm)))

Two things: the above is destructive; it changes the list received.
So does SORT, so maybe that is OK.

Second, if the point of this was for you to master cons cells (which I
suspect since you were
told not to use SORT) then forget you ever saw the splicing bit and try
to work
it out for yourself. I recommend drawing pictures of cons cells at first
to make this much
easier.

 kenny tilton
 clinisys, inc
 ---------------------------------------------------------------
 "Be the ball...be the ball...you're not being the ball, Danny."
                                               - Ty, Caddy Shack


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul Foley  
View profile  
 More options Mar 11 2002, 5:04 am
Newsgroups: comp.lang.lisp
From: Paul Foley <mycr...@actrix.gen.nz>
Date: 11 Mar 2002 23:04:20 +1300
Local: Mon, Mar 11 2002 5:04 am
Subject: Re: Newbie - 2 MORE Small problems?
On 10 Mar 2002 23:31:56 -0800, Thomas Bushnell, BSG wrote:

> Paul Foley <mycr...@actrix.gen.nz> writes:
>> > Scheme is usually represented as one dialect of Lisp.  comp.lang.lisp
>> > *predates* Common Lisp, however.

>> No it doesn't.

>> The first post to comp.lang.lisp was in November of 1986; _Common
>> Lisp, The Language_ was published in 1984.
> Oh, that's just an artifact of the Great Renaming, which was 1986-7.
> comp.lang.lisp is the new name of the old net.lang.lisp.

I know that; you didn't say "net.lang.lisp predates Common Lisp",
though.

--
Qui beneficium dedit, taceat; narret qui accepit                 -- Seneca

(setq reply-to
  (concatenate 'string "Paul Foley " "<mycroft" '(#\@) "actrix.gen.nz>"))


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 64   Newer >
« Back to Discussions « Newer topic     Older topic »