🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.functional
Article #1153

Re: How to improve the readability of (any) LISP or any highlevel functional language to the level of FORTH ?

#1153
From: w_a_x_man
Date: Fri, 07 Jan 2011 09:41
21 lines
2556 bytes
On Jan 1, 5:56 pm, The Quiet Center <thequietcen...@gmail.com> wrote:

> How would you code this simple list compression problem in Ruby:
>
> 1.08 (**) Eliminate consecutive duplicates of list elements.
>     If a list contains repeated elements they should be replaced with
> a single copy of the element. The order of the elements should not be
> changed.
>
>     Example:
>     ?- compress([a,a,a,a,b,c,c,a,a,d,e,e,e,e],X).
>     X = [a,b,c,a,d,e]



(defun compress (stuff)
  (mapcon #'(lambda (x)
              (if (and (> (length x) 1) (eql (car x) (cadr x)))
                nil
                (list (car x))))
          stuff))
Technical Details
Message-ID: <fd19f2c5-30a8-4f24-9104-b8038e9d1a67@l32g2000yqc.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!l32g2000yqc.googlegroups.com!not-for-mail
References: <80ceeca0-1d32-47d1-ba96-feb4d9729c3a@v17g2000yqv.googlegroups.com> <87pqsgk8v9.fsf@kuiper.lan.informatimago.com> <ca15d8c3-86db-46fd-b35f-1a2596475769@n32g2000pre.googlegroups.com> <9e7a7683-a92a-4e88-a6f1-9e6a6bd2f057@z9g2000yqz.googlegroups.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 107f24,1641de092071599d
X-Google-NewGroupId: yes
X-Google-Thread: f4fd2,1641de092071599d
X-Google-NewGroupId: yes
X-Google-Thread: 103b8b,1641de092071599d
X-Google-NewGroupId: yes
X-Google-Thread: fd7c9,1641de092071599d
X-Google-NewGroupId: yes
X-Google-Thread: f907c,1641de092071599d
X-Google-NewGroupId: yes
X-Google-Attributes: gid4e63bbc566,gidf85ca024c1,gid39ae015015,gid2832dde05d,gidee3de009bc,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!l32g2000yqc.googlegroups.com!not-for-mail
From: w_a_x_man <w_a_x_man@yahoo.com>
Newsgroups: comp.lang.functional,comp.lang.lisp,gnu.emacs.help,comp.lang.forth,comp.lang.prolog
Subject: Re: How to improve the readability of (any) LISP or any highlevel
 functional language to the level of FORTH ?
Date: Fri, 7 Jan 2011 01:41:21 -0800 (PST)
Organization: http://groups.google.com
Lines: 21
Message-ID: <fd19f2c5-30a8-4f24-9104-b8038e9d1a67@l32g2000yqc.googlegroups.com>
References: <80ceeca0-1d32-47d1-ba96-feb4d9729c3a@v17g2000yqv.googlegroups.com>
 <87pqsgk8v9.fsf@kuiper.lan.informatimago.com> <ca15d8c3-86db-46fd-b35f-1a2596475769@n32g2000pre.googlegroups.com>
 <9e7a7683-a92a-4e88-a6f1-9e6a6bd2f057@z9g2000yqz.googlegroups.com>
NNTP-Posting-Host: 208.100.225.9
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1294393282 16369 127.0.0.1 (7 Jan 2011 09:41:22 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 7 Jan 2011 09:41:22 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: l32g2000yqc.googlegroups.com; posting-host=208.100.225.9; posting-account=vf5QpQoAAADgh9WOa2uZtoS1yoyJdEBw
User-Agent: G2/1.0
X-HTTP-UserAgent: Opera/9.80 (Windows NT 5.1; U; en) Presto/2.6.30 Version/10.63,gzip(gfe)