summaryrefslogtreecommitdiffstats
path: root/final_project
diff options
context:
space:
mode:
authorbnewbold <bnewbold@eta.mit.edu>2009-05-08 03:35:05 -0400
committerbnewbold <bnewbold@eta.mit.edu>2009-05-08 03:35:05 -0400
commit2aad489f2c311a8fdfed8419fdf523f055f0296d (patch)
tree4d21f1ad6768f9fb4b3c9e2307c9e3d13e0c882a /final_project
parentbeaad775a6621f0896f0f5b9b40bd9e25ec9d8c7 (diff)
download6.945-2aad489f2c311a8fdfed8419fdf523f055f0296d.tar.gz
6.945-2aad489f2c311a8fdfed8419fdf523f055f0296d.zip
oh yeah
Diffstat (limited to 'final_project')
-rw-r--r--final_project/work/description13
-rw-r--r--final_project/work/discovery.scm59
-rw-r--r--final_project/work/explore.scm31
-rw-r--r--final_project/work/notes1
4 files changed, 88 insertions, 16 deletions
diff --git a/final_project/work/description b/final_project/work/description
index 8768e08..a5c7977 100644
--- a/final_project/work/description
+++ b/final_project/work/description
@@ -8,7 +8,8 @@ sense of the word, but in the s-expression sense of the word) and determine
the set of procedures which /could/ be applied to it based on type predicates
and present these options interactively to the user in a useful manner.
-[Various optimizations to this process will be discussed]
+Lookup for an individual object is O([number of operators]) and O([number
+of predicates per operators]). Memoization could save time here if needed.
We will consider and demonstrate this system in the domains of a) the R5RS
Scheme builtin types and procedures and b) the scmutils types and special
@@ -23,8 +24,6 @@ Other domains this system could be applied to include:
Related problems (which could be covered by this work?):
chaining procedures (eg if f maps A->B and g maps B->C, then gof maps
A->C which might be what we want
- some kind
-
----------------
@@ -61,3 +60,11 @@ operators are displayed; it could also be done as a continuation so that the
first 10 would be displayed, then there would be a button to view the next 10
operators (eg, turn the search problem into a stream).
+
+-----------
+
+* predicate satisfaction search
+* predicate could be "this is a simple equation"
+* data un-corruption: have a validity predicate
+
+
diff --git a/final_project/work/discovery.scm b/final_project/work/discovery.scm
index 3fa138f..e3756ab 100644
--- a/final_project/work/discovery.scm
+++ b/final_project/work/discovery.scm
@@ -9,6 +9,8 @@
; If it isn't already....
;(load "ghelper")
+(define filter keep-matching-items)
+
; takes two lists: the first is a set of predicates and the second a set
; of arguments; if any of the predicates are #t for the args, win, else fail
(define (for-any? preds args)
@@ -137,21 +139,54 @@
-------------------- End Testing ------------------- |#
-(define (discover:apply-all . args)
- (filter (compose not null?)
- (map (lambda (oper)
- (if (symbol? oper)
- '()
- (list oper (apply oper args))))
- (apply discover:opers-for args))))
+; this is just what operators do
+(define (discover:apply-name name . args)
+ (let ((record (hash-table/get *generic-operator-table* name #f)))
+ (let ((succeed
+ (lambda (handler)
+ (apply handler args))))
+ (let per-arg
+ ((tree (operator-record-tree record))
+ (args args)
+ (fail
+ (lambda ()
+ (error:no-applicable-methods operator args))))
+ (let per-pred ((tree tree) (fail fail))
+ (cond ((pair? tree)
+ (if ((caar tree) (car args))
+ (if (pair? (cdr args))
+ (per-arg (cdar tree)
+ (cdr args)
+ (lambda ()
+ (per-pred (cdr tree) fail)))
+ (succeed (cdar tree)))
+ (per-pred (cdr tree) fail)))
+ ((null? tree)
+ (fail))
+ (else
+ (succeed tree))))))))
+
+(define (discover:thunklist-for . args)
+ (let ((names (apply discover:named-opers-for args)))
+ (cons args
+ (map (lambda (x)
+ (list x
+ (lambda ()
+ (apply discover:apply-name (cons x args)))))
+ names))))
+
+
+
+
+
+
+
+
+
+
-(discover:apply-all 2)
-
-(discover:named-opers-for 2)
-(environment-lookup (the-environment) 'sin)
-(one-like 4)
diff --git a/final_project/work/explore.scm b/final_project/work/explore.scm
new file mode 100644
index 0000000..526c8f0
--- /dev/null
+++ b/final_project/work/explore.scm
@@ -0,0 +1,31 @@
+
+; explore.scm
+
+; if it isn't already...
+;(load "ghelper")
+
+; just pass through to display
+(define explore:display
+ (make-generic-operator 1 display 'display))
+
+; just pass through to pp
+(define explore:pp
+ (make-generic-operator 1 pp 'pp))
+
+; show latex
+(define explore:show-latex
+ (make-generic-operator 1 #f 'show-latex))
+
+(assign-operation explore:show-latex se function?)
+(assign-operation explore:show-latex se matrix?)
+(assign-operation explore:show-latex se vector?)
+
+#| ----- Testing
+(explore:show-latex sin)
+; works as expected
+
+(explore:show-latex #(1 2 3 4))
+
+|# -----
+
+
diff --git a/final_project/work/notes b/final_project/work/notes
index 36793b1..6f5608a 100644
--- a/final_project/work/notes
+++ b/final_project/work/notes
@@ -1,4 +1,3 @@
-
Types in r5rS:
----------------------------------------------------------------
boolean, symbol, char, vector, pair, number, string, port, procedure