From: Robert Miller
Subject: help!! (run-line encoding)
Date: 
Message-ID: <353ed405.15678005@nntp.lse.fullfeed.com>
Can anyone help me create a function(s) to run-line encode a binary
list???   (common lisp)
i.e.

>(compress '(1110100001))
((3 1) 0 1 (4 0) 1)

From: Kent M Pitman
Subject: Re: help!! (run-line encoding)
Date: 
Message-ID: <sfwbttt72oa.fsf@world.std.com>
······@usc.edu (Robert Miller) writes:

> Can anyone help me create a function(s) to run-line encode a binary
> list???   (common lisp)
> i.e.
> 
> >(compress '(1110100001))
> ((3 1) 0 1 (4 0) 1)

This looks like a homework problem.

Either that, or you need to explain why you think this will be an
improvement in storage.  The output representation looks to be using
more storage than the input, so the choice of the name COMPRESS is 
funny unless this is an academic exercise.
From: Lyman S. Taylor
Subject: Re: help!! (run-line encoding)
Date: 
Message-ID: <6hme4b$6gm@pravda.cc.gatech.edu>
In article <···············@world.std.com>,
Kent M Pitman  <······@world.std.com> wrote:
>······@usc.edu (Robert Miller) writes:
...
>> >(compress '(1110100001))
>> ((3 1) 0 1 (4 0) 1)
....
>improvement in storage.  The output representation looks to be using
>more storage than the input, so the choice of the name COMPRESS is 
>funny unless this is an academic exercise.

 Perhaps, he really didn't mean to compress a list of ONE element.  :-)  

 (compress '( 1 1 1 0 1 0 0 0 0 1 1 )  )  => ( (3 1) 0 1 (4 0) 1)

 Actually manages to be two cons cells less (if I count correctly).

 Maybe that's run-length( run-line) encoding... 

 This does smack of a homework problem so I'll pass on offering up a 
 solution.... although I'd imagine that (= (first lst) (first (rest lst)))



   

 
-- 

Lyman S. Taylor			"Because no matter where you go,
(·····@cc.gatech.edu)			there you are."
						Buckaroo Banzai
From: Link Davis
Subject: Re: help!! (run-line encoding)
Date: 
Message-ID: <6ht10j$sj5$1@newsfep2.sprintmail.com>
Yeah, it does look like homework...  This was in the 1st for 2nd chapter of
ANSI Common Lisp by Paul Graham.  I don't recall if he gave it as an example
or a as a problem.  I think as an example.

Lyman S. Taylor wrote in message <··········@pravda.cc.gatech.edu>...
>In article <···············@world.std.com>,
>Kent M Pitman  <······@world.std.com> wrote:
>>······@usc.edu (Robert Miller) writes:
>...
>>> >(compress '(1110100001))
>>> ((3 1) 0 1 (4 0) 1)
>....
>>improvement in storage.  The output representation looks to be using
>>more storage than the input, so the choice of the name COMPRESS is
>>funny unless this is an academic exercise.
>
> Perhaps, he really didn't mean to compress a list of ONE element.  :-)
>
> (compress '( 1 1 1 0 1 0 0 0 0 1 1 )  )  => ( (3 1) 0 1 (4 0) 1)
>
> Actually manages to be two cons cells less (if I count correctly).
>
> Maybe that's run-length( run-line) encoding...
>
> This does smack of a homework problem so I'll pass on offering up a
> solution.... although I'd imagine that (= (first lst) (first (rest lst)))
>
>
>
>
>
>
>--
>
>Lyman S. Taylor "Because no matter where you go,
>(·····@cc.gatech.edu) there you are."
> Buckaroo Banzai
From: Kent M Pitman
Subject: Re: help!! (run-line encoding)
Date: 
Message-ID: <sfwiunxmo4s.fsf@world.std.com>
"Link Davis" <·········@sprintmail.com> writes:

> Lyman S. Taylor wrote in message <··········@pravda.cc.gatech.edu>...
>
> > Perhaps, he really didn't mean to compress a list of ONE element.  :-)
> >
> > (compress '( 1 1 1 0 1 0 0 0 0 1 1 )  )  => ( (3 1) 0 1 (4 0) 1)
> >
> > Actually manages to be two cons cells less (if I count correctly).
>
> Yeah, it does look like homework...  This was in the 1st for 2nd chapter of
> ANSI Common Lisp by Paul Graham.  I don't recall if he gave it as an example
> or a as a problem.  I think as an example.

Ah, I see now.

And here I thought he was looking for someone to tell him about 
(multiple-value-bind (quotient remainder) (truncate n 2) ...)
or (ash n -1) or (ldb (byte 1 0) n) so he could save all the
consing it would take to do it the "easy way" with FORMAT's ~B
and SUBSEQ and CHAR.