Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

help!! (run-line encoding)

1 view
Skip to first unread message

Lyman S. Taylor

unread,
Apr 22, 1998, 3:00:00 AM4/22/98
to

In article <sfwbttt...@world.std.com>,
Kent M Pitman <pit...@world.std.com> wrote:
>mil...@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,
(ly...@cc.gatech.edu) there you are."
Buckaroo Banzai

Robert Miller

unread,
Apr 23, 1998, 3:00:00 AM4/23/98
to

Can anyone help me create a function(s) to run-line encode a binary
list??? (common lisp)
i.e.

Kent M Pitman

unread,
Apr 23, 1998, 3:00:00 AM4/23/98
to

mil...@usc.edu (Robert Miller) writes:

This looks like a homework problem.

Either that, or you need to explain why you think this will be an

Link Davis

unread,
Apr 25, 1998, 3:00:00 AM4/25/98
to

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 <6hme4b$6...@pravda.cc.gatech.edu>...


>In article <sfwbttt...@world.std.com>,
>Kent M Pitman <pit...@world.std.com> wrote:
>>mil...@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.
>

Kent M Pitman

unread,
Apr 26, 1998, 3:00:00 AM4/26/98
to

"Link Davis" <link...@sprintmail.com> writes:

> Lyman S. Taylor wrote in message <6hme4b$6...@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.


0 new messages