🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.functional
Article #1190

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

#1190
From: LanX
Date: Sun, 02 Jan 2011 03:45
56 lines
3575 bytes
> On Jan 1, 11:08 am, Nathan <nbeen...@gmail.com> wrote:
> > Matz himself admitted that “...Ruby is a bad rip-off of Lisp... But it
> > is nicer to ordinary people.”

Matz himself admitted in the earliest sources that Ruby is basically
Perl's semantics melted with Smalltalk's OOP syntax. All influences
from LISP come via Perl and many things criticized in Perl derive from
Larry's dedication to stay close to LISP in contrast to Guido who
breaks a lot in Python, e.g limiting lambdas to single expressions.

For sure Perl's scoping rules are much closer to eLISP's.

So in order to emulate eLISP I would rather chose a Perl or JavaScript
1.7 (with the additional "let"-command) but with the need of extra
macro functionality.

The problem are rather the datatypes which are far more static in
eLISP,
i.e.
1. no autocasting eLisp
2. hashes and arrays have only fixed length in eLisp
3. OTOH linked linked lists are not a  native type in most mainstream
languages.

> 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]
>

in Perl:
  DB<1>  my $l; print  grep { $l = $_  if  $_ ne $l }
(a,a,a,a,b,c,c,a,a,d,e,e,e,e);
abcade

from 5.10 one can use feature "state" to avoid an extra scope to make
$l lexical.

or define an explicit compress function:

  DB<2> sub compress { my $l;  grep { $l = $_  if  $_ ne $l }  @_ }

  DB<3> print compress(a,a,a,a,b,c,c,a,a,d,e,e,e,e);
abcade

(Nota bene, no explicit return needed like in LISP)

I suppose one can translate those approaches directly to Ruby, Python
or PHP. Newer JS versions call "grep" rather "filter" like in Python.
Technical Details
Message-ID: <aa0e6de9-26c7-4a98-93af-24d0188a3506@m35g2000vbn.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!m35g2000vbn.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: 39ae015015,1641de092071599d
X-Google-Attributes: gid39ae015015,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: ENGLISH,CP1252
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!m35g2000vbn.googlegroups.com!not-for-mail
From: LanX <lanx.perl@googlemail.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 19:45:43 -0800 (PST)
Organization: http://groups.google.com
Lines: 56
Message-ID: <aa0e6de9-26c7-4a98-93af-24d0188a3506@m35g2000vbn.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: 89.14.213.187
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1293939943 370 127.0.0.1 (2 Jan 2011 03:45:43 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sun, 2 Jan 2011 03:45:43 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: m35g2000vbn.googlegroups.com; posting-host=89.14.213.187; posting-account=W9fpQwoAAADZYmkl-8sXk1VPxG3rq-Pd
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.0.19)
 Gecko/2010040118 Ubuntu/8.10 (intrepid) Firefox/3.0.19,gzip(gfe)