-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathquerier.scm
42 lines (38 loc) · 1.59 KB
/
querier.scm
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
34
35
36
37
38
39
40
41
42
(require 'schelog)
(require 'selector)
(require 'knowledgebase)
(module querier *
(import chicken scheme extras schelog selector knowledgebase)
;utility: query all answers, strip duplicates
(define (query-strip query)
(define (accum ls val)
(if (not val) ls
(accum (cons val ls) (%more))))
(let ((sols (list query)))
(strip-duplicates (accum sols (%more)))))
;query procedure. returns the stats and suggestion for 'client'.
;remove duplicates.
(define (es:query client)
(let ((query (%which (Client Ok-profile Requested Collateral-rating Financial-rating Yield Suggestion)
(%and (%credit client Ok-profile Collateral-rating Financial-rating Yield Suggestion)
(%is Client client)
(%requested-credit client Requested))))
(fun (lambda(x)
(display "\t")
(for-each (lambda(y) (display y) (display " ")) x)
(newline))))
(newline)
(for-each fun (car (query-strip query)))
(newline)))
(define (es:outcome outcome)
(let ((query (%which (Client Requested)
(%let (?Ok-profile= Collateral-rating= Financial-rating= Yield=)
(%and (%credit Client ?Ok-profile= Collateral-rating= Financial-rating= Yield= outcome)
(%requested-credit Client Requested)))))
(fun (lambda(x)
(for-each (lambda(y) (display (car y)) (display " = ") (display (cadr y)) (display " ")) x)
(newline))))
(newline)
(for-each fun (query-strip query))
(newline)))
)