Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit377a71e7d657cda69f5fab88e4fcb5310b7e83ea (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-10-27 11:02:52 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-10-27 11:02:52 +0300
Files8da76590efbe6158d4f19f51d3f82dc6b8546d4b
uni-projects-377a71e7d657cda69f5fab88e4fcb5310b7e83ea.tar
uni-projects-377a71e7d657cda69f5fab88e4fcb5310b7e83ea.tar.gz
uni-projects-377a71e7d657cda69f5fab88e4fcb5310b7e83ea.zip
Parenteed80989c03e8852e03042a61112c2d3b7662f0f (diff)
[FP/P04] Added work from practicum
1 files changed, 46 insertions, 0 deletions
-rw-r--r--Year 2/Functional Programming/04-Practice-27.10.2022.rkt46
diff --git a/Year 2/Functional Programming/04-Practice-27.10.2022.rkt b/Year 2/Functional Programming/04-Practice-27.10.2022.rkt
new file mode 100644
index 0000000..cfb1933
--- /dev/null
+++ b/Year 2/Functional Programming/04-Practice-27.10.2022.rkt
@@ -0,0 +1,46 @@
+#lang racket
+
+;;; Exercise 01
+
+(define (10^len n)
+ (if (= n 0)
+ 1
+ (* (10^len (quotient n 10)) 10)))
+
+(define (substr? a b)
+ (define (calc-iter b comp)
+ (cond [(= b 0) #f]
+ [(= (remainder (- b a) comp) 0) #t]
+ [else (calc-iter (quotient b 10) comp)]))
+ (calc-iter b (10^len a)))
+
+(substr? 123 5123783)
+
+;;; Exercise 02
+
+(define (my-identity x)
+ x)
+
+(define (my-compose f g)
+ (lambda (x) (f (g x))))
+
+(define (my-negate p?)
+ (not p?))
+
+(define (my-curry f x)
+ ((curry f) x))
+
+;;; Exercise 03
+
+(define (difference F a b)
+ (- (F a) (F b)))
+
+;;; Exercise 04
+
+(define f
+ (lambda (x) (* 2 x)))
+
+;;; Exercise 05
+
+(define (derive f eps)
+ (lambda (x) (/ (- (f (+ x eps)) (f x)) eps)))