[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: Common Lisp and the Little Schemer

William James

6/6/2015 8:22:00 AM

Gabe Garza wrote:

> (defun sum-squares (list)
> (reduce #'+ (mapcar (lambda (a) (* a a)) list)))

Gauche Scheme:

(define (sum-squares numbers)
(fold (^(x acc) (+ acc (* x x))) 0 numbers))

Another way:

(use srfi-42 :only (sum-ec))
(define (sum-squares numbers)
(sum-ec (:list x numbers) (* x x)))

Another way:

(use srfi-42 :only (fold-ec))
(define (sum-squares numbers)
(fold-ec 0 (:list x numbers) (* x x) +))

--
"A concerted effort that aims at educating Swedes that immigrants are a
blessing to their country must be pursued," said Sahlin, stressing that her
compatriots must accept that the new Sweden is multi-cultural.... "Like it or
not, this is the new Sweden."
fjordman.blogspot.ca/2005/05/is-swedish-democracy-collapsing.html

1 Answer

William James

11/28/2015 6:54:00 AM

0

WJ wrote:

> Gabe Garza wrote:
>
> > (defun sum-squares (list)
> > (reduce #'+ (mapcar (lambda (a) (* a a)) list)))

Ocaml:

open List;;

let sum_squares xs = map2 ( * ) xs xs |> fold_left (+) 0;;

--
Turkish teens gang-raped a 16-year-old girl ... and assaulted her with a
bottle. Even when the bottle broke, they continued her attack, eventually
severing her intestine and her uterus.... German privacy laws meant that the
attack went entirely unreported in the German press.
http://www.liveleak.com/view?i=807_...