-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3.txt
33 lines (25 loc) · 762 Bytes
/
3.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#lang scheme/base
;------------------------------------------------1
#lang scheme/base
(define (list-fib-squares-a n)
(let loop ((fib0 0) (fib1 1) (i 1) (result '()))
(if(and (<= i n)(integer? n))
(loop fib1 (+ fib0 fib1) (+ i 1) (cons fib1 result))
(map (lambda (x) (* x x)) (reverse result))
)
)
)
(define (list-fib-squares-b n)
(let loop ((fib0 0) (fib1 1) (i 1) (result '()))
(if(and (<= i n)(integer? n))
(loop fib1 (+ fib0 fib1) (+ i 1) (cons fib1 result))
(foldl (lambda (x y) (cons (* x x) y)) '() result)
)
)
)
;------------------------------------------------2
(define (process lst)
(let ((first-elem (foldl * 1 (car lst))))
(filter (lambda (x) (> (foldl + 0 x) first-elem)) lst)
)
)