Message from discussion rant: LISP is non-functional!
Received: by 10.68.221.4 with SMTP id qa4mr16181370pbc.7.1330909219693;
Sun, 04 Mar 2012 17:00:19 -0800 (PST)
From: Kaz Kylheku <k...@kylheku.com>
Subject: Re: rant: LISP is non-functional!
Date: Mon, 5 Mar 2012 01:00:18 +0000 (UTC)
Organization: Aioe.org NNTP Server
User-Agent: slrn/pre1.0.0-18 (Linux)
X-Notice: Filtered by postfilter v. 0.8.2
On 2012-03-04, WJ <w_a_x_...@yahoo.com> wrote:
> Antsan wrote:
>> I didn't know Lisp was supposed to be purely functional. And I also didn't
>> know that using lists somehow made functional programming impossible. This
>> is even more puzzling to me, as I never ever used a modifying function on a
>> list, as I see no reason to do that - as opposed to modifying arrays.
> You never used push, pop, or sort?
Bzzt: push and pop don't modify lists. They modify places.
(Of course, they can modify a list if you make a lsit place their
target, e.g. (pop (cdr list)) or (push 42 (third list))).
I.e. push and pop show that not only is functional programming possible
on lists, but also a kind of imperative programming that never destroys
(Let us coin a new word: "funperative programming". This is a style whereby
mutations are restricted to local variables, and data structures that
are guarnateed not to be shared because they were locally allocated in
the same scope. Functions written in funperative style appear functional
to outsiders, but have pragmatic innards.)
Maybe Antsan has a non-destructive sort routine which returns a newly allocated
sorted list. This is easy to write "funperatively": copy-list followed by sort.