From: Christian Lynbech
Subject: Loop is cool
Date: 
Message-ID: <ofznf08iad.fsf@othello.ted.dk.eu.ericsson.se>
I am in the process of learning more about loop, and just came up with
following example why `loop' rocks.

The task is to take a single string with embedded newlines and chop it
up into a list of strings without newlines, and here is what I came up
with:

    (setq *log* "1234
    5678
    90")

    (loop with log = *log*
          for start = 0 then (1+ index)
          for index = (position #\Newline log :start start)  
          collect (subseq log start index)
          while index)

    ;=> ("1234" "5678" "90")



------------------------+-----------------------------------------------------
Christian Lynbech       | christian ··@ defun #\. dk
------------------------+-----------------------------------------------------
Hit the philistines three times over the head with the Elisp reference manual.
                                        - ·······@hal.com (Michael A. Petonic)

From: larry
Subject: Re: Loop is cool
Date: 
Message-ID: <7b8f89d6.0311131057.11d9b3c4@posting.google.com>
Christian Lynbech <·················@ericsson.com> wrote in message news:<··············@othello.ted.dk.eu.ericsson.se>...
> I am in the process of learning more about loop, and just came up with
> following example why `loop' rocks.
> 
> The task is to take a single string with embedded newlines and chop it
> up into a list of strings without newlines, and here is what I came up
> with:
> 
>     (setq *log* "1234
>     5678
>     90")
> 
>     (loop with log = *log*
>           for start = 0 then (1+ index)
>           for index = (position #\Newline log :start start)  
>           collect (subseq log start index)
>           while index)
> 
>     ;=> ("1234" "5678" "90")
> 
> 
> 
> ------------------------+-----------------------------------------------------
> Christian Lynbech       | christian ··@ defun #\. dk
> ------------------------+-----------------------------------------------------
> Hit the philistines three times over the head with the Elisp reference manual.
>                                         - ·······@hal.com (Michael A. Petonic)

Here's what I think would be really cool.Instead of using loops you
could just use something close to set theoretic notation. For instance
suppose given an integer n, you wanted to return the list of pairs of
integers (i,j) such that i<j and 1<=j <n. You could do that with loop
but it would be really cool if you could just say something like
(set-expr (cons i j) :such-that (and (< i j) (< 1 j n))).
Maybe you would also have to specify what sets i and j were in. In
this example maybe you'd have to say i and j are in the set
{0,1,...n-1}.

Has anyone written something that would allow you to do this?
From: Darius
Subject: Re: Loop is cool
Date: 
Message-ID: <20031113142422.000003f5.ddarius@hotpop.com>
On 13 Nov 2003 10:57:37 -0800
··········@hotmail.com (larry) wrote:

> Here's what I think would be really cool.Instead of using loops you
> could just use something close to set theoretic notation. For instance
> suppose given an integer n, you wanted to return the list of pairs of
> integers (i,j) such that i<j and 1<=j <n. You could do that with loop
> but it would be really cool if you could just say something like
> (set-expr (cons i j) :such-that (and (< i j) (< 1 j n))).
> Maybe you would also have to specify what sets i and j were in. In
> this example maybe you'd have to say i and j are in the set
> {0,1,...n-1}.
> 
> Has anyone written something that would allow you to do this?

You mean list/set comprehensions; e.g. in Haskell 
[(i,j) | j <- [1..n], i <- [1..n], i < j] ?  I'm pretty sure people have
written list comprehension macros in CL.  Set comprehension versions
would be trivial to make from there.  In fact, both are instances of
monad comprehensions.  Or a totally different vein would be constraint
systems, e.g. a la Oz.
From: Kenny Tilton
Subject: Re: Loop is cool
Date: 
Message-ID: <KKQsb.87474$ri.14016275@twister.nyc.rr.com>
larry wrote:
> Here's what I think would be really cool.Instead of using loops you
> could just use something close to set theoretic notation. For instance
> suppose given an integer n, you wanted to return the list of pairs of
> integers (i,j) such that i<j and 1<=j <n. You could do that with loop
> but it would be really cool if you could just say something like
> (set-expr (cons i j) :such-that (and (< i j) (< 1 j n))).
> Maybe you would also have to specify what sets i and j were in. In
> this example maybe you'd have to say i and j are in the set
> {0,1,...n-1}.
> 
> Has anyone written something that would allow you to do this?

Screamer? Not sure, but I think it would. And there are Prolog-in-lisp 
implementations that would do this, methinks. Jes thinkin out loud...

kt

-- 
http://tilton-technology.com

Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film

Your Project Here! http://alu.cliki.net/Industry%20Application
From: Christopher C. Stacy
Subject: Re: Loop is cool
Date: 
Message-ID: <uvfpojbm3.fsf@dtpq.com>
>>>>> On 13 Nov 2003 10:57:37 -0800, larry  ("larry") writes:

 larry> Christian Lynbech <·················@ericsson.com> wrote in message news:<··············@othello.ted.dk.eu.ericsson.se>...
 >> I am in the process of learning more about loop, and just came up with
 >> following example why `loop' rocks.
 >> 
 >> The task is to take a single string with embedded newlines and chop it
 >> up into a list of strings without newlines, and here is what I came up
 >> with:
 >> 
 >> (setq *log* "1234
 >> 5678
 >> 90")
 >> 
 >> (loop with log = *log*
 >> for start = 0 then (1+ index)
 >> for index = (position #\Newline log :start start)  
 >> collect (subseq log start index)
 >> while index)
 >> 
 >> ;=> ("1234" "5678" "90")
 >> 
 >> 
 >> 
 >> ------------------------+-----------------------------------------------------
 >> Christian Lynbech       | christian ··@ defun #\. dk
 >> ------------------------+-----------------------------------------------------
 >> Hit the philistines three times over the head with the Elisp reference manual.
 >> - ·······@hal.com (Michael A. Petonic)

 larry> Here's what I think would be really cool.Instead of using loops you
 larry> could just use something close to set theoretic notation. For instance
 larry> suppose given an integer n, you wanted to return the list of pairs of
 larry> integers (i,j) such that i<j and 1<=j <n. You could do that with loop
 larry> but it would be really cool if you could just say something like
 larry> (set-expr (cons i j) :such-that (and (< i j) (< 1 j n))).
 larry> Maybe you would also have to specify what sets i and j were in. In
 larry> this example maybe you'd have to say i and j are in the set
 larry> {0,1,...n-1}.

 larry> Has anyone written something that would allow you to do this?

The SERIES package is somewhat like that.
From: Espen Vestre
Subject: Re: Loop is cool
Date: 
Message-ID: <kwd6bwe3u9.fsf@merced.netfonds.no>
Christian Lynbech <·················@ericsson.com> writes:

> The task is to take a single string with embedded newlines and chop it
> up into a list of strings without newlines, and here is what I came up
> with:

It might not be the most efficient solution, but since the string
seems to be "stream contents", it's tempting to treat it like a 
stream:

(with-input-from-string (s *log*) 
   (loop for line = (read-line s nil nil)
         while line
         collect line))
-- 
  (espen)
From: Venkat
Subject: Re: Loop is cool
Date: 
Message-ID: <55442638.0311132058.6c073216@posting.google.com>
Christian Lynbech <·················@ericsson.com> wrote in message news:<··············@othello.ted.dk.eu.ericsson.se>...
> I am in the process of learning more about loop, and just came up with
> following example why `loop' rocks.
> 
> The task is to take a single string with embedded newlines and chop it
> up into a list of strings without newlines, and here is what I came up
> with:
> 
>     (setq *log* "1234
>     5678
>     90")
> 
>     (loop with log = *log*
>           for start = 0 then (1+ index)
>           for index = (position #\Newline log :start start)  
>           collect (subseq log start index)
>           while index)
> 
>     ;=> ("1234" "5678" "90")
> 


   ANSI lisp function 'excl:delimited-string-to-list' can be used  which takes 
   a single string,delimiter and gives list of strings by tokenizing the string
   using the delimiter
 
    The following will serve u r need easily
     
    (setq *log* "1234
     5678
     90")

   (excl:delimited-string-to-list *log* #\Newline)
From: Christian Lynbech
Subject: Re: Loop is cool
Date: 
Message-ID: <ofekwbcrmc.fsf@situla.ted.dk.eu.ericsson.se>
>>>>> "Venkat" == Venkat  <············@yahoo.com> writes:

Venkat> ANSI lisp function 'excl:delimited-string-to-list' can be used...

That is not an ANSI Lisp function, it is specific to Franz Allegro.


------------------------+-----------------------------------------------------
Christian Lynbech       | christian ··@ defun #\. dk
------------------------+-----------------------------------------------------
Hit the philistines three times over the head with the Elisp reference manual.
                                        - ·······@hal.com (Michael A. Petonic)
From: larry
Subject: Re: Loop is cool
Date: 
Message-ID: <7b8f89d6.0311141037.50bb8721@posting.google.com>
Christian Lynbech <·················@ericsson.com> wrote in message news:<··············@situla.ted.dk.eu.ericsson.se>...
> >>>>> "Venkat" == Venkat  <············@yahoo.com> writes:
> 
> Venkat> ANSI lisp function 'excl:delimited-string-to-list' can be used...
> 
> That is not an ANSI Lisp function, it is specific to Franz Allegro.
> 

So that means that there isn't an ANSI lisp function to split strings,
otherwise allegro wouldn't have written their own.
Is there any move to add to the ANSI lisp standard a lot of useful
libraries and utilties that come standard with other languages like
Python and Perl.
Or do the lisp powers-that-be have the attitude that: If you want some
function that's not in the ansi lisp standard(but is a standard
function in Python and Perl)  you should : 1) write it yourself, or 2)
find someone else who has written something similiar to what you want,
or 3) use python or perl -- lisp is for super sophisticated
programming problems, not for trivial things like string processing."
It's all very well and good to say that but still it's a bit of a
nuisance to write your own or go looking for code to do something that
should be standard. Common Lisp is so big already. What's the problem
with making it a little bigger with more standard libraries?
Does the ansi lisp standard ever change?
From: Marco Antoniotti
Subject: Re: Loop is cool
Date: 
Message-ID: <yeatb.195$KR3.106452@typhoon.nyu.edu>
larry wrote:
> Christian Lynbech <·················@ericsson.com> wrote in message news:<··············@situla.ted.dk.eu.ericsson.se>...
> 
>>>>>>>"Venkat" == Venkat  <············@yahoo.com> writes:
>>
>>Venkat> ANSI lisp function 'excl:delimited-string-to-list' can be used...
>>
>>That is not an ANSI Lisp function, it is specific to Franz Allegro.
>>
> 
> 
> So that means that there isn't an ANSI lisp function to split strings,
> otherwise allegro wouldn't have written their own.
> Is there any move to add to the ANSI lisp standard a lot of useful
> libraries and utilties that come standard with other languages like
> Python and Perl.

Search SPLIT-SEQUENCE in the Cliki.  BTW.  As the name implies, it 
splits sequences, not just strings.



> Or do the lisp powers-that-be

Here lies the core of the problem.  Since Common Lisp is *NOT* (for the 
(expt 2 N) time with (< MOST-POSITIVE-FIXNUM N) yielding T) a 1.8 
implementation language the "powers-that-be" are many and not easily put 
together.

However, the SPLIT-SEQUENCE issue has been solved.

> have the attitude that: If you want some
> function that's not in the ansi lisp standard(but is a standard
> function in Python and Perl)

Let's repeat it again.  In Python and Perl the language *is* the 
standard.  In Common Lisp it is not the case: standard =/= (conforming) 
implementation.  If you where using a single implementation all the 
time, you'd be a happy camper.

> you should : 1) write it yourself,

Why not?

> or 2)
> find someone else who has written something similiar to what you want,

Usually this has happened.

> or 3) use python or perl -- lisp is for super sophisticated
> programming problems, not for trivial things like string processing."

Given that you can do string processing in CL, why use Perl or tllotbafir?


> It's all very well and good to say that but still it's a bit of a
> nuisance to write your own or go looking for code to do something that
> should be standard. Common Lisp is so big already. What's the problem
> with making it a little bigger with more standard libraries?
> Does the ansi lisp standard ever change?

Well, it is a problem.  I am sure LW and ACL have similar extra-standard 
functions for doing something trivial or not.  The smeantics is just 
off.  Now.  Who decides which function goes into the new - quote - 
standardized - unquote - library?

In Perl and Python it boils down to one person.  My understanding is 
that e.g. Guido van Rossum is a very capable person when it comes to 
manage this process.  In the CL world you simply do not have this luxury.

Cheers
--
marco
From: Peter Seibel
Subject: Re: Loop is cool
Date: 
Message-ID: <m3brren58i.fsf@javamonkey.com>
··········@hotmail.com (larry) writes:

> Christian Lynbech <·················@ericsson.com> wrote in message news:<··············@situla.ted.dk.eu.ericsson.se>...
> > >>>>> "Venkat" == Venkat  <············@yahoo.com> writes:
> > 
> > Venkat> ANSI lisp function 'excl:delimited-string-to-list' can be used...
> > 
> > That is not an ANSI Lisp function, it is specific to Franz Allegro.
> > 
> 
> So that means that there isn't an ANSI lisp function to split
> strings, otherwise allegro wouldn't have written their own. Is there
> any move to add to the ANSI lisp standard a lot of useful libraries
> and utilties that come standard with other languages like Python and
> Perl.

Actually, the situation in Lisp is a lot like it is in Perl or Python:
the "standard" libraries in those languages are the ones that folks
find useful and are widely distributed. The only difference is that
because Perl and Python each have a single source for the canonical
implementation (Larry Wall and GvR), it's possible for the canonical
implementation to adopt certain libraries and make them standard. In
Lisp the situation is different because the ANSI standard is
implemented by at least a half dozen different "organizations" some
commercial entities and some free software or open source projects.
There is no dictator, benevolent or otherwise, that can simply decide
to add something to the standard.

What's lacking at the moment in Lisp is not a means to change the
language standard but (IMHO) an easy way for folks to find and
distribute libraries, a la the CPAN. But there's momentum growing to
address that lack--there's a list of libraries on the Cliki;
common-lisp.net seems to be picking up steam; and some of the Bay Area
Lispniks and I have been kicking around ideas about what else could be
done. And that's just the efforts that I know about.

> Or do the lisp powers-that-be have the attitude that: If you want
> some function that's not in the ansi lisp standard(but is a standard
> function in Python and Perl) you should : 1) write it yourself, or
> 2) find someone else who has written something similiar to what you
> want, or 3) use python or perl -- lisp is for super sophisticated
> programming problems, not for trivial things like string
> processing."

I'd say 2). Which is pretty much what Perl and Python say, modulo
their ability to incorporate popular libarries into the canonical
distribution of the language. Hopefully the efforts I mentioned will
bear some fruit, making it easier for would-be library users to find
what they need.

> It's all very well and good to say that but still it's a bit of a
> nuisance to write your own or go looking for code to do something
> that should be standard. Common Lisp is so big already. What's the
> problem with making it a little bigger with more standard libraries?
> Does the ansi lisp standard ever change?

It's unlikely that the language standard itself will change because of
the way ANSI works. But the good news is there's no need to change the
language standard in order for people who care to promulgate de facto
library standards.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Nikodemus Siivola
Subject: Re: Loop is cool
Date: 
Message-ID: <bp3avl$20a$1@nyytiset.pp.htv.fi>
larry <··········@hotmail.com> wrote:

> So that means that there isn't an ANSI lisp function to split strings,
> otherwise allegro wouldn't have written their own.

Exactomundo.

> Is there any move to add to the ANSI lisp standard a lot of useful
> libraries and utilties that come standard with other languages like
> Python and Perl.

Yes and no. 

Common Lisp was born out of existing community practises: it did not
spring fully formed from anyone's forehead.

Currently there is no active move to add to the standard, but there is
*plenty* of activity to build libraries, etc -- which many view as an
intermediate step before standardizing.

Eg. for splitting strings the "community standard" is the
split-sequence you were already referred to. It's good. Use it.

I personally have fair confidence that those of these libraries which
should have standardized interfaces *eventually* will.

> Or do the lisp powers-that-be have the attitude that: If you want some
> function that's not in the ansi lisp standard(but is a standard
> function in Python and Perl)  you should : 1) write it yourself, or 2)
> find someone else who has written something similiar to what you want,
> or 3) use python or perl 

That's a rethorical question, right?

Of course you should do #2, unless you happen to disagree with their
implementation / interface -- in which case you do #1, and hopefully
make you stuff available under a MIT/BSD style license.

Eventually things that need to converge will converge.

[ Cue KMP and Substandards. ]

Cheers,

 -- Nikodemus
From: Daniel Barlow
Subject: Re: Loop is cool
Date: 
Message-ID: <87he1690h6.fsf@noetbook.telent.net>
··········@hotmail.com (larry) writes:

> So that means that there isn't an ANSI lisp function to split strings,
> otherwise allegro wouldn't have written their own.
> Is there any move to add to the ANSI lisp standard a lot of useful
> libraries and utilties that come standard with other languages like
> Python and Perl.

There isn't, as far as I'm aware, any move to add anything at all to
the ANSI standard.  When the question comes up, veterans of the
previous standardisation round tend to describe the ANSI process as
slow and expensive.  Still, that we even _have_ a standard is more
than either of the Perl or Python languages you mention below.

> Or do the lisp powers-that-be have the attitude that: If you want some

OK, who _are_ the lisp powers-that-be?  'fess up, guys.  I have a
cricket bat here with COMPILE-FILE-PATHNAME written on it.

> function that's not in the ansi lisp standard(but is a standard
> function in Python and Perl)  you should : 1) write it yourself, or 2)
> find someone else who has written something similiar to what you want,
> or 3) use python or perl -- lisp is for super sophisticated
> programming problems, not for trivial things like string processing."
> It's all very well and good to say that but still it's a bit of a
> nuisance to write your own or go looking for code to do something that
> should be standard. Common Lisp is so big already. What's the problem
> with making it a little bigger with more standard libraries?

I find it worrying that you apparently leap so instantly from a
consideration of the possibilities to an assumption that the third
is the correct one.

But I'm more curious about who these Lisp powers-that-be are - and
what powers they have.  Was there an election I missed, or is it the
Divine Right Of Cons, or what?


-dan

-- 

   http://web.metacircles.com/cirCLe_CD - Free Software Lisp/Linux distro
From: Joe Marshall
Subject: Re: Loop is cool
Date: 
Message-ID: <zneylkrf.fsf@ccs.neu.edu>
Daniel Barlow <···@telent.net> writes:


> But I'm more curious about who these Lisp powers-that-be are - and
> what powers they have.  Was there an election I missed, or is it the
> Divine Right Of Cons, or what?

To become a `power' you have to let John McCarthy use your laptop.
From: Daniel Barlow
Subject: Re: Loop is cool
Date: 
Message-ID: <873ccq8xjl.fsf@noetbook.telent.net>
Joe Marshall <···@ccs.neu.edu> writes:

> Daniel Barlow <···@telent.net> writes:
>
>
>> But I'm more curious about who these Lisp powers-that-be are - and
>> what powers they have.  Was there an election I missed, or is it the
>> Divine Right Of Cons, or what?
>
> To become a `power' you have to let John McCarthy use your laptop.

Ah.  Hail Tilton, that shall be Ken hereafter.


-dan

-- 

   http://web.metacircles.com/cirCLe_CD - Free Software Lisp/Linux distro
From: Kenny Tilton
Subject: Re: Loop is cool
Date: 
Message-ID: <Bcctb.95365$ri.14452190@twister.nyc.rr.com>
Daniel Barlow wrote:

> Joe Marshall <···@ccs.neu.edu> writes:
> 
> 
>>Daniel Barlow <···@telent.net> writes:
>>
>>
>>
>>>But I'm more curious about who these Lisp powers-that-be are - and
>>>what powers they have.  Was there an election I missed, or is it the
>>>Divine Right Of Cons, or what?
>>
>>To become a `power' you have to let John McCarthy use your laptop.
> 
> 
> Ah.  Hail Tilton, that shall be Ken hereafter.

This is a helluvan upgrade! I thought JMcCUML made me "Pathetic Groupie".

No, Larry, welcome to a Rudderless Ship, one of those planets visited by 
the original Star Trek, where the inhabitants blindly do the bidding of 
what turns out be an inanimate oracle, in our case the ANSI spec.

Quickest draw on their Trek compendium gets a beer on me.

kenny

-- 
http://tilton-technology.com

Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film

Your Project Here! http://alu.cliki.net/Industry%20Application
From: Geoffrey Summerhayes
Subject: Re: Loop is cool
Date: 
Message-ID: <GAltb.47933$xI2.1287130@news20.bellglobal.com>
"Kenny Tilton" <·······@nyc.rr.com> wrote in message
····························@twister.nyc.rr.com...
>
> No, Larry, welcome to a Rudderless Ship, one of those planets visited by
> the original Star Trek, where the inhabitants blindly do the bidding of
> what turns out be an inanimate oracle, in our case the ANSI spec.
>
> Quickest draw on their Trek compendium gets a beer on me.
>

Hmmm...is there an episode where they didn't?

3 come to mind immediately:

For the World is Hollow and I have touched the Sky
(best fit for rudderless ship)

The Return of the Archons
(Festival--the equivalent of Scheme vs. Lisp threads)

The Apple
(Vaal - ugliest computer case going)

Then there's the iffy ones:

A Taste of Armageddon
;;one-liner!
(loop (write-line "Report to the nearest disintegration booth"))

The Gamesters of Triskelion
(40 quatloos on the Lisper!)

--
Geoff
From: Paolo Amoroso
Subject: Re: Loop is cool
Date: 
Message-ID: <873ccqacoq.fsf@plato.moon.paoloamoroso.it>
Larry writes:

> Is there any move to add to the ANSI lisp standard a lot of useful
> libraries and utilties that come standard with other languages like
> Python and Perl.
> Or do the lisp powers-that-be have the attitude that: If you want some
[...]
> Does the ansi lisp standard ever change?

The attitude of the Lisp powers-that-be, and changes in the ANSI
standard, are complex issues. The comp.lang.lisp archive provides
copious material on this.


Paolo
-- 
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
From: Vladimir S.
Subject: Re: Loop is cool
Date: 
Message-ID: <8765ho19wx.fsf@shawnews.cg.shawcable.net>
Huzzah! The grand olde string-tokenizer debate revisited.

Not to rain on your parade or anything, but do is cooler*! I wrote the
following macro for the same purpose (before I ever heard of CLOCC and
their tokenize-sequence function):

(defmacro string-tokenize (str action &key
			   (delimiters
                            '(list #\Space #\Newline #\Tab))
			   (test 'char=)
			   (start 0)
			   end
			   (end-action t)
			   (char-accessor 'schar))
  (symbol-macrolet ((gs (gensym "stoken-")))
      (let ((endkey gs) (wbeg gs) (wend gs) (delimiter-p gs)
            (orlist gs) (clause gs) (string gs) (act gs))
	`(macrolet ((,delimiter-p (x)
		     (let ((,orlist ()))
		       (dolist (,clause ,delimiters)
                        (push (list (quote ,test) x ,clause) ,orlist))
		       `(or ,@,orlist))))
	  (do* ((,act ,action)
		(,string ,str)
		(,endkey ,(if end end `(length ,string)))
		(,wbeg ,start)
		(,wend (1+ ,wbeg) (1+ ,wend)))
	       ((< ,endkey ,wend) ,end-action)
	    (cond ((,delimiter-p (,char-accessor ,string ,wbeg))
                   (setq ,wbeg (1+ ,wbeg)))
		  ((or (= ,endkey ,wend)
                       (,delimiter-p (,char-accessor ,string ,wend)))
		   (progn (funcall ,act (subseq ,string ,wbeg ,wend))
			  (setf ,wbeg (1+ ,wend)
				,wend ,wbeg)))))))))

Just "pass" a closure over a list as the action, and you get the
intended result. Even then, it's faster than anything else (at least
in CMUCL) I've come across for tokenizing simple strings (but this
only matters if you've got a lot of string to tokenize).

BTW, your loop also produces empty strings on multiple newlines. I
don't claim to be an expert on tokenizing sequences in CL, but more
than a few other pieces of code I've come across do the same - the
workaround is usually not very clean. For example, the entire first
cond clause in the above macro is devoted to just this problem.

If anyone spots a bug in this macro^ I'd like to hear about it (yes, I
actually use this code! stop laughing!).

Vladimir

* - I hope this will start a do vs. loop flame war, revisiting another
    classic c.l.l. discussion topic in the same thread. Actually, I
    was convinced I wrote this using loop until I dug up the source -
    now I'm pretty convinced that at least the first revision used
    loop.

^ - I don't consider the double evaluation of the delimiters form a
    bug (it's a *feature* dammit!). If you don't like it, throw
    another let around the whole mess. And yes, test and char-accessor
    are supposed to be symbols/lambda forms (it's dirty, and it works,
    fast, and HOFs are overrated anyway).
From: Tayss
Subject: Re: Loop is cool
Date: 
Message-ID: <5627c6fa.0311140651.91a9709@posting.google.com>
Man, does everyone have a pet split function?  Mine splits on
arbitrary strings and chars, defaulting to whitespace.  It was
tail-recursive, then converted to do/psetf after testing.  (Soon I'll
learn that series stuff at the end of cltl2; hope clisp supports it.)


> BTW, your loop also produces empty strings on multiple newlines. I
> don't claim to be an expert on tokenizing sequences in CL, but more
> than a few other pieces of code I've come across do the same - the
> workaround is usually not very clean. For example, the entire first
> cond clause in the above macro is devoted to just this problem.

Hmm, I'd think putting a big (remove "" answer :test #'string=) should
do the trick.
From: Joe Marshall
Subject: Re: Loop is cool
Date: 
Message-ID: <he17nfz7.fsf@ccs.neu.edu>
··········@yahoo.com (Tayss) writes:

>> BTW, your loop also produces empty strings on multiple newlines. I
>> don't claim to be an expert on tokenizing sequences in CL, but more
>> than a few other pieces of code I've come across do the same - the
>> workaround is usually not very clean. For example, the entire first
>> cond clause in the above macro is devoted to just this problem.

Why is this a `problem'?  If someone puts in blank lines, I'd expect
blank strings.  If you omit them, then you are losing information.
From: Tayss
Subject: Re: Loop is cool
Date: 
Message-ID: <5627c6fa.0311141031.a74f09c@posting.google.com>
Joe Marshall <···@ccs.neu.edu> wrote in message news:<············@ccs.neu.edu>...
> ··········@yahoo.com (Tayss) writes:
> 
> >> BTW, your loop also produces empty strings on multiple newlines. I
> >> don't claim to be an expert on tokenizing sequences in CL, but more
> >> than a few other pieces of code I've come across do the same - the
> >> workaround is usually not very clean. For example, the entire first
> >> cond clause in the above macro is devoted to just this problem.
> 
> Why is this a `problem'?  If someone puts in blank lines, I'd expect
> blank strings.  If you omit them, then you are losing information.

I'm not the person you quoted, and I personally don't think it's a
problem.  OTOH, the only cl split util I looked at (McIntire's
com-lisp-utils) does filter empty strings.

fyi, the python split util doesn't do this filtering, which was the
one I emulated for my own cl implementation.
From: Joe Marshall
Subject: Re: Loop is cool
Date: 
Message-ID: <k762n5yr.fsf@ccs.neu.edu>
··········@yahoo.com (Tayss) writes:

> Joe Marshall <···@ccs.neu.edu> wrote in message news:<············@ccs.neu.edu>...
>> ··········@yahoo.com (Tayss) writes:
>> 
>> >> BTW, your loop also produces empty strings on multiple newlines. I
>> >> don't claim to be an expert on tokenizing sequences in CL, but more
>> >> than a few other pieces of code I've come across do the same - the
>> >> workaround is usually not very clean. For example, the entire first
>> >> cond clause in the above macro is devoted to just this problem.
>> 
>> Why is this a `problem'?  If someone puts in blank lines, I'd expect
>> blank strings.  If you omit them, then you are losing information.
>
> I'm not the person you quoted, and I personally don't think it's a
> problem.  

My apologies!  I cut too much.
From: Tayss
Subject: Re: Loop is cool
Date: 
Message-ID: <5627c6fa.0311141141.75f6f847@posting.google.com>
Joe Marshall <···@ccs.neu.edu> wrote in message news:<············@ccs.neu.edu>...
> Why is this a `problem'?  If someone puts in blank lines, I'd expect
> blank strings.  If you omit them, then you are losing information.

Let me clarify my last post (which hasn't shown up on google).  Python
2.3's behavior apparently is to filter empty strings iff the user uses
the default option of splitting on whitespace, or specifies None. 
Otherwise, it will return 1+ number of separators found in the string.
 I will look at the source later to see if they're up to any extra
madness.
From: Vladimir S.
Subject: Re: Loop is cool
Date: 
Message-ID: <87d6btbwvw.fsf@shawnews.cg.shawcable.net>
You're absolutely right. I confused the issue of string-tokenizing
(which seems to be a fuzzy, ambiguous concept that I define as being
string-splitting where the delimiters are considered garbage) and
general string-splitting. Looking at the purpose of Christian's
utility, giving blank strings is more likely than not exactly what he
wants. The split-seq function from string.lisp in CLOCC's CLLIB (which
I misidentified in my previous post) gives the option of either
behavior with a keyword parameter (but defaults to "tokenizing"
behavior).

Vladimir
From: Greg Menke
Subject: Re: Loop is cool
Date: 
Message-ID: <m34qx66ebe.fsf@europa.pienet>
··········@yahoo.com (Tayss) writes:

> Man, does everyone have a pet split function?  Mine splits on
> arbitrary strings and chars, defaulting to whitespace.  It was
> tail-recursive, then converted to do/psetf after testing.  (Soon I'll
> learn that series stuff at the end of cltl2; hope clisp supports it.)

It seems to be one of the canonical "learning Lisp" exercises.

"split-sequence" aka "partition" is a pretty reasonable and portable
implementation of that does lots of the nice things that a new Lisp
programmer won't be aware they need.  cliki.net has the link.

Gregm
From: Petter Gustad
Subject: Re: Loop is cool
Date: 
Message-ID: <87brreo3mn.fsf@zener.home.gustad.com>
Christian Lynbech <·················@ericsson.com> writes:

> I am in the process of learning more about loop, and just came up with
> following example why `loop' rocks.

[ neat example snipped ]

Yes. Mastering loop gives you a warm feeling. I can recall a similar
feeling when I had to convert a bit vector to integer:

(defun bvi (bv)
  "bit-vector to integer conversion"
  (loop for bit across bv and
        i from 0
        sum (ash bit i)))

(format nil "~B" (bvi #*110100001)) -> "100001011"

Not a the most optimal implementation, but simple...

Petter

-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?