[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: Why don't people like lisp?

William James

7/30/2015 8:12:00 PM

Rmagere wrote:

> >>> Here's a more realistic example that illustrates exactly the
> >>> opposite point. Take the task of finding the sum of the square of a
> >>> bunch of numbers.
> >>> Do people really think to themselves when they do this task:
> >>> Umm first make a variable called sum
> >>> then set that variable sum to zero.
> >>> Then get the next number in the list,
> >>> square it,
> >>> add it to the old value of sum,
> >>> store the resulting value into sum,
> >>> then get the next variable,etc....
> >>>
> >>> No they they think: sum up the square of a bunch of numbers.
> >>> This has an almost direct translation to the lisp style:
> >>> (apply '+ (mapcar #'(lambda(x)(* x x)) numlist)).
> >> Well..
> >> sum (map (\x -> x ** 2) [1..10])
> >> in Haskell, or
> >> sum (map ((lambda x: x ** 2), range(1,11)))
> >
> > Too much line noise ;-)
> >
> > sum([x*x for x in range(1,11)])
> >
>
> Then I would say that a clearer way to express what a person think is:
> (loop for number in numberlist sum (expt number power))


Gauche Scheme:

(use srfi-42 :only (sum-ec))
(sum-ec (: x 1 11) (* x x))
===>
385

--
An important part of the explanation is the role of mass media in Sweden. Not a
single TV-program, radio program, or big newspaper would give space to critics
of the multicultural project.
fjordman.blogspot.ca/2005/05/is-swedish-democracy-collapsing.html