help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to improve the readability of (any) LISP or any highlevel functi


From: The Quiet Center
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 15:56:05 -0800 (PST)
User-agent: G2/1.0

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]

> Matz himself admitted that “...Ruby is a bad rip-off of Lisp... But it
> is nicer to ordinary people.”

yeah I guess the LOOP macro is where I got stuck in doing Lisp.

>
> Though every language I've worked in, I've never been half as
> productive as when I'm coding in Ruby.

I've done Perl at corporate level for 10 years and I've heard seasoned
Perl developers say the same thing.


>
> In particular, cross platform GUI application
> development seemed poor.

yeah, wxPython is the only thing for any scripting languages that
seemed to make very professional desktop UI programs.

>
> If you want to develop webpages, or bang out quick one time scripts,
> Ruby is hard to beat. For use at home, console applications are
> probably a tolerable price to pay for the incredible development speed
> and fantastic ease of maintenance Ruby will give your code.

yeah sinatra.rb looks nice for web dev and ruby on rails was a runaway
hit for awhile.

By the way, here's the Prolog solution to the compression problem I
posted earlier:



% http://sites.google.com/site/prologsite/prolog-problems/1

% Problem 1.08 - compress consecutive duplicates into a single
% list element

compress([], []).
compress([X,Y], [X,Y]) :- X \= Y.
compress([X,Y], [X])   :- X  = Y.

% problems writing other clauses (thanks RLa)

compress([X,Y|Z], [X|Z1])   :- X \= Y, compress([Y|Z], Z1).
compress([X,Y|Z], Z1)       :- X  = Y, compress([Y|Z], Z1).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]