🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.functional
Article #1195

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

#1195
From: w_a_x_man
Date: Sun, 02 Jan 2011 06:59
30 lines
2755 bytes
On Jan 1, 5:56 pm, The Quiet Center <thequietcen...@gmail.com> wrote:
> On Jan 1, 11:08 am, Nathan <nbeen...@gmail.com> wrote:
>
> > If you want a easy to read self-documenting functional language, look
> > into Ruby. I know personally that Ruby syntax was a big turn off to me
> > for several weeks (kind of like Lisp) but once you learn it, it
> > becomes the easiest to read of any programming language I've ever
> > experimented with. No contest.
>
> Well, Python was chosen over Ruby for MIT's rework of their intro to
> cs course because Python is multi-paradigm, whereas Ruby claims
> everything is an object.
>
> 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]
>

"aaaabccaadeeee".squeeze
    ==>"abcade"

p=nil; %w(a a a b c c a a d e e e).select{|x| x!=p && p=x}
    ==>["a", "b", "c", "a", "d", "e"]
Technical Details
Message-ID: <617eae48-d532-4eb1-aefa-b54ca3d23654@r19g2000prm.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!r19g2000prm.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: ee3de009bc,1641de092071599d
X-Google-Attributes: gidee3de009bc,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: ENGLISH,ASCII
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!r19g2000prm.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: Sat, 1 Jan 2011 22:59:32 -0800 (PST)
Organization: http://groups.google.com
Lines: 30
Message-ID: <617eae48-d532-4eb1-aefa-b54ca3d23654@r19g2000prm.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: 209.42.179.244
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1293951572 4185 127.0.0.1 (2 Jan 2011 06:59:32 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sun, 2 Jan 2011 06:59:32 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: r19g2000prm.googlegroups.com; posting-host=209.42.179.244; 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)