aboutsummaryrefslogtreecommitdiff
path: root/files
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2024-08-30 17:01:28 +0300
committerkartofen <mladenovnasko0@gmail.com>2024-08-30 17:01:28 +0300
commite1ceef73192f0300ff9b10ba9a16475fbebeaa5f (patch)
tree0cb2bc5336a522b965c1d171b433044591721e20 /files
parentde3a062bfc206bf0373f96f4f6cc8c74ffcbab48 (diff)
proper repl, stylistic changes, removed trailing whitespace
Diffstat (limited to 'files')
-rw-r--r--files/test-lambda.l41
1 files changed, 34 insertions, 7 deletions
diff --git a/files/test-lambda.l b/files/test-lambda.l
index e088ad6..71ef0bd 100644
--- a/files/test-lambda.l
+++ b/files/test-lambda.l
@@ -4,20 +4,47 @@
'(a b ,((lambda (a) '(test . ,a)) 69) c d)
-(define fib (lambda (c) (fib-rec 0 1 0 c)))
-(define fib-rec (lambda (a b n c)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define fib (lambda (c) (_fib 0 1 0 c)))
+(define _fib (lambda (a b n c)
(if (= n c)
b
- (fib-rec b (+ a b) (+ n 1) c))))
+ (_fib b (+ a b) (+ n 1) c))))
+
+
-(define do (lambda (c f) (do-rec f 0 0 c)))
-(define do-rec (lambda (f r n c)
+
+(define do (lambda (c f) (_do f '() 0 c)))
+
+(define _do (lambda (f r n c)
(if (= n c) r
- (do-rec f (f n) (+ n 1) c))))
+ (_do f (cons (f n) r) (+ n 1) c))))
;; comment
;; another comment
;; fib(13)
-(do 10 (lambda (n) (display (fib n)))) ; comment
+;(do 10 (lambda (n) (display (fib n)))) ; comment
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define +list (lambda (l) (_+list l 0)))
+(define _+list (lambda (l acc)
+ (if (nil? l)
+ acc
+ (_+list (cdr l) (+ acc (car l))))))
+(+list '(10 12))
+
+(define * (lambda (a n) (+list (do n (lambda (n) a)))))
+
+(* 9 7)
+
+(define reverse (lambda (l) (_reverse l '())))
+(define _reverse (lambda (l n)
+ (if (nil? l) n
+ (_reverse (cdr l) (cons (car l) n)))))
+
+;; (+list (do 100 (lambda (n) (fib n))))
+(reverse (do 100 (lambda (n) (fib n))))