summaryrefslogtreecommitdiffstats
path: root/final_project/work/discovery-examples.scm
diff options
context:
space:
mode:
Diffstat (limited to 'final_project/work/discovery-examples.scm')
-rw-r--r--final_project/work/discovery-examples.scm58
1 files changed, 34 insertions, 24 deletions
diff --git a/final_project/work/discovery-examples.scm b/final_project/work/discovery-examples.scm
index 45ae2ea..e525252 100644
--- a/final_project/work/discovery-examples.scm
+++ b/final_project/work/discovery-examples.scm
@@ -35,34 +35,26 @@
;Value: .15384615384615385
(discover:opers-for 6.5)
-;Value 57: (#[compound-procedure 38 operator] thingaling)
+;Value 52: (inverse #[compound-procedure 49 operator])
(discover:named-opers-for 6.5)
-;Value 58: (thingaling)
+;Value 53: (inverse)
(discover:named-opers-for 1 2)
-;Value 81: (plus minus)
-
-;;; this stuff is just play crap
-
-(car (hash-table->alist *generic-operator-table*))
-
-(caadr (hash-table/get *generic-operator-table* inverse #f))
-
-(environment-bound-names (the-environment))
+;Value 54: (plus minus)
(environment-lookup (the-environment) 'inverse)
-
-
-(inverse '( (1 2 3)
- (0 1 2)
- (0 0 1)))
+;Value 49: #[compound-procedure 49 operator]
(hash-table/get *generic-operator-table* inverse #f)
+;Value 59: (1 (#[compound-procedure 57] . #[compound-procedure 60]) (#[compound-procedure 61] . #[compound-procedure 62]))
+
(hash-table/get *generic-operator-table* minus #f)
+;Value 63: (2 (#[compound-procedure 56 any?] (#[compound-procedure 56 any?] . #[arity-dispatched-procedure 28])))
(hash-table-size *generic-operator-table*)
-;Value: 92 ;this is for mechanics
+;Value: 6 ; for this file
+;Value: 92 ; for scmutils
;this prints all keys line by line
(for-each
@@ -70,7 +62,6 @@
(display x))
(hash-table/key-list *generic-operator-table*))
-
(define add1 (make-generic-operator 1 #f 'add1))
(define sub1 (make-generic-operator 1 #f 'sub1))
(define double (make-generic-operator 1 #f 'double))
@@ -84,17 +75,36 @@
(and (number? n)
(not (zero? n)))))
-(add1 4)
-;(sub1 'b)
-
(discover:apply-all 3)
+;Value 89: (1/3 4 9 2 6)
(discover:satisfy (lambda (x) (eq? x 9)) (/ 1 2))
+;Value 35: (9)
+
(discover:satisfy-sequence (lambda (x) (eq? x 9)) (/ 1 2))
+;Value 36: (((9) square double add1) ((9) square add1 inverse))
+
(discover:satisfy-sequence (lambda (x) (eq? x 49)) (/ 5 6))
+;Value 37: (((49) square sub1 inverse sub1))
+
+(define (prime? n)
+ (cond ((null? n) #f)
+ ((not (integer? n)) #f)
+ ((> 0 n) #f)
+ (else (let lp ((m 2))
+ (cond ((> m (sqrt n)) #t)
+ ((integer? (/ n m)) #f)
+ (else (lp (+ m 1))))))))
+
+(prime? 47)
+; #t
+
+(discover:satisfy-sequence prime? (/ 5 6))
+;Value 39: (((5) inverse sub1 inverse))
+
+(discover:satisfy-sequence prime? 923)
+;Value 44: (((1847) add1 double))
-(square (sqrt 2))
-(sqrt 2)
-(square 3)
+(discover:named-opers)