all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Doug Hoffman <glidedog@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to improve the readability of (any) LISP or any highlevel functional language to the level of FORTH ?
Date: Thu, 06 Jan 2011 08:38:59 -0500	[thread overview]
Message-ID: <4d25c5f5$0$23761$14726298@news.sunsite.dk> (raw)
In-Reply-To: <87ei8rdo38.fsf@kuiper.lan.informatimago.com>

On 1/5/11 4:42 PM, Pascal J. Bourguignon wrote:
> Elena<egarrulo@gmail.com>  writes:
>
>> On Jan 5, 3:58 pm, Xah Lee<xah...@gmail.com>  wrote:
>>> The same expression in lisp style you get this
>>>
>>> /(+(-(b) √(+(^(b 2) -(*(4 a c))))) *(2 a))
>>>
>>> is it readable? Many lispers insist that its the most readable syntax.
>>
>> And here is why: http://blo.udoidio.info/2008/09/lisp-syntax-is-great.html
>
> He's wrong, the most readable is:
>
>    (divide (minus (square-root (minus (square b) (* 4 a c)))
>                   b)
>            2 a)
>
> or, for wanbees:
>
>    (/ (- (sqrt (- (square b) (* 4 a c))) b)
>       2 a)

Without getting into the issues of the proper way to handle the 
quadratic (this has been thoroughly hashed thru on comp.lang.forth) and 
sticking with just the simple equation as presented (I'll ignore the 
issue of taking the square root of negative numbers) I would make the 
following observations:

1)
 > (divide (minus (square-root (minus (square b) (* 4 a c))) b) 2 a)

This may be very readable for Lispers.  For others not so much.

2) The following is one way (of many) to approach this in standard Forth:

: quad f{ a b c -- root }
   b FNEGATE b FDUP F* 4e a c F* F* F- FSQRT F+ 2e a F* F/
   ;

-2e 7e 15e quad f.
-1.500000

Is it readable?  Unless you're a Forther I would say no.  But notice the 
complete lack of parentheses and operator precedences to resolve.  Any 
competent Forther could quickly see exactly what is going on.

3) We have available in Forth a FORmula TRANslator utility (it is not 
part of the official ANS Forth standard).  It could be applied in this 
situation as follows:

: quad2 f{ a b c -- root }
   f' (-b + sqrt(b^2 - 4*a*c))/(2*a)'
   ;

-2e 7e 15e quad2 f.
-1.500000

Is it readable?  I would say yes.  Note that it compiles *exactly* the 
same Forth code as quad in 2).

4) I am able to do a copy/paste of
    =(-b + sqrt(b^2 - 4*a*c))/(2*a)
    into an Excel spreadsheet and with the variables a, b, and c defined 
the spreadsheet gives the expected results.

-Doug


  reply	other threads:[~2011-01-06 13:38 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-01  7:04 How to improve the readability of (any) LISP or any highlevel functional language to the level of FORTH ? girosenth
2011-01-01 11:39 ` Elena
2011-01-01 14:15 ` Pascal J. Bourguignon
2011-01-01 16:08   ` Nathan
2011-01-01 18:05     ` Jan Burse
2011-01-01 23:56     ` The Quiet Center
2011-01-02  1:10       ` Jan Burse
2011-01-02  3:45       ` LanX
2011-01-02  4:04         ` LanX
2011-01-02  5:36           ` Nathan
2011-01-02  6:46             ` Paul Rubin
2011-01-02 15:01               ` LanX
2011-01-02 15:14                 ` Jerome Baum
2011-01-02 21:21                 ` Paul Rubin
2011-01-02  7:14             ` w_a_x_man
2011-01-02  6:59       ` w_a_x_man
2011-01-03 15:22         ` LanX
2011-01-02 14:07       ` Frank GOENNINGER
2011-01-07  9:41       ` w_a_x_man
2011-01-09 10:41         ` How to improve the readability of (any) LISP or any highlevelfunctional " WJ
2011-01-03 10:29     ` How to improve the readability of (any) LISP or any highlevel functional " Didier Verna
2011-01-03 13:05       ` Tim Harig
2011-01-04  4:49         ` rusi
2011-01-04  5:39           ` D Herring
2011-01-04  8:02             ` Tim Harig
2011-01-04  9:09               ` Nicolas Neuss
2011-01-04 10:00               ` Tim Bradshaw
2011-01-04 12:21                 ` Tim Harig
2011-01-04 12:23                   ` Tim Bradshaw
2011-01-04 13:33                     ` Tim Harig
2011-01-04 12:41                   ` Tamas K Papp
2011-01-04 23:32                 ` Tim X
2011-01-05  1:35                   ` [OT] LISP community advocacy [was Re: How to improve the readability of (any) LISP or any highlevel functional language to the level of FORTH ?] Tim Harig
2011-01-05  9:52                   ` How to improve the readability of (any) LISP or any highlevel functional language to the level of FORTH ? Tim Bradshaw
2011-01-04  6:24           ` Pascal J. Bourguignon
2011-01-04 15:43             ` Raffael Cavallaro
2011-01-04 10:18         ` Didier Verna
2011-01-01 22:50   ` girosenth
2011-01-02 21:11     ` Thien-Thi Nguyen
2011-01-03 16:21     ` José A. Romero L.
2011-01-03 18:03     ` jacko
2011-01-02 23:45   ` Chip Eastham
2011-01-01 18:27 ` How to improve the readability of Steve Revilak
2011-01-01 19:22 ` How to improve the readability of (any) LISP or any highlevel functional language to the level of FORTH ? prad
2011-01-01 23:56 ` Pascal Costanza
2011-01-02  5:39   ` D Herring
2011-01-02 14:17     ` Frank GOENNINGER
2011-01-02 14:53       ` Jerome Baum
2011-01-02 14:58         ` LanX
2011-01-02 17:55     ` Bernd Paysan
2011-01-03 18:07   ` jacko
2011-01-02 12:59 ` Doug Hoffman
2011-01-02 19:14   ` w_a_x_man
2011-01-03  5:20     ` Elizabeth D Rather
2011-01-03 10:48     ` MarkWills
2011-01-03 15:13       ` LanX
2011-01-03 18:20     ` jacko
2011-01-03 18:22     ` jacko
2011-01-03 10:18 ` Didier Verna
2011-01-04  6:47 ` pineapple
2011-01-04 14:14   ` P.M.Lawrence
2011-01-05 14:58 ` Xah Lee
2011-01-05 16:21   ` Andrew Haley
2011-01-05 21:29     ` Pascal J. Bourguignon
2011-01-06  8:57       ` Jonathan Groll
2011-01-07  5:36     ` Xah Lee
2011-01-07 13:28       ` Andrew Haley
2011-01-07 16:19         ` Xah Lee
2011-01-05 17:59   ` Elena
2011-01-05 20:13     ` Xah Lee
2011-01-05 21:42     ` Pascal J. Bourguignon
2011-01-06 13:38       ` Doug Hoffman [this message]
2011-01-06 19:20         ` Pascal J. Bourguignon
2011-01-07  0:09           ` w_a_x_man
2011-01-07 12:04           ` Doug Hoffman
2011-01-06 22:59   ` Xah Lee
2011-01-07 11:47     ` Jan Burse
2011-01-21 10:03       ` rupertlssmith
2011-01-21 16:08         ` Jan Burse
2011-01-21 21:43           ` D. J. Penton
2011-01-18 22:55 ` m_l_g3
2011-01-19 13:45   ` Doug Hoffman
2011-01-21 16:15   ` Jan Burse
  -- strict thread matches above, loose matches on Subject: below --
2011-01-02 16:50 Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='4d25c5f5$0$23761$14726298@news.sunsite.dk' \
    --to=glidedog@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.