blob: 62852a05f0703e22c8ec66b6ef453d9b0ec39813 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
(use-modules (srfi srfi-41))
(define (square x)
(* x x))
(define naturals (stream-from 1))
(define squares
(stream-map square naturals))
(define (sum-stream n stream)
(stream-fold + 0 (stream-take n stream)))
(define (sum-square-difference n)
(- (square (sum-stream n naturals))
(sum-stream n squares)))
(sum-square-difference 100)
|